Skip to content

Commit f9420e9

Browse files
Apply suggestions from gemini-code-assist
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent e6b6b54 commit f9420e9

File tree

1 file changed

+4
-2
lines changed
  • firebase-ai/src/main/kotlin/com/google/firebase/ai

1 file changed

+4
-2
lines changed

firebase-ai/src/main/kotlin/com/google/firebase/ai/Chat.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ public class Chat(
6666
prompt.assertComesFromUser()
6767
attemptLock()
6868
try {
69-
val response = model.generateContent(prompt, *history.toTypedArray())
69+
val fullPrompt = history + prompt
70+
val response = model.generateContent(fullPrompt.first(), *fullPrompt.drop(1).toTypedArray())
7071
history.add(prompt)
7172
history.add(response.candidates.first().content)
7273
return response
@@ -127,7 +128,8 @@ public class Chat(
127128
prompt.assertComesFromUser()
128129
attemptLock()
129130

130-
val flow = model.generateContentStream(prompt, *history.toTypedArray())
131+
val fullPrompt = history + prompt
132+
val flow = model.generateContentStream(fullPrompt.first(), *fullPrompt.drop(1).toTypedArray())
131133
val bitmaps = LinkedList<Bitmap>()
132134
val inlineDataParts = LinkedList<InlineDataPart>()
133135
val text = StringBuilder()

0 commit comments

Comments
 (0)