Skip to content

Commit 48983e6

Browse files
committed
Async server improvements
1 parent 6735370 commit 48983e6

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

interpreter/core/async_core.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ async def output(self):
6868

6969
def respond(self):
7070
for chunk in self._respond_and_store():
71+
if chunk["type"] == "code":
72+
if "start" in chunk:
73+
print("\n\n```" + chunk["format"], flush=True)
74+
if "end" in chunk:
75+
print("\n```", flush=True)
7176
print(chunk.get("content", ""), end="", flush=True)
7277
if self.stop_event.is_set():
7378
return
@@ -223,4 +228,10 @@ def __init__(self, async_interpreter, host="0.0.0.0", port=8000):
223228
)
224229

225230
def run(self):
226-
self.uvicorn_server.run()
231+
try:
232+
self.uvicorn_server.run()
233+
except ImportError as e:
234+
raise ImportError(
235+
str(e)
236+
+ """\n\nPlease ensure you have run `pip install "open-interpreter[server]"` to install server dependencies."""
237+
)

interpreter/core/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050
safe_mode="off",
5151
shrink_images=False,
5252
loop=False,
53-
loop_message="""Proceed. You CAN run code on my machine. If you want to run code, start your message with "```"! If the entire task I asked for is done, say exactly 'The task is done.' If you need some specific information (like username or password) say EXACTLY 'Please provide more information.' If it's impossible, say 'The task is impossible.' (If I haven't provided a task, say exactly 'Let me know what you'd like to do next.') Otherwise keep going.""",
53+
loop_message="""Proceed. You CAN run code on my machine. If the entire task I asked for is done, say exactly 'The task is done.' If you need some specific information (like username or password) say EXACTLY 'Please provide more information.' If it's impossible, say 'The task is impossible.' (If I haven't provided a task, say exactly 'Let me know what you'd like to do next.') Otherwise keep going.""",
5454
loop_breakers=[
5555
"The task is done.",
5656
"The task is impossible.",

interpreter/terminal_interface/start_terminal_interface.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,12 @@ def start_terminal_interface(interpreter):
476476
conversation_navigator(interpreter)
477477
return
478478

479-
validate_llm_settings(
480-
interpreter
481-
) # This should actually just run interpreter.llm.load() once that's == to validate_llm_settings
479+
if not args.server:
480+
# This SHOULD RUN WHEN THE SERVER STARTS. But it can't rn because
481+
# if you don't have an API key, a prompt shows up, breaking the whole thing.
482+
validate_llm_settings(
483+
interpreter
484+
) # This should actually just run interpreter.llm.load() once that's == to validate_llm_settings
482485

483486
if args.server:
484487
interpreter.server.run()

0 commit comments

Comments
 (0)