Skip to content

Server robustness #1396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions interpreter/core/async_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ def respond(self, run_code=None):
self.output_queue.sync_q.put(chunk)

self.output_queue.sync_q.put(complete_message)

if self.print or self.debug:
print("Server response complete.")

except Exception as e:
error = traceback.format_exc() + "\n" + str(e)
error_message = {
Expand Down Expand Up @@ -505,6 +509,8 @@ async def send_message(output):
break

try:
# print("sending:", output)

if isinstance(output, bytes):
await websocket.send_bytes(output)
else:
Expand Down
2 changes: 2 additions & 0 deletions interpreter/core/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import litellm

litellm.suppress_debug_info = True
litellm.REPEATED_STREAMING_CHUNK_LIMIT = 99999999

import json
import subprocess
import time
Expand Down
22 changes: 17 additions & 5 deletions interpreter/core/llm/run_tool_calling_llm.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import re

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

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

else:
raise (Exception("Can't parse tool output: " + str(accumulated_deltas)))
# If name exists and it's not "execute" or "python" or "functions", who knows what's going on.
if "name" in accumulated_deltas["function_call"]:
# yield {
# "type": "code",
# "format": "python",
# "content": str(delta),
# }
yield {
"type": "code",
"format": "python",
"content": "ERROR",
}
return

if os.getenv("INTERPRETER_REQUIRE_AUTHENTICATION", "False").lower() == "true":
print("function_call_detected", function_call_detected)
print("accumulated_review", accumulated_review)
if function_call_detected and not accumulated_review:
print("WTF!!!!!!!!!")
# import pdb
# pdb.set_trace()
raise Exception("Judge layer required but did not run.")
4 changes: 3 additions & 1 deletion interpreter/core/llm/utils/convert_to_openai_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ def convert_to_openai_messages(

elif message["type"] == "file":
new_message = {"role": "user", "content": message["content"]}

elif message["type"] == "error":
print("Ignoring 'type' == 'error' messages.")
continue
else:
raise Exception(f"Unable to convert this message type: {message}")

Expand Down
Loading