Spaces:
Runtime error
Runtime error
Fix Gemini format
Browse files
utils.py
CHANGED
|
@@ -144,11 +144,8 @@ def _call_openai(prompt: str, chat_history: list[tuple[str, str]], question: str
|
|
| 144 |
# Format the message history to the one used by OpenAI
|
| 145 |
msg_history = [{'role': 'system', 'content': prompt}]
|
| 146 |
for i, (user, bot) in enumerate(chat_history):
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
else:
|
| 150 |
-
msg_history.append({'role': 'user', 'content': user})
|
| 151 |
-
msg_history.append({'role': 'assistant', 'content': bot})
|
| 152 |
msg_history.append({'role': 'user', 'content': question})
|
| 153 |
|
| 154 |
# Call ChatGPT 4
|
|
@@ -171,14 +168,11 @@ def _call_google(prompt: str, chat_history: list[tuple[str, str]], question: str
|
|
| 171 |
# Format the message history to the one used by Google
|
| 172 |
history = [
|
| 173 |
{'role': 'user', 'parts': [prompt]},
|
| 174 |
-
{'role': 'model', 'parts': 'Excelente! Estoy super lista para ayudarte en lo que necesites'}
|
| 175 |
]
|
| 176 |
for i, (user, bot) in enumerate(chat_history):
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
else:
|
| 180 |
-
history.append({'role': 'user', 'parts': user})
|
| 181 |
-
history.append({'role': 'model', 'parts': bot})
|
| 182 |
convo = GEMINI.start_chat(history=history)
|
| 183 |
|
| 184 |
# Call Gemini
|
|
|
|
| 144 |
# Format the message history to the one used by OpenAI
|
| 145 |
msg_history = [{'role': 'system', 'content': prompt}]
|
| 146 |
for i, (user, bot) in enumerate(chat_history):
|
| 147 |
+
msg_history.append({'role': 'user', 'content': user})
|
| 148 |
+
msg_history.append({'role': 'assistant', 'content': bot})
|
|
|
|
|
|
|
|
|
|
| 149 |
msg_history.append({'role': 'user', 'content': question})
|
| 150 |
|
| 151 |
# Call ChatGPT 4
|
|
|
|
| 168 |
# Format the message history to the one used by Google
|
| 169 |
history = [
|
| 170 |
{'role': 'user', 'parts': [prompt]},
|
| 171 |
+
{'role': 'model', 'parts': ['Excelente! Estoy super lista para ayudarte en lo que necesites']}
|
| 172 |
]
|
| 173 |
for i, (user, bot) in enumerate(chat_history):
|
| 174 |
+
history.append({'role': 'user', 'parts': [user]})
|
| 175 |
+
history.append({'role': 'model', 'parts': [bot]})
|
|
|
|
|
|
|
|
|
|
| 176 |
convo = GEMINI.start_chat(history=history)
|
| 177 |
|
| 178 |
# Call Gemini
|