Skip to content

Commit 4047083

Browse files
committed
Ensure LangSmith traces include tool runs
1 parent 71faaf6 commit 4047083

File tree

8 files changed

+556
-430
lines changed

8 files changed

+556
-430
lines changed

eval_protocol/adapters/langfuse.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
to EvaluationRow format for use in evaluation pipelines.
55
"""
66

7-
from langfuse.api.resources.commons.types.observations_view import ObservationsView
87
import logging
98
import random
109
import time
1110
from datetime import datetime, timedelta
12-
from typing import Any, Dict, List, Optional, Protocol
11+
from typing import Any, Dict, List, Optional, Protocol, cast
1312

13+
from langfuse.api.resources.commons.types.observations_view import ObservationsView
1414
from eval_protocol.models import EvaluationRow, InputMetadata, Message
1515
from .utils import extract_messages_from_data
1616

@@ -213,12 +213,12 @@ class LangfuseAdapter:
213213
... ))
214214
"""
215215

216-
def __init__(self):
216+
def __init__(self, client: Optional[Any] = None):
217217
"""Initialize the Langfuse adapter."""
218218
if not LANGFUSE_AVAILABLE:
219219
raise ImportError("Langfuse not installed. Install with: pip install 'eval-protocol[langfuse]'")
220220

221-
self.client = get_client()
221+
self.client = client or cast(Any, get_client)()
222222

223223
def get_evaluation_rows(
224224
self,

eval_protocol/adapters/langsmith.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from __future__ import annotations
1111

1212
import logging
13-
from typing import Any, Dict, List, Optional, Iterable
13+
from typing import Any, Dict, List, Optional, Iterable, cast
1414

1515
from eval_protocol.models import EvaluationRow, InputMetadata, Message
1616

@@ -22,6 +22,7 @@
2222
LANGSMITH_AVAILABLE = True
2323
except ImportError:
2424
LANGSMITH_AVAILABLE = False
25+
Client = None # type: ignore[misc]
2526

2627

2728
class LangSmithAdapter:
@@ -34,10 +35,14 @@ class LangSmithAdapter:
3435
- outputs: { messages: [...] } | { content } | { result } | { answer } | { output } | str | list[dict]
3536
"""
3637

37-
def __init__(self, client: Optional[Client] = None) -> None:
38+
def __init__(self, client: Optional[Any] = None) -> None:
3839
if not LANGSMITH_AVAILABLE:
3940
raise ImportError("LangSmith not installed. Install with: pip install 'eval-protocol[langsmith]'")
40-
self.client = client or Client()
41+
if client is not None:
42+
self.client = client
43+
else:
44+
assert Client is not None
45+
self.client = cast(Any, Client)()
4146

4247
def get_evaluation_rows(
4348
self,

examples/langsmith/README.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

examples/langsmith/dump_traces_langsmith.py

Lines changed: 0 additions & 115 deletions
This file was deleted.

examples/langsmith/emit_tool_calls.py

Lines changed: 0 additions & 116 deletions
This file was deleted.

0 commit comments

Comments
 (0)