MCPcopy
hub / github.com/landing-ai/vision-agent / send_inference_request

Function send_inference_request

vision_agent/utils/tools.py:48–83  ·  view source on GitHub ↗
(
    payload: Dict[str, Any],
    endpoint_name: str,
    files: Optional[List[Tuple[Any, ...]]] = None,
    v2: bool = False,
    metadata_payload: Optional[Dict[str, Any]] = None,
    is_form: bool = False,
)

Source from the content-addressed store, hash-verified

46
47
48def send_inference_request(
49 payload: Dict[str, Any],
50 endpoint_name: str,
51 files: Optional[List[Tuple[Any, ...]]] = None,
52 v2: bool = False,
53 metadata_payload: Optional[Dict[str, Any]] = None,
54 is_form: bool = False,
55) -> Any:
56 url = f"{_LND_API_URL_v2 if v2 else _LND_API_URL}/{endpoint_name}"
57 if "TOOL_ENDPOINT_URL" in os.environ:
58 url = os.environ["TOOL_ENDPOINT_URL"]
59
60 vision_agent_api_key = get_vision_agent_api_key()
61 headers = {
62 "Authorization": f"Basic {vision_agent_api_key}",
63 "X-Source": "vision_agent",
64 }
65
66 if runtime_tag := os.environ.get("RUNTIME_TAG", "vision-agent"):
67 headers["runtime_tag"] = runtime_tag
68
69 session = _create_requests_session(
70 url=url,
71 num_retry=3,
72 headers=headers,
73 )
74
75 function_name = "unknown"
76 if "function_name" in payload:
77 function_name = payload["function_name"]
78 elif metadata_payload is not None and "function_name" in metadata_payload:
79 function_name = metadata_payload["function_name"]
80
81 response = _call_post(url, payload, session, files, function_name, is_form)
82
83 return response["data"]
84
85
86def send_task_inference_request(

Callers 15

instance_segmentationFunction · 0.90
ocrFunction · 0.90
depth_estimationFunction · 0.90
florence2_ocrFunction · 0.90
custom_object_detectionFunction · 0.90
qwen25_vl_images_vqaFunction · 0.90
qwen25_vl_video_vqaFunction · 0.90
qwen2_vl_images_vqaFunction · 0.90
qwen2_vl_video_vqaFunction · 0.90
paddle_ocrFunction · 0.90
document_extractionFunction · 0.90

Calls 4

get_vision_agent_api_keyFunction · 0.85
_create_requests_sessionFunction · 0.85
_call_postFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected