File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ def run(
5252 host : str = "127.0.0.1" ,
5353 port : int = 8080 ,
5454 assistant_name : str = "assistant" ,
55+ is_async : bool = True ,
5556 open_browser : bool = True ,
5657):
5758 """Run the assistant in *script* and launch the web UI."""
@@ -71,7 +72,7 @@ def run(
7172
7273 # Pass the assistant instance directly to create_app
7374 uvicorn .run (
74- lambda : create_app (assistant ),
75+ lambda : create_app (assistant = assistant , is_async = is_async ), # type: ignore
7576 factory = True , # <─ tells Uvicorn to call it
7677 host = host ,
7778 port = port ,
Original file line number Diff line number Diff line change @@ -76,16 +76,22 @@ def get_request_ids(conv_id: str):
7676
7777
7878# ---------- FastAPI factory ---------------------------------------------
79- def create_app (assistant : Assistant ) -> FastAPI :
79+ def create_app (assistant : Assistant , is_async : bool = True ) -> FastAPI :
8080 api = FastAPI (title = "Graphite-Dev API" )
8181
8282 @api .post ("/chat" , response_model = ChatReply )
8383 async def chat (req : ChatRequest ):
8484 try :
85- out = assistant .execute (
86- _execution_context (req .conversation_id , req .assistant_request_id ),
87- _to_messages (req .messages ),
88- )
85+ if is_async :
86+ out = await assistant .a_execute (
87+ _execution_context (req .conversation_id , req .assistant_request_id ),
88+ _to_messages (req .messages ),
89+ )
90+ else :
91+ out = assistant .execute (
92+ _execution_context (req .conversation_id , req .assistant_request_id ),
93+ _to_messages (req .messages ),
94+ )
8995 logger .info (out )
9096 return ChatReply (messages = out )
9197 except Exception as exc :
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44
55[project ]
66name = " grafi-dev"
7- version = " 0.0.2 "
7+ version = " 0.0.3 "
88description = " Run a grafi Assistant locally with a live workflow graph & trace viewer"
99authors = [{ name = " Craig Li" , email = " craig@binome.dev" }]
1010readme = " README.md"
You can’t perform that action at this time.
0 commit comments