MCPcopy Index your code
hub / github.com/CopilotKit/CopilotKit / handler_v1

Function handler_v1

sdk-python/copilotkit/integrations/fastapi.py:173–234  ·  view source on GitHub ↗

Handle FastAPI request for v1

(
    sdk: CopilotKitRemoteEndpoint,
    method: str,
    path: str,
    body: Any,
    context: CopilotKitContext,
)

Source from the content-addressed store, hash-verified

171
172
173async def handler_v1(
174 sdk: CopilotKitRemoteEndpoint,
175 method: str,
176 path: str,
177 body: Any,
178 context: CopilotKitContext,
179):
180 """Handle FastAPI request for v1"""
181
182 if body is None:
183 raise HTTPException(status_code=400, detail="Request body is required")
184
185 if method == "POST" and path == "info":
186 return await handle_info(sdk=sdk, context=context)
187
188 if method == "POST" and path == "actions/execute":
189 name = body_get_or_raise(body, "name")
190 arguments = body.get("arguments", {})
191
192 return await handle_execute_action(
193 sdk=sdk,
194 context=context,
195 name=name,
196 arguments=arguments,
197 )
198
199 if method == "POST" and path == "agents/execute":
200 thread_id = body.get("threadId")
201 node_name = body.get("nodeName")
202 config = body.get("config")
203
204 name = body_get_or_raise(body, "name")
205 state = body_get_or_raise(body, "state")
206 messages = body_get_or_raise(body, "messages")
207 actions = cast(List[ActionDict], body.get("actions", []))
208 meta_events = cast(List[MetaEvent], body.get("metaEvents", []))
209
210 return handle_execute_agent(
211 sdk=sdk,
212 context=context,
213 thread_id=thread_id,
214 node_name=node_name,
215 name=name,
216 state=state,
217 config=config,
218 messages=messages,
219 actions=actions,
220 meta_events=meta_events,
221 )
222
223 if method == "POST" and path == "agents/state":
224 thread_id = body_get_or_raise(body, "threadId")
225 name = body_get_or_raise(body, "name")
226
227 return await handle_get_agent_state(
228 sdk=sdk,
229 context=context,
230 thread_id=thread_id,

Callers 1

handlerFunction · 0.85

Calls 6

handle_infoFunction · 0.85
body_get_or_raiseFunction · 0.85
handle_execute_actionFunction · 0.85
handle_execute_agentFunction · 0.85
handle_get_agent_stateFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…