Spaces:
Runtime error
Runtime error
Commit ·
8cf5c01
1
Parent(s): b48eaee
Add error handling
Browse filesSigned-off-by: Aivin V. Solatorio <avsolatorio@gmail.com>
- mcp_remote_client.py +8 -0
mcp_remote_client.py
CHANGED
|
@@ -140,6 +140,13 @@ class MCPClientWrapper:
|
|
| 140 |
|
| 141 |
yield messages, gr.Textbox(value="")
|
| 142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
with open("messages.log.jsonl", "a+") as fl:
|
| 144 |
fl.write(json.dumps(dict(time=f"{datetime.now()}", messages=messages)))
|
| 145 |
|
|
@@ -174,6 +181,7 @@ class MCPClientWrapper:
|
|
| 174 |
"content": "The LLM API is overloaded now, try again later...",
|
| 175 |
}
|
| 176 |
]
|
|
|
|
| 177 |
|
| 178 |
result_messages = []
|
| 179 |
partial_messages = []
|
|
|
|
| 140 |
|
| 141 |
yield messages, gr.Textbox(value="")
|
| 142 |
|
| 143 |
+
if (
|
| 144 |
+
messages[-1]["role"] == "assistant"
|
| 145 |
+
and messages[-1]["content"]
|
| 146 |
+
== "The LLM API is overloaded now, try again later..."
|
| 147 |
+
):
|
| 148 |
+
break
|
| 149 |
+
|
| 150 |
with open("messages.log.jsonl", "a+") as fl:
|
| 151 |
fl.write(json.dumps(dict(time=f"{datetime.now()}", messages=messages)))
|
| 152 |
|
|
|
|
| 181 |
"content": "The LLM API is overloaded now, try again later...",
|
| 182 |
}
|
| 183 |
]
|
| 184 |
+
# TODO: Add a retry mechanism
|
| 185 |
|
| 186 |
result_messages = []
|
| 187 |
partial_messages = []
|