Skip to content

Commit c887f6e

Browse files
author
Andrei Bratu
committed
evals_run modification works with simple callable and instrumented callables
1 parent 86b7904 commit c887f6e

File tree

4 files changed

+5
-19
lines changed

4 files changed

+5
-19
lines changed

src/humanloop/decorators/prompt.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import logging
2-
import os
3-
import sys
42
import typing
5-
import uuid
63
from functools import wraps
74
from typing import Any, Callable, Mapping, Optional, Sequence
85

96
from opentelemetry.sdk.trace import Span
107
from opentelemetry.trace import Tracer
118

12-
from humanloop.types.prompt_kernel_request import PromptKernelRequest
139

1410
if typing.TYPE_CHECKING:
1511
from humanloop import ToolFunctionParams

src/humanloop/eval_utils/run.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def log_with_evaluation_context(
103103
def _is_evaluated_file(
104104
evaluation_context: EvaluationContext,
105105
log_args: dict,
106-
file_id_attribute: str,
107106
) -> bool:
108107
"""Check if the File that will Log against is part of the current Evaluation.
109108
@@ -112,7 +111,7 @@ def _is_evaluated_file(
112111
"""
113112
if evaluation_context is None:
114113
return False
115-
return evaluation_context.get("file_id") == log_args.get(file_id_attribute) or evaluation_context.get(
114+
return evaluation_context.get("file_id") == log_args.get("id") or evaluation_context.get(
116115
"path"
117116
) == log_args.get("path")
118117

@@ -130,19 +129,9 @@ def _overloaded_log(
130129
]:
131130
evaluation_context = evaluation_context_variable.get()
132131

133-
if isinstance(client, PromptsClient):
134-
file_id_attribute = "prompt_id"
135-
elif isinstance(client, ToolsClient):
136-
file_id_attribute = "tool_id"
137-
elif isinstance(client, FlowsClient):
138-
file_id_attribute = "flow_id"
139-
elif isinstance(client, EvaluatorsClient):
140-
file_id_attribute = "evaluator_id"
141-
142132
if _is_evaluated_file(
143133
evaluation_context=evaluation_context, # type: ignore
144134
log_args=kwargs,
145-
file_id_attribute=file_id_attribute,
146135
):
147136
# If the .log API user does not provide the source_datapoint_id or run_id,
148137
# override them with the values from the EvaluationContext
@@ -161,7 +150,6 @@ def _overloaded_log(
161150
if _is_evaluated_file(
162151
evaluation_context=evaluation_context, # type: ignore
163152
log_args=kwargs,
164-
file_id_attribute=file_id_attribute,
165153
):
166154
# Notify that the Log has been added to the Evaluation
167155
# evaluation_context cannot be None
@@ -171,8 +159,10 @@ def _overloaded_log(
171159
)
172160
evaluation_context["upload_callback"]( # type: ignore
173161
{
174-
"id": response.id,
175162
**kwargs,
163+
# ID in kwargs refers to the File ID
164+
# Replace it with the Log ID
165+
"id": response.id,
176166
}
177167
)
178168

src/humanloop/flows/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def log(
200200
),
201201
)
202202
"""
203+
203204
_response = self._client_wrapper.httpx_client.request(
204205
"flows/log",
205206
method="POST",

src/humanloop/otel/exporter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ def _export_prompt(self, span: ReadableSpan) -> None:
195195
log_object["inputs"] = {}
196196
if "messages" not in log_object:
197197
log_object["messages"] = []
198-
# Same as with messages above
199198
if "tools" not in file_object["prompt"]:
200199
file_object["prompt"]["tools"] = []
201200
trace_metadata = TRACE_FLOW_CONTEXT.get(span.get_span_context().span_id)

0 commit comments

Comments
 (0)