MCPcopy Index your code
hub / github.com/google/adk-python / query

Function query

src/google/adk/cli/fast_api.py:847–883  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

845 response_class=JSONResponse,
846 )
847 async def query(request: Request):
848 try:
849 body = await request.json()
850 except json.JSONDecodeError as exc:
851 raise HTTPException(status_code=400, detail=f"Invalid JSON: {exc}")
852 try:
853 parsed = _QueryRequest.model_validate(body)
854 except _ValidationError as exc:
855 raise HTTPException(status_code=400, detail=exc.errors())
856 if not adk_app._tmpl_attrs.get("runner"):
857 adk_app._tmpl_attrs["runner"] = await adk_web_server.get_runner_async(
858 app_name=gemini_enterprise_app_name
859 )
860 if parsed.class_method is None:
861 raise HTTPException(
862 status_code=400, detail="class_method cannot be None"
863 )
864 if parsed.class_method not in _ALLOWED_AGENT_ENGINE_CLASS_METHODS:
865 raise HTTPException(
866 status_code=400,
867 detail=f"class_method {parsed.class_method} is not allowed",
868 )
869 method = getattr(adk_app, parsed.class_method)
870 output = await _invoke_callable_or_raise(method, parsed.input or {})
871
872 try:
873 json_serialized_content = jsonable_encoder({"output": output})
874 except ValueError as encoding_error:
875 logging.exception(
876 "FastAPI could not JSON-encode the response from invocation method"
877 " %s. Error: %s. Invocation method's original response: %r",
878 parsed.class_method,
879 encoding_error,
880 output,
881 )
882 raise
883 return JSONResponse(content=json_serialized_content)
884
885 @app.post(
886 "/api/stream_reasoning_engine",

Callers

nothing calls this directly

Calls 7

getattrFunction · 0.85
jsonMethod · 0.80
model_validateMethod · 0.80
get_runner_asyncMethod · 0.80
errorsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected