Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to latest stable Gemini 1.5 Flash model #179

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading