Skip to content

Commit 1e25281

Browse files
committed
infer file type from client passed into call overload
1 parent cfc0266 commit 1e25281

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/humanloop/overload.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from humanloop.prompts.client import PromptsClient
1616
from humanloop.agents.client import AgentsClient
1717
from humanloop.tools.client import ToolsClient
18+
from humanloop.types import FileType
1819
from humanloop.types.create_evaluator_log_response import CreateEvaluatorLogResponse
1920
from humanloop.types.create_flow_log_response import CreateFlowLogResponse
2021
from humanloop.types.create_prompt_log_response import CreatePromptLogResponse
@@ -128,7 +129,6 @@ def _overload_call(self, **kwargs) -> PromptCallResponse:
128129
def overload_call_with_local_files(
129130
client: Union[PromptsClient, AgentsClient],
130131
use_local_files: bool,
131-
file_type: Literal["prompt", "agent"]
132132
) -> Union[PromptsClient, AgentsClient]:
133133
"""Overload call to handle local files when use_local_files is True.
134134
@@ -138,6 +138,14 @@ def overload_call_with_local_files(
138138
file_type: Type of file ("prompt" or "agent")
139139
"""
140140
original_call = client._call if hasattr(client, '_call') else client.call
141+
# get file type from client type
142+
file_type: FileType
143+
if isinstance(client, PromptsClient):
144+
file_type = "prompt"
145+
elif isinstance(client, AgentsClient):
146+
file_type = "agent"
147+
else:
148+
raise ValueError(f"Unsupported client type: {type(client)}")
141149

142150
def _overload_call(self, **kwargs) -> PromptCallResponse:
143151
if use_local_files and "path" in kwargs:
@@ -152,7 +160,7 @@ def _overload_call(self, **kwargs) -> PromptCallResponse:
152160
with open(local_path) as f:
153161
file_content = f.read()
154162

155-
kwargs[file_type] = file_content # "prompt" or "agent"
163+
kwargs[file_type] = file_content # "prompt" or "agent" # TODO: raise warning if kernel passed in
156164

157165
logger.debug(f"Using local file content from {local_path}")
158166
else:

0 commit comments

Comments
 (0)