Update app.py
Browse files
app.py
CHANGED
|
@@ -150,9 +150,9 @@ class Me:
|
|
| 150 |
)
|
| 151 |
|
| 152 |
done = False
|
| 153 |
-
|
| 154 |
-
response = None
|
| 155 |
|
|
|
|
| 156 |
for attempt in range(3):
|
| 157 |
try:
|
| 158 |
response = self.openai.chat.completions.create(
|
|
@@ -168,6 +168,9 @@ class Me:
|
|
| 168 |
raise
|
| 169 |
time.sleep(2)
|
| 170 |
|
|
|
|
|
|
|
|
|
|
| 171 |
if response.choices[0].finish_reason == "tool_calls":
|
| 172 |
msg = response.choices[0].message
|
| 173 |
tool_calls = msg.tool_calls or []
|
|
@@ -202,5 +205,6 @@ def chat_safe(message, history):
|
|
| 202 |
|
| 203 |
if __name__ == "__main__":
|
| 204 |
me = Me()
|
| 205 |
-
gr.ChatInterface(chat_safe).launch()
|
|
|
|
| 206 |
|
|
|
|
| 150 |
)
|
| 151 |
|
| 152 |
done = False
|
| 153 |
+
response = None
|
|
|
|
| 154 |
|
| 155 |
+
while not done:
|
| 156 |
for attempt in range(3):
|
| 157 |
try:
|
| 158 |
response = self.openai.chat.completions.create(
|
|
|
|
| 168 |
raise
|
| 169 |
time.sleep(2)
|
| 170 |
|
| 171 |
+
if response is None:
|
| 172 |
+
raise RuntimeError("No response from OpenAI")
|
| 173 |
+
|
| 174 |
if response.choices[0].finish_reason == "tool_calls":
|
| 175 |
msg = response.choices[0].message
|
| 176 |
tool_calls = msg.tool_calls or []
|
|
|
|
| 205 |
|
| 206 |
if __name__ == "__main__":
|
| 207 |
me = Me()
|
| 208 |
+
gr.ChatInterface(chat_safe, type="messages").launch()
|
| 209 |
+
|
| 210 |
|