Skip to content

Commit 818744d

Browse files
authored
Merge pull request #1396 from OpenInterpreter/development
Server robustness
2 parents 23d5cb1 + c88c14e commit 818744d

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

interpreter/core/async_core.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ def respond(self, run_code=None):
143143
self.output_queue.sync_q.put(chunk)
144144

145145
self.output_queue.sync_q.put(complete_message)
146+
147+
if self.print or self.debug:
148+
print("Server response complete.")
149+
146150
except Exception as e:
147151
error = traceback.format_exc() + "\n" + str(e)
148152
error_message = {
@@ -505,6 +509,8 @@ async def send_message(output):
505509
break
506510

507511
try:
512+
# print("sending:", output)
513+
508514
if isinstance(output, bytes):
509515
await websocket.send_bytes(output)
510516
else:

interpreter/core/llm/llm.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import litellm
77

88
litellm.suppress_debug_info = True
9+
litellm.REPEATED_STREAMING_CHUNK_LIMIT = 99999999
10+
911
import json
1012
import subprocess
1113
import time

interpreter/core/llm/run_tool_calling_llm.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import re
23

34
from .utils.merge_deltas import merge_deltas
@@ -284,6 +285,7 @@ def run_tool_calling_llm(llm, request_params):
284285
if llm.interpreter.verbose:
285286
print("Arguments not a dict.")
286287

288+
# THESE NEED TO BE UPDATED FOR TOOL CALLING!!!!
287289
# Common hallucinations
288290
elif "name" in accumulated_deltas["function_call"] and (
289291
accumulated_deltas["function_call"]["name"] == "python"
@@ -310,11 +312,21 @@ def run_tool_calling_llm(llm, request_params):
310312
}
311313

312314
else:
315+
raise (Exception("Can't parse tool output: " + str(accumulated_deltas)))
313316
# If name exists and it's not "execute" or "python" or "functions", who knows what's going on.
314317
if "name" in accumulated_deltas["function_call"]:
315-
# yield {
316-
# "type": "code",
317-
# "format": "python",
318-
# "content": str(delta),
319-
# }
318+
yield {
319+
"type": "code",
320+
"format": "python",
321+
"content": "ERROR",
322+
}
320323
return
324+
325+
if os.getenv("INTERPRETER_REQUIRE_AUTHENTICATION", "False").lower() == "true":
326+
print("function_call_detected", function_call_detected)
327+
print("accumulated_review", accumulated_review)
328+
if function_call_detected and not accumulated_review:
329+
print("WTF!!!!!!!!!")
330+
# import pdb
331+
# pdb.set_trace()
332+
raise Exception("Judge layer required but did not run.")

interpreter/core/llm/utils/convert_to_openai_messages.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ def convert_to_openai_messages(
237237

238238
elif message["type"] == "file":
239239
new_message = {"role": "user", "content": message["content"]}
240-
240+
elif message["type"] == "error":
241+
print("Ignoring 'type' == 'error' messages.")
242+
continue
241243
else:
242244
raise Exception(f"Unable to convert this message type: {message}")
243245

0 commit comments

Comments
 (0)