Skip to content

Commit b1e4b30

Browse files
committed
fx
1 parent 54c3c66 commit b1e4b30

File tree

10 files changed

+98
-72
lines changed

10 files changed

+98
-72
lines changed

packages/traceloop-sdk/.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ exclude =
1111
max-line-length = 120
1212
per-file-ignores =
1313
__init__.py:F401
14-
traceloop/sdk/evaluators_generated/*.py:E501
14+
traceloop/sdk/generated/**/*.py:E501

packages/traceloop-sdk/traceloop/sdk/evaluator/evaluator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
)
1313
from .stream_client import SSEClient
1414
from .config import EvaluatorDetails
15-
from ..evaluators_generated import get_request_model
15+
from ..generated.evaluators import get_request_model
1616

1717

1818
def _validate_evaluator_input(slug: str, input: Dict[str, str]) -> None:

packages/traceloop-sdk/traceloop/sdk/evaluator/evaluators_made_by_traceloop.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""
22
Factory class for creating Traceloop evaluators with proper configuration.
33
4-
This module dynamically generates factory methods from the evaluators_generated registry.
4+
This module dynamically generates factory methods from the generated.evaluators registry.
55
"""
66

77
from typing import Any, List
88

9-
from ..evaluators_generated import REQUEST_MODELS
9+
from ..generated.evaluators import REQUEST_MODELS
1010
from .config import EvaluatorDetails
1111

1212

packages/traceloop-sdk/traceloop/sdk/evaluator/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def typed_result(self, model: Type[T]) -> T:
5555
An instance of the provided model class
5656
5757
Example:
58-
from traceloop.sdk.evaluators_generated import PIIDetectorResponse
58+
from traceloop.sdk.generated.evaluators import PIIDetectorResponse
5959
result = await evaluator.run_experiment_evaluator(...)
6060
pii = result.typed_result(PIIDetectorResponse)
6161
print(pii.has_pii) # IDE autocomplete works!
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Generated code modules
2+
# DO NOT EDIT MANUALLY - Regenerate with scripts in /scripts/
3+
4+
from .evaluators import (
5+
REQUEST_MODELS,
6+
RESPONSE_MODELS,
7+
get_request_model,
8+
get_response_model,
9+
)
10+
11+
__all__ = [
12+
"REQUEST_MODELS",
13+
"RESPONSE_MODELS",
14+
"get_request_model",
15+
"get_response_model",
16+
]

packages/traceloop-sdk/traceloop/sdk/evaluators_generated/__init__.py renamed to packages/traceloop-sdk/traceloop/sdk/generated/evaluators/__init__.py

File renamed without changes.

packages/traceloop-sdk/traceloop/sdk/evaluators_generated/registry.py renamed to packages/traceloop-sdk/traceloop/sdk/generated/evaluators/registry.py

File renamed without changes.

packages/traceloop-sdk/traceloop/sdk/evaluators_generated/request.py renamed to packages/traceloop-sdk/traceloop/sdk/generated/evaluators/request.py

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# generated by datamodel-codegen:
2-
# filename: tmpcyjngtw9.json
2+
# filename: tmpvqz8m01b.json
33

44
from __future__ import annotations
55

@@ -19,7 +19,7 @@ class AgentEfficiencyRequest(BaseModel):
1919

2020
class AgentFlowQualityRequest(BaseModel):
2121
conditions: list[str] = Field(
22-
..., examples=[["no tools called", "agent completed task"]]
22+
..., examples=[['no tools called', 'agent completed task']]
2323
)
2424
threshold: float = Field(..., examples=[0.5])
2525
trajectory_completions: str = Field(
@@ -38,13 +38,13 @@ class AgentGoalAccuracyRequest(BaseModel):
3838
completion: str = Field(
3939
...,
4040
examples=[
41-
"I have booked your flight from New York to Los Angeles departing Monday at 9am."
41+
'I have booked your flight from New York to Los Angeles departing Monday at 9am.'
4242
],
4343
)
4444
question: str = Field(
45-
..., examples=["Book a flight from NYC to LA for next Monday"]
45+
..., examples=['Book a flight from NYC to LA for next Monday']
4646
)
47-
reference: str = Field(..., examples=["Flight booked: NYC to LA, Monday departure"])
47+
reference: str = Field(..., examples=['Flight booked: NYC to LA, Monday departure'])
4848

4949

5050
class AgentGoalCompletenessRequest(BaseModel):
@@ -72,42 +72,42 @@ class AgentToolErrorDetectorRequest(BaseModel):
7272

7373

7474
class AnswerCompletenessRequest(BaseModel):
75-
completion: str = Field(..., examples=["Paris."])
76-
context: str = Field(..., examples=["The capital of France is Paris."])
77-
question: str = Field(..., examples=["What is the capital of France?"])
75+
completion: str = Field(..., examples=['Paris.'])
76+
context: str = Field(..., examples=['The capital of France is Paris.'])
77+
question: str = Field(..., examples=['What is the capital of France?'])
7878

7979

8080
class AnswerCorrectnessRequest(BaseModel):
81-
completion: str = Field(..., examples=["World War II ended in 1945."])
82-
ground_truth: str = Field(..., examples=["1945"])
83-
question: str = Field(..., examples=["What year did World War II end?"])
81+
completion: str = Field(..., examples=['World War II ended in 1945.'])
82+
ground_truth: str = Field(..., examples=['1945'])
83+
question: str = Field(..., examples=['What year did World War II end?'])
8484

8585

8686
class AnswerRelevancyRequest(BaseModel):
87-
answer: str = Field(..., examples=["The capital of France is Paris."])
88-
question: str = Field(..., examples=["What is the capital of France?"])
87+
answer: str = Field(..., examples=['The capital of France is Paris.'])
88+
question: str = Field(..., examples=['What is the capital of France?'])
8989

9090

9191
class CharCountRatioRequest(BaseModel):
9292
denominator_text: str = Field(
93-
..., examples=["This is a longer text for comparison"]
93+
..., examples=['This is a longer text for comparison']
9494
)
95-
numerator_text: str = Field(..., examples=["Short text"])
95+
numerator_text: str = Field(..., examples=['Short text'])
9696

9797

9898
class CharCountRequest(BaseModel):
99-
text: str = Field(..., examples=["Hello, world! This is a sample text."])
99+
text: str = Field(..., examples=['Hello, world! This is a sample text.'])
100100

101101

102102
class ContextRelevanceRequest(BaseModel):
103103
context: str = Field(
104104
...,
105105
examples=[
106-
"Our store is open Monday to Friday from 9am to 6pm, and Saturday from 10am to 4pm. We are closed on Sundays."
106+
'Our store is open Monday to Friday from 9am to 6pm, and Saturday from 10am to 4pm. We are closed on Sundays.'
107107
],
108108
)
109-
model: Optional[str] = Field(None, examples=["gpt-4o"])
110-
query: str = Field(..., examples=["What are the business hours?"])
109+
model: Optional[str] = Field(None, examples=['gpt-4o'])
110+
query: str = Field(..., examples=['What are the business hours?'])
111111

112112

113113
class ConversationQualityRequest(BaseModel):
@@ -117,33 +117,33 @@ class ConversationQualityRequest(BaseModel):
117117
'["Hi! I\'d be happy to assist you today.", "We offer consulting, development, and support services."]'
118118
],
119119
)
120-
model: Optional[str] = Field(None, examples=["gpt-4o"])
120+
model: Optional[str] = Field(None, examples=['gpt-4o'])
121121
prompts: str = Field(
122122
..., examples=['["Hello, how can I help?", "What services do you offer?"]']
123123
)
124124

125125

126126
class FaithfulnessRequest(BaseModel):
127127
completion: str = Field(
128-
..., examples=["The Eiffel Tower is located in Paris and was built in 1889."]
128+
..., examples=['The Eiffel Tower is located in Paris and was built in 1889.']
129129
)
130130
context: str = Field(
131131
...,
132132
examples=[
133-
"The Eiffel Tower is a wrought-iron lattice tower on the Champ de Mars in Paris, France. It was constructed from 1887 to 1889."
133+
'The Eiffel Tower is a wrought-iron lattice tower on the Champ de Mars in Paris, France. It was constructed from 1887 to 1889.'
134134
],
135135
)
136-
question: str = Field(..., examples=["When was the Eiffel Tower built?"])
136+
question: str = Field(..., examples=['When was the Eiffel Tower built?'])
137137

138138

139139
class InstructionAdherenceRequest(BaseModel):
140140
instructions: str = Field(
141-
..., examples=["Respond in exactly 3 bullet points and use formal language."]
141+
..., examples=['Respond in exactly 3 bullet points and use formal language.']
142142
)
143143
response: str = Field(
144144
...,
145145
examples=[
146-
"- First point about the topic\n- Second relevant consideration\n- Final concluding thought"
146+
'- First point about the topic\n- Second relevant consideration\n- Final concluding thought'
147147
],
148148
)
149149

@@ -155,7 +155,7 @@ class IntentChangeRequest(BaseModel):
155155
'["Sure, I can help with hotel booking", "No problem, let me search for flights"]'
156156
],
157157
)
158-
model: Optional[str] = Field(None, examples=["gpt-4o"])
158+
model: Optional[str] = Field(None, examples=['gpt-4o'])
159159
prompts: str = Field(
160160
...,
161161
examples=['["I want to book a hotel", "Actually, I need a flight instead"]'],
@@ -164,7 +164,7 @@ class IntentChangeRequest(BaseModel):
164164

165165
class JSONValidatorRequest(BaseModel):
166166
enable_schema_validation: Optional[bool] = Field(None, examples=[True])
167-
schema_string: Optional[str] = Field(None, examples=["{}"])
167+
schema_string: Optional[str] = Field(None, examples=['{}'])
168168
text: str = Field(..., examples=['{"name": "John", "age": 30}'])
169169

170170

@@ -173,105 +173,105 @@ class PIIDetectorRequest(BaseModel):
173173
text: str = Field(
174174
...,
175175
examples=[
176-
"Please contact John Smith at john.smith@email.com or call 555-123-4567."
176+
'Please contact John Smith at john.smith@email.com or call 555-123-4567.'
177177
],
178178
)
179179

180180

181181
class PerplexityRequest(BaseModel):
182-
logprobs: str = Field(..., examples=["[-2.3, -1.5, -0.8, -1.2, -0.5]"])
182+
logprobs: str = Field(..., examples=['[-2.3, -1.5, -0.8, -1.2, -0.5]'])
183183

184184

185185
class PlaceholderRegexRequest(BaseModel):
186186
case_sensitive: Optional[bool] = Field(None, examples=[True])
187187
dot_include_nl: Optional[bool] = Field(None, examples=[True])
188188
multi_line: Optional[bool] = Field(None, examples=[True])
189189
placeholder_value: str = Field(
190-
..., examples=["[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}"]
190+
..., examples=['[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}']
191191
)
192192
should_match: Optional[bool] = Field(None, examples=[True])
193-
text: str = Field(..., examples=["user@example.com"])
193+
text: str = Field(..., examples=['user@example.com'])
194194

195195

196196
class ProfanityDetectorRequest(BaseModel):
197-
text: str = Field(..., examples=["This is a clean and professional message."])
197+
text: str = Field(..., examples=['This is a clean and professional message.'])
198198

199199

200200
class PromptInjectionRequest(BaseModel):
201-
prompt: str = Field(..., examples=["What is the weather like today?"])
201+
prompt: str = Field(..., examples=['What is the weather like today?'])
202202
threshold: Optional[float] = Field(None, examples=[0.5])
203203

204204

205205
class PromptPerplexityRequest(BaseModel):
206-
prompt: str = Field(..., examples=["What is the capital of France?"])
206+
prompt: str = Field(..., examples=['What is the capital of France?'])
207207

208208

209209
class RegexValidatorRequest(BaseModel):
210210
case_sensitive: Optional[bool] = Field(None, examples=[True])
211211
dot_include_nl: Optional[bool] = Field(None, examples=[True])
212212
multi_line: Optional[bool] = Field(None, examples=[True])
213-
regex: Optional[str] = Field(None, examples=[".*"])
213+
regex: Optional[str] = Field(None, examples=['.*'])
214214
should_match: Optional[bool] = Field(None, examples=[True])
215-
text: str = Field(..., examples=["user@example.com"])
215+
text: str = Field(..., examples=['user@example.com'])
216216

217217

218218
class SQLValidatorRequest(BaseModel):
219-
text: str = Field(..., examples=["SELECT * FROM users WHERE id = 1;"])
219+
text: str = Field(..., examples=['SELECT * FROM users WHERE id = 1;'])
220220

221221

222222
class SecretsDetectorRequest(BaseModel):
223223
text: str = Field(
224-
..., examples=["Here is some text without any API keys or passwords."]
224+
..., examples=['Here is some text without any API keys or passwords.']
225225
)
226226

227227

228228
class SemanticSimilarityRequest(BaseModel):
229-
completion: str = Field(..., examples=["The cat sat on the mat."])
230-
reference: str = Field(..., examples=["A feline was resting on the rug."])
229+
completion: str = Field(..., examples=['The cat sat on the mat.'])
230+
reference: str = Field(..., examples=['A feline was resting on the rug.'])
231231

232232

233233
class SexismDetectorRequest(BaseModel):
234234
text: str = Field(
235235
...,
236-
examples=["All team members should be treated equally regardless of gender."],
236+
examples=['All team members should be treated equally regardless of gender.'],
237237
)
238238
threshold: Optional[float] = Field(None, examples=[0.5])
239239

240240

241241
class ToneDetectionRequest(BaseModel):
242-
text: str = Field(..., examples=["The capital of France is Paris."])
242+
text: str = Field(..., examples=['The capital of France is Paris.'])
243243

244244

245245
class TopicAdherenceRequest(BaseModel):
246246
completion: str = Field(
247247
...,
248248
examples=[
249-
"Machine learning is a subset of AI that enables systems to learn from data."
249+
'Machine learning is a subset of AI that enables systems to learn from data.'
250250
],
251251
)
252-
question: str = Field(..., examples=["Tell me about machine learning"])
252+
question: str = Field(..., examples=['Tell me about machine learning'])
253253
reference_topics: str = Field(
254-
..., examples=["artificial intelligence, data science, algorithms"]
254+
..., examples=['artificial intelligence, data science, algorithms']
255255
)
256256

257257

258258
class ToxicityDetectorRequest(BaseModel):
259-
text: str = Field(..., examples=["Thank you for your help with this project."])
259+
text: str = Field(..., examples=['Thank you for your help with this project.'])
260260
threshold: Optional[float] = Field(None, examples=[0.5])
261261

262262

263263
class UncertaintyDetectorRequest(BaseModel):
264264
prompt: str = Field(
265-
..., examples=["I am not sure, I think the capital of France is Paris."]
265+
..., examples=['I am not sure, I think the capital of France is Paris.']
266266
)
267267

268268

269269
class WordCountRatioRequest(BaseModel):
270270
denominator_text: str = Field(
271-
..., examples=["This is a longer input text for comparison"]
271+
..., examples=['This is a longer input text for comparison']
272272
)
273-
numerator_text: str = Field(..., examples=["Short response"])
273+
numerator_text: str = Field(..., examples=['Short response'])
274274

275275

276276
class WordCountRequest(BaseModel):
277-
text: str = Field(..., examples=["This is a sample text with several words."])
277+
text: str = Field(..., examples=['This is a sample text with several words.'])

0 commit comments

Comments
 (0)