diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml deleted file mode 100644 index c076e8c..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Bug report -description: Use this template to report bugs -labels: ["type:bug", "component:swift sdk"] -body: - - type: markdown - attributes: - value: > - **Note:** If this is a support question (e.g. _How do I do XYZ?_), please visit the [Build with Google AI Forum](https://discuss.ai.google.dev/). This is a great place to interact with developers, and to learn, share, and support each other. - - type: textarea - id: description - attributes: - label: > - Description of the bug: - - type: textarea - id: behavior - attributes: - label: > - Actual vs expected behavior: - - type: textarea - id: info - attributes: - label: > - Any other information you'd like to share? diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml deleted file mode 100644 index c32ae77..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Feature request -description: Use this template to suggest a new feature -labels: ["type:feature request", "component:swift sdk"] -body: - - type: markdown - attributes: - value: > - **Note:** If this is a support question (e.g. _How do I do XYZ?_), please visit the [Build with Google AI Forum](https://discuss.ai.google.dev/). This is a great place to interact with developers, and to learn, share, and support each other. - - type: textarea - id: description - attributes: - label: > - Description of the feature request: - - type: textarea - id: behavior - attributes: - label: > - What problem are you trying to solve with this feature? - - type: textarea - id: info - attributes: - label: > - Any other information you'd like to share? diff --git a/Examples/GenerativeAICLI/Sources/GenerateContent.swift b/Examples/GenerativeAICLI/Sources/GenerateContent.swift index ab71c43..669dfe4 100644 --- a/Examples/GenerativeAICLI/Sources/GenerateContent.swift +++ b/Examples/GenerativeAICLI/Sources/GenerateContent.swift @@ -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]() @@ -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" } } } diff --git a/Examples/GenerativeAISample/ChatSample/Screens/ConversationScreen.swift b/Examples/GenerativeAISample/ChatSample/Screens/ConversationScreen.swift index d9c9b62..d0bcde3 100644 --- a/Examples/GenerativeAISample/ChatSample/Screens/ConversationScreen.swift +++ b/Examples/GenerativeAISample/ChatSample/Screens/ConversationScreen.swift @@ -94,6 +94,8 @@ struct ConversationScreen: View { } private func sendOrStop() { + focusedField = nil + if viewModel.busy { viewModel.stop() } else { diff --git a/Examples/GenerativeAISample/ChatSample/ViewModels/ConversationViewModel.swift b/Examples/GenerativeAISample/ChatSample/ViewModels/ConversationViewModel.swift index 84a8f7e..9508c3f 100644 --- a/Examples/GenerativeAISample/ChatSample/ViewModels/ConversationViewModel.swift +++ b/Examples/GenerativeAISample/ChatSample/ViewModels/ConversationViewModel.swift @@ -36,7 +36,7 @@ class ConversationViewModel: ObservableObject { private var chatTask: Task? 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() } diff --git a/Examples/GenerativeAISample/FunctionCallingSample/Screens/FunctionCallingScreen.swift b/Examples/GenerativeAISample/FunctionCallingSample/Screens/FunctionCallingScreen.swift index 4848ec5..c7f4dd5 100644 --- a/Examples/GenerativeAISample/FunctionCallingSample/Screens/FunctionCallingScreen.swift +++ b/Examples/GenerativeAISample/FunctionCallingSample/Screens/FunctionCallingScreen.swift @@ -65,6 +65,9 @@ struct FunctionCallingScreen: View { } } }) + .onTapGesture { + focusedField = nil + } } InputField("Message...", text: $userPrompt) { Image(systemName: viewModel.busy ? "stop.circle.fill" : "arrow.up.circle.fill") diff --git a/Examples/GenerativeAISample/FunctionCallingSample/ViewModels/FunctionCallingViewModel.swift b/Examples/GenerativeAISample/FunctionCallingSample/ViewModels/FunctionCallingViewModel.swift index cc569d4..7ebb821 100644 --- a/Examples/GenerativeAISample/FunctionCallingSample/ViewModels/FunctionCallingViewModel.swift +++ b/Examples/GenerativeAISample/FunctionCallingSample/ViewModels/FunctionCallingViewModel.swift @@ -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( diff --git a/Examples/GenerativeAISample/GenerativeAIMultimodalSample/Screens/PhotoReasoningScreen.swift b/Examples/GenerativeAISample/GenerativeAIMultimodalSample/Screens/PhotoReasoningScreen.swift index 98f3275..9302147 100644 --- a/Examples/GenerativeAISample/GenerativeAIMultimodalSample/Screens/PhotoReasoningScreen.swift +++ b/Examples/GenerativeAISample/GenerativeAIMultimodalSample/Screens/PhotoReasoningScreen.swift @@ -20,9 +20,17 @@ import SwiftUI struct PhotoReasoningScreen: View { @StateObject var viewModel = PhotoReasoningViewModel() + enum FocusedField: Hashable { + case message + } + + @FocusState + var focusedField: FocusedField? + var body: some View { VStack { MultimodalInputField(text: $viewModel.userInput, selection: $viewModel.selectedItems) + .focused($focusedField, equals: .message) .onSubmit { onSendTapped() } @@ -47,11 +55,16 @@ struct PhotoReasoningScreen: View { } } .navigationTitle("Multimodal sample") + .onAppear { + focusedField = .message + } } // MARK: - Actions private func onSendTapped() { + focusedField = nil + Task { await viewModel.reason() } diff --git a/Examples/GenerativeAISample/GenerativeAIMultimodalSample/ViewModels/PhotoReasoningViewModel.swift b/Examples/GenerativeAISample/GenerativeAIMultimodalSample/ViewModels/PhotoReasoningViewModel.swift index 181c586..3e3fd19 100644 --- a/Examples/GenerativeAISample/GenerativeAIMultimodalSample/ViewModels/PhotoReasoningViewModel.swift +++ b/Examples/GenerativeAISample/GenerativeAIMultimodalSample/ViewModels/PhotoReasoningViewModel.swift @@ -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 { diff --git a/Examples/GenerativeAISample/GenerativeAITextSample/Screens/SummarizeScreen.swift b/Examples/GenerativeAISample/GenerativeAITextSample/Screens/SummarizeScreen.swift index 8fbb89f..748c1ad 100644 --- a/Examples/GenerativeAISample/GenerativeAITextSample/Screens/SummarizeScreen.swift +++ b/Examples/GenerativeAISample/GenerativeAITextSample/Screens/SummarizeScreen.swift @@ -28,19 +28,23 @@ struct SummarizeScreen: View { var body: some View { VStack { - Text("Enter some text, then tap on _Go_ to summarize it.") - HStack(alignment: .top) { - TextField("Enter text summarize", text: $userInput, axis: .vertical) - .textFieldStyle(.roundedBorder) - .onSubmit { + VStack(alignment: .leading) { + Text("Enter some text, then tap on _Go_ to summarize it.") + .padding(.horizontal, 6) + HStack(alignment: .top) { + TextField("Enter text summarize", text: $userInput, axis: .vertical) + .focused($focusedField, equals: .message) + .textFieldStyle(.roundedBorder) + .onSubmit { + onSummarizeTapped() + } + Button("Go") { onSummarizeTapped() } - Button("Go") { - onSummarizeTapped() + .padding(.top, 4) } - .padding(.top, 4) } - .padding([.horizontal, .bottom]) + .padding(.horizontal, 16) List { HStack(alignment: .top) { @@ -61,6 +65,8 @@ struct SummarizeScreen: View { } private func onSummarizeTapped() { + focusedField = nil + Task { await viewModel.summarize(inputText: userInput) } diff --git a/Examples/GenerativeAISample/GenerativeAITextSample/ViewModels/SummarizeViewModel.swift b/Examples/GenerativeAISample/GenerativeAITextSample/ViewModels/SummarizeViewModel.swift index c49d6f1..08aab40 100644 --- a/Examples/GenerativeAISample/GenerativeAITextSample/ViewModels/SummarizeViewModel.swift +++ b/Examples/GenerativeAISample/GenerativeAITextSample/ViewModels/SummarizeViewModel.swift @@ -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 { diff --git a/Examples/GenerativeAISample/GenerativeAIUIComponents/Sources/GenerativeAIUIComponents/InputField.swift b/Examples/GenerativeAISample/GenerativeAIUIComponents/Sources/GenerativeAIUIComponents/InputField.swift index 3f12ea6..67941c3 100644 --- a/Examples/GenerativeAISample/GenerativeAIUIComponents/Sources/GenerativeAIUIComponents/InputField.swift +++ b/Examples/GenerativeAISample/GenerativeAIUIComponents/Sources/GenerativeAIUIComponents/InputField.swift @@ -60,10 +60,10 @@ public struct InputField