From 7097d715eabd84d4ba303ad883cdfdb21f02102d Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Fri, 3 May 2024 14:56:59 -0700 Subject: [PATCH] Fix interrupt on tools --- backend/app/api/runs.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/app/api/runs.py b/backend/app/api/runs.py index 666b40a6..00e05343 100644 --- a/backend/app/api/runs.py +++ b/backend/app/api/runs.py @@ -13,7 +13,7 @@ from sse_starlette import EventSourceResponse from app.auth.handlers import AuthedUser -from app.storage import get_thread +from app.storage import get_assistant, get_thread from app.lifespan import get_langserve router = APIRouter() @@ -50,6 +50,9 @@ async def stream_run( thread = await get_thread(user["user_id"], payload.thread_id) if not thread: raise HTTPException(status_code=404, detail="Thread not found") + assistant = await get_assistant(user["user_id"], thread["assistant_id"]) + if not assistant: + raise HTTPException(status_code=404, detail="Assistant not found") return EventSourceResponse( ( @@ -60,6 +63,11 @@ async def stream_run( input=payload.input, config=payload.config, stream_mode="messages", + interrupt_before=["action"] + if assistant["config"]["configurable"].get( + "type==agent/interrupt_before_action" + ) + else None, ) ) )