Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import re
|
|
| 3 |
import logging
|
| 4 |
import gradio as gr
|
| 5 |
import openai
|
|
|
|
| 6 |
|
| 7 |
print(os.environ)
|
| 8 |
openai.api_base1 = os.environ.get("OPENAI_API_BASE1")
|
|
@@ -88,9 +89,14 @@ def chat(api_model, history, system_message, max_tokens, temperature, top_p, top
|
|
| 88 |
def chat_double(history1, history2, system_message, max_tokens, temperature, top_p, top_k, repetition_penalty):
|
| 89 |
gen1 = chat(openai.api_model1, history1, system_message, max_tokens, temperature, top_p, top_k, repetition_penalty, openai.api_key1, openai.api_base1)
|
| 90 |
gen2 = chat(openai.api_model2, history2, system_message, max_tokens, temperature, top_p, top_k, repetition_penalty, openai.api_key2, openai.api_base2)
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
yield chatbot1_out, chatbot2_out, chat_history_state1_out, chat_history_state2_out, ""
|
| 93 |
|
|
|
|
| 94 |
start_message = ""
|
| 95 |
|
| 96 |
CSS ="""
|
|
|
|
| 3 |
import logging
|
| 4 |
import gradio as gr
|
| 5 |
import openai
|
| 6 |
+
from itertools import zip_longest
|
| 7 |
|
| 8 |
print(os.environ)
|
| 9 |
openai.api_base1 = os.environ.get("OPENAI_API_BASE1")
|
|
|
|
| 89 |
def chat_double(history1, history2, system_message, max_tokens, temperature, top_p, top_k, repetition_penalty):
|
| 90 |
gen1 = chat(openai.api_model1, history1, system_message, max_tokens, temperature, top_p, top_k, repetition_penalty, openai.api_key1, openai.api_base1)
|
| 91 |
gen2 = chat(openai.api_model2, history2, system_message, max_tokens, temperature, top_p, top_k, repetition_penalty, openai.api_key2, openai.api_base2)
|
| 92 |
+
|
| 93 |
+
# We define a default value that will be used when one of the generators is exhausted
|
| 94 |
+
default_value = ([["", ""]], [["", ""]], "")
|
| 95 |
+
|
| 96 |
+
for (chatbot1_out, chat_history_state1_out, message1), (chatbot2_out, chat_history_state2_out, message2) in zip_longest(gen1, gen2, fillvalue=default_value):
|
| 97 |
yield chatbot1_out, chatbot2_out, chat_history_state1_out, chat_history_state2_out, ""
|
| 98 |
|
| 99 |
+
|
| 100 |
start_message = ""
|
| 101 |
|
| 102 |
CSS ="""
|