Skip to content

Commit

Permalink
feat: add files to tool call trace (#230)
Browse files Browse the repository at this point in the history
* save

* change from dict to tuple
  • Loading branch information
yzld2002 authored Sep 9, 2024
1 parent 8154b92 commit ba89dfb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 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[tuple[str, str]]]


def send_inference_request(
Expand Down Expand Up @@ -202,12 +204,16 @@ def _call_post(
files: Optional[List[Tuple[Any, ...]]] = None,
function_name: str = "unknown",
) -> Any:
files_in_b64 = None
if files:
files_in_b64 = [(file[0], b64encode(file[1]).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 ba89dfb

Please sign in to comment.