Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
yzld2002 committed Sep 9, 2024
1 parent 8154b92 commit 515a4b1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions vision_agent/tools/tool_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from base64 import b64encode
import inspect
import logging
import os
Expand Down Expand Up @@ -27,6 +28,7 @@ class ToolCallTrace(BaseModel):
request: MutableMapping[str, Any]
response: MutableMapping[str, Any]
error: Optional[Error]
files: Optional[List[Dict[str, str]]]


def send_inference_request(
Expand Down Expand Up @@ -202,12 +204,21 @@ def _call_post(
files: Optional[List[Tuple[Any, ...]]] = None,
function_name: str = "unknown",
) -> Any:
files_in_b64 = None
if files:
files_in_b64 = [
{"video": b64encode(file[1]).decode("utf-8")}
if file[0] == "video"
else {"image": b64encode(file[0]).decode("utf-8")}
for file in files
]
try:
tool_call_trace = ToolCallTrace(
endpoint_url=url,
request=payload,
response={},
error=None,
files=files_in_b64,
)

if files is not None:
Expand Down

0 comments on commit 515a4b1

Please sign in to comment.