Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import os
|
2 |
import google.generativeai as genai
|
3 |
import gradio as gr
|
4 |
-
from google.generativeai.protos import content_types as protos
|
5 |
|
6 |
# Configure the API key
|
7 |
genai.configure(api_key=os.environ["YOUR_API_KEY"])
|
@@ -30,7 +29,8 @@ def chat_with_model(user_input, history):
|
|
30 |
# Convert history to expected format (list of protos.Content)
|
31 |
formatted_history = []
|
32 |
for entry in history:
|
33 |
-
|
|
|
34 |
formatted_history.append(content)
|
35 |
|
36 |
# Start or continue the chat session using the formatted history
|
|
|
1 |
import os
|
2 |
import google.generativeai as genai
|
3 |
import gradio as gr
|
|
|
4 |
|
5 |
# Configure the API key
|
6 |
genai.configure(api_key=os.environ["YOUR_API_KEY"])
|
|
|
29 |
# Convert history to expected format (list of protos.Content)
|
30 |
formatted_history = []
|
31 |
for entry in history:
|
32 |
+
# Assuming the message content is a string
|
33 |
+
content = genai.protos.Content(text=entry["content"], role=entry["role"])
|
34 |
formatted_history.append(content)
|
35 |
|
36 |
# Start or continue the chat session using the formatted history
|