88from opentelemetry .sdk .trace import TracerProvider
99from opentelemetry .trace import Tracer
1010
11+ from humanloop .context import PromptContext , reset_prompt_context , set_prompt_context
1112from humanloop .core .client_wrapper import SyncClientWrapper
12- from humanloop .eval_utils .run import prompt_call_evaluation_aware
1313
14- from humanloop .eval_utils import log_with_evaluation_context , run_eval
14+ from humanloop .eval_utils import run_eval
1515from humanloop .eval_utils .types import Dataset , Evaluator , EvaluatorCheck , File
1616
1717from humanloop .base_client import AsyncBaseHumanloop , BaseHumanloop
18+ from humanloop .overload import overload_call , overload_log
1819from humanloop .utilities .flow import flow as flow_decorator_factory
19- from humanloop .utilities .prompt import prompt as prompt_decorator_factory
20+ from humanloop .utilities .prompt import prompt
2021from humanloop .utilities .tool import tool as tool_decorator_factory
2122from humanloop .environment import HumanloopEnvironment
2223from humanloop .evaluations .client import EvaluationsClient
2526from humanloop .otel .processor import HumanloopSpanProcessor
2627from humanloop .prompt_utils import populate_template
2728from humanloop .prompts .client import PromptsClient
28- from humanloop .requests .flow_kernel_request import FlowKernelRequestParams
29- from humanloop .requests .tool_kernel_request import ToolKernelRequestParams
3029
3130
3231class ExtendedEvalsClient (EvaluationsClient ):
@@ -119,9 +118,10 @@ def __init__(
119118 self .prompts = ExtendedPromptsClient (client_wrapper = self ._client_wrapper )
120119
121120 # Overload the .log method of the clients to be aware of Evaluation Context
122- self .prompts = log_with_evaluation_context (client = self .prompts )
123- self .prompts = prompt_call_evaluation_aware (client = self .prompts )
124- self .flows = log_with_evaluation_context (client = self .flows )
121+ self .prompts = overload_log (client = self .prompts )
122+ self .prompts = overload_call (client = self .prompts )
123+ self .flows = overload_log (client = self .flows )
124+ self .tools = overload_log (client = self .tools )
125125
126126 if opentelemetry_tracer_provider is not None :
127127 self ._tracer_provider = opentelemetry_tracer_provider
@@ -135,10 +135,7 @@ def __init__(
135135 )
136136 instrument_provider (provider = self ._tracer_provider )
137137 self ._tracer_provider .add_span_processor (
138- HumanloopSpanProcessor (
139- client = self ,
140- exporter = HumanloopSpanExporter (client = self ),
141- ),
138+ HumanloopSpanProcessor (exporter = HumanloopSpanExporter (client = self )),
142139 )
143140
144141 if opentelemetry_tracer is None :
@@ -151,6 +148,7 @@ def prompt(
151148 self ,
152149 * ,
153150 path : str ,
151+ template : Optional [str ] = None ,
154152 ):
155153 """Decorator for declaring a [Prompt](https://humanloop.com/docs/explanation/prompts) in code.
156154
@@ -225,14 +223,16 @@ def call_llm(messages):
225223
226224 :param prompt_kernel: Attributes that define the Prompt. See `class:DecoratorPromptKernelRequestParams`
227225 """
228- return prompt_decorator_factory (path = path )
226+
227+ with prompt (path = path , template = template ):
228+ yield
229229
230230 def tool (
231231 self ,
232232 * ,
233233 path : str ,
234- attributes : dict [str , Any ] | None = None ,
235- setup_values : dict [str , Any ] | None = None ,
234+ attributes : Optional [ dict [str , Any ]] = None ,
235+ setup_values : Optional [ dict [str , Any ]] = None ,
236236 ):
237237 """Decorator for declaring a [Tool](https://humanloop.com/docs/explanation/tools) in code.
238238
@@ -312,8 +312,8 @@ def calculator(a: int, b: Optional[int]) -> int:
312312 def flow (
313313 self ,
314314 * ,
315- path : str = None ,
316- attributes : dict [str , Any ] | None = None ,
315+ path : str ,
316+ attributes : Optional [ dict [str , Any ]] = None ,
317317 ):
318318 """Decorator for declaring a [Flow](https://humanloop.com/docs/explanation/flows) in code.
319319
@@ -366,6 +366,7 @@ def entrypoint():
366366 :param flow_kernel: Attributes that define the Flow. See `class:ToolKernelRequestParams`
367367 """
368368 return flow_decorator_factory (
369+ client = self ,
369370 opentelemetry_tracer = self ._opentelemetry_tracer ,
370371 path = path ,
371372 attributes = attributes ,
0 commit comments