-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[FirebaseAI ] Integrate conversationkit #1745
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
Open
YoungHypo
wants to merge
17
commits into
firebase:peterfriese/firebase-ai-quickstart-refresh
Choose a base branch
from
YoungHypo:integrate-conversationkit
base: peterfriese/firebase-ai-quickstart-refresh
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+578
−705
Open
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9dc09fb
integrate conversationkit to firebaseai
YoungHypo fdb313c
refract functioncalling logic
YoungHypo 92c4172
remove fatalError
YoungHypo 55a4658
change preview for screens
YoungHypo 3d5adad
♻️ Use ConversationKit
peterfriese 84c921e
♻️ Refactor error handling
peterfriese c1c436e
✨ Bring back pre-filled user messages
peterfriese d43eac3
🧹Cleanup
peterfriese fd4dad0
⬆️ Use latest ConversationKit version
peterfriese 17f9ed0
Merge pull request #1 from firebase/peterfriese/integrate-conversatio…
YoungHypo 97f275b
fix style check
YoungHypo a9c6ab1
add errordetailview for imagenexample
YoungHypo 85121dd
✏️ Fix typo
peterfriese a300774
✏️ Fix typo
peterfriese 6d7b3a4
✏️ Fix typo
peterfriese c2f3745
✏️ Fix typo
peterfriese 95e491f
fix style and change ci
YoungHypo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import FirebaseAI | ||
import SwiftUI | ||
|
||
struct ChatScreen: View { | ||
let firebaseService: FirebaseAI | ||
@StateObject var viewModel: ChatViewModel | ||
|
||
init(firebaseService: FirebaseAI, sample: Sample? = nil) { | ||
self.firebaseService = firebaseService | ||
_viewModel = | ||
StateObject(wrappedValue: ChatViewModel(firebaseService: firebaseService, | ||
sample: sample)) | ||
} | ||
|
||
var body: some View { | ||
NavigationStack { | ||
ConversationView(messages: $viewModel.messages, | ||
userPrompt: viewModel.initialPrompt) { message in | ||
MessageView(message: message) | ||
} | ||
.disableAttachments() | ||
.errorState(viewModel.error) | ||
.onSendMessage { prompt in | ||
Task { | ||
await viewModel.sendMessage(prompt, streaming: true) | ||
} | ||
} | ||
.toolbar { | ||
ToolbarItem(placement: .primaryAction) { | ||
Button(action: newChat) { | ||
Image(systemName: "square.and.pencil") | ||
} | ||
} | ||
} | ||
.navigationTitle(viewModel.title) | ||
.navigationBarTitleDisplayMode(.inline) | ||
} | ||
} | ||
|
||
private func newChat() { | ||
viewModel.startNewChat() | ||
} | ||
} | ||
|
||
struct ChatScreen_Previews: PreviewProvider { | ||
struct ContainerView: View { | ||
@StateObject var viewModel = ChatViewModel(firebaseService: FirebaseAI | ||
.firebaseAI(), sample: nil) // Example service init | ||
|
||
var body: some View { | ||
ChatScreen(firebaseService: FirebaseAI.firebaseAI()) | ||
.onAppear { | ||
viewModel.messages = ChatMessage.samples | ||
} | ||
} | ||
} | ||
|
||
static var previews: some View { | ||
NavigationStack { | ||
ChatScreen(firebaseService: FirebaseAI.firebaseAI()) | ||
} | ||
} | ||
} |
145 changes: 0 additions & 145 deletions
145
firebaseai/ChatExample/Screens/ConversationScreen.swift
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.