Skip to content

Commit

Permalink
Switch to latest stable Gemini 1.5 Flash model
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheard committed Jun 10, 2024
1 parent 5478400 commit 1ab556a
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Examples/GenerativeAICLI/Sources/GenerateContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ struct GenerateContent: AsyncParsableCommand {
if let modelName {
return modelName
} else {
return "gemini-1.5-flash-latest"
return "gemini-1.5-flash"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ConversationViewModel: ObservableObject {
private var chatTask: Task<Void, Never>?

init() {
model = GenerativeModel(name: "gemini-1.5-flash-latest", apiKey: APIKey.default)
model = GenerativeModel(name: "gemini-1.5-flash", apiKey: APIKey.default)
chat = model.startChat()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class FunctionCallingViewModel: ObservableObject {

init() {
model = GenerativeModel(
name: "gemini-1.5-flash-latest",
name: "gemini-1.5-flash",
apiKey: APIKey.default,
tools: [Tool(functionDeclarations: [
FunctionDeclaration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PhotoReasoningViewModel: ObservableObject {
private var model: GenerativeModel?

init() {
model = GenerativeModel(name: "gemini-1.5-flash-latest", apiKey: APIKey.default)
model = GenerativeModel(name: "gemini-1.5-flash", apiKey: APIKey.default)
}

func reason() async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SummarizeViewModel: ObservableObject {
private var model: GenerativeModel?

init() {
model = GenerativeModel(name: "gemini-1.5-flash-latest", apiKey: APIKey.default)
model = GenerativeModel(name: "gemini-1.5-flash", apiKey: APIKey.default)
}

func summarize(inputText: String) async {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ For example, with just a few lines of code, you can access Gemini's multimodal c
generate text from text-and-image input:

```swift
let model = GenerativeModel(name: "gemini-1.5-flash-latest", apiKey: "YOUR_API_KEY")
let model = GenerativeModel(name: "gemini-1.5-flash", apiKey: "YOUR_API_KEY")
let cookieImage = UIImage(...)
let prompt = "Do these look store-bought or homemade?"

Expand Down
4 changes: 2 additions & 2 deletions Sources/GoogleAI/GenerativeModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public final class GenerativeModel {
/// Initializes a new remote model with the given parameters.
///
/// - Parameters:
/// - name: The name of the model to use, for example `"gemini-1.5-pro-latest"`; see
/// - name: The name of the model to use, for example `"gemini-1.5-flash"`; see
/// [Gemini models](https://ai.google.dev/models/gemini) for a list of supported model names.
/// - apiKey: The API key for your project.
/// - generationConfig: The content generation parameters your model should use.
Expand Down Expand Up @@ -83,7 +83,7 @@ public final class GenerativeModel {
/// Initializes a new remote model with the given parameters.
///
/// - Parameters:
/// - name: The name of the model to use, e.g., `"gemini-1.5-pro-latest"`; see
/// - name: The name of the model to use, e.g., `"gemini-1.5-flash"`; see
/// [Gemini models](https://ai.google.dev/models/gemini) for a list of supported model names.
/// - apiKey: The API key for your project.
/// - generationConfig: The content generation parameters your model should use.
Expand Down
22 changes: 7 additions & 15 deletions Tests/GoogleAITests/GoogleAITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,29 @@ final class GoogleGenerativeAITests: XCTestCase {
let systemInstruction = ModelContent(role: "system", parts: [.text("Talk like a pirate.")])

// Permutations without optional arguments.
let _ = GenerativeModel(name: "gemini-1.5-pro-latest", apiKey: "API_KEY")
let _ = GenerativeModel(name: "gemini-1.5-flash", apiKey: "API_KEY")
let _ = GenerativeModel(name: "gemini-1.5-flash", apiKey: "API_KEY", safetySettings: filters)
let _ = GenerativeModel(name: "gemini-1.5-flash", apiKey: "API_KEY", generationConfig: config)
let _ = GenerativeModel(
name: "gemini-1.5-pro-latest",
apiKey: "API_KEY",
safetySettings: filters
)
let _ = GenerativeModel(
name: "gemini-1.5-pro-latest",
apiKey: "API_KEY",
generationConfig: config
)
let _ = GenerativeModel(
name: "gemini-1.5-pro-latest",
name: "gemini-1.5-flash",
apiKey: "API_KEY",
systemInstruction: systemInstruction
)

let _ = GenerativeModel(
name: "gemini-1.5-pro-latest",
name: "gemini-1.5-flash",
apiKey: "API_KEY",
systemInstruction: "Talk like a pirate."
)

let _ = GenerativeModel(
name: "gemini-1.5-pro-latest",
name: "gemini-1.5-flash",
apiKey: "API_KEY",
systemInstruction: "Talk like a pirate.", "Your name is Francis Drake."
)

// All arguments passed.
let genAI = GenerativeModel(name: "gemini-1.5-pro-latest",
let genAI = GenerativeModel(name: "gemini-1.5-flash",
apiKey: "API_KEY",
generationConfig: config, // Optional
safetySettings: filters, // Optional
Expand Down

0 comments on commit 1ab556a

Please sign in to comment.