MCPcopy Create free account
hub / github.com/LangGraph-GUI/LangGraph-GUI-backend / run_script

Function run_script

src/main.py:62–89  ·  view source on GitHub ↗
(request: Request, username: str)

Source from the content-addressed store, hash-verified

60
61@app.post('/run/{username}')
62async def run_script(request: Request, username: str):
63 user_workspace = os.path.join("workspace", username)
64
65 data = await request.json()
66 llm_model = data.get('llm_model', '')
67 api_key = data.get('api_key', '')
68
69 command = [
70 "python", "../../run_graph.py",
71 "--llm", llm_model,
72 "--key", api_key
73 ]
74
75 # Get or create a handler for the user
76 if username not in handlers:
77 handlers[username] = ProcessHandler()
78
79 handler = handlers[username]
80 # start process in background
81 async def stream_response():
82 asyncio.create_task(handler.run(command, user_workspace)) # start the process as a task
83 async for output in handler.get_stream():
84 if isinstance(output, dict):
85 yield f"data: {output}\n\n" # Send final status
86 break
87 yield f"data: {output}\n\n"
88
89 return StreamingResponse(stream_response(), media_type="text/event-stream")
90
91@app.get('/status/{username}')
92async def check_status(username: str):

Callers

nothing calls this directly

Calls 2

ProcessHandlerClass · 0.90
stream_responseFunction · 0.85

Tested by

no test coverage detected