Skip to content

Commit

Permalink
Update models in samples and README to gemini-1.5-flash-latest (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheard authored May 16, 2024
1 parent e8bbb72 commit edc9de3
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 26 deletions.
24 changes: 3 additions & 21 deletions Examples/GenerativeAICLI/Sources/GenerateContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,7 @@ struct GenerateContent: AsyncParsableCommand {

mutating func run() async throws {
do {
let safetySettings = [SafetySetting(harmCategory: .dangerousContent, threshold: .blockNone)]
// Let the server pick the default config.
let config = GenerationConfig(
temperature: 0.2,
topP: 0.1,
topK: 16,
candidateCount: 1,
maxOutputTokens: isStreaming ? nil : 256,
stopSequences: nil
)

let model = GenerativeModel(
name: modelNameOrDefault(),
apiKey: apiKey,
generationConfig: config,
safetySettings: safetySettings
)
let model = GenerativeModel(name: modelNameOrDefault(), apiKey: apiKey)

var parts = [ModelContent.Part]()

Expand Down Expand Up @@ -115,12 +99,10 @@ struct GenerateContent: AsyncParsableCommand {
}

func modelNameOrDefault() -> String {
if let modelName = modelName {
if let modelName {
return modelName
} else if imageURL != nil {
return "gemini-1.0-pro-vision-latest"
} else {
return "gemini-1.0-pro"
return "gemini-1.5-flash-latest"
}
}
}
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.0-pro", apiKey: APIKey.default)
model = GenerativeModel(name: "gemini-1.5-flash-latest", 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.0-pro",
name: "gemini-1.5-flash-latest",
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.0-pro-vision-latest", apiKey: APIKey.default)
model = GenerativeModel(name: "gemini-1.5-flash-latest", 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.0-pro", apiKey: APIKey.default)
model = GenerativeModel(name: "gemini-1.5-flash-latest", 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-pro-latest", apiKey: "YOUR_API_KEY")
let model = GenerativeModel(name: "gemini-1.5-flash-latest", apiKey: "YOUR_API_KEY")
let cookieImage = UIImage(...)
let prompt = "Do these look store-bought or homemade?"

Expand Down

0 comments on commit edc9de3

Please sign in to comment.