Skip to content

Commit

Permalink
Merge pull request #8 from e2b-dev/switch-from-trio-to-asyncio
Browse files Browse the repository at this point in the history
Switch Python agent protocol library from trio to asyncio
  • Loading branch information
jakubno committed Jul 23, 2023
2 parents a47d0db + ee3c8ef commit dd847c4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 222 deletions.
9 changes: 4 additions & 5 deletions agent/python/agent_protocol/agent.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import trio
import asyncio

import uuid

from hypercorn.trio import serve
from hypercorn.asyncio import serve
from hypercorn.config import Config
from typing import Awaitable, Callable, List, Optional, Tuple, Any
from .dependencies import *
from .models import Step, Task, TaskRequestBody


from .server import app
Expand Down Expand Up @@ -156,4 +155,4 @@ def handle_task(handler: Callable[[TaskInput | None], Awaitable[StepHandler]]):
def start(port: int = 8000):
config = Config()
config.bind = [f"localhost:{port}"] # As an example configuration setting
trio.run(serve, app, config)
asyncio.run(serve(app, config))
4 changes: 3 additions & 1 deletion agent/python/examples/smol_developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ async def task_handler(task_input) -> StepHandler:
smol_developer_loop = smol(prompt=task_input)

async def step_handler(step_input):
result = await anext(smol_developer_loop)
result = await anext(smol_developer_loop, None)
if result is None:
return StepResult(is_last=True)
return StepResult(output=result)

return step_handler
Expand Down
Loading

0 comments on commit dd847c4

Please sign in to comment.