autoevals 0.0.76__tar.gz → 0.0.78__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. {autoevals-0.0.76/py/autoevals.egg-info → autoevals-0.0.78}/PKG-INFO +2 -2
  2. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/llm.py +27 -15
  3. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/test_llm.py +3 -3
  4. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/test_partial.py +0 -2
  5. autoevals-0.0.78/py/autoevals/version.py +1 -0
  6. {autoevals-0.0.76 → autoevals-0.0.78/py/autoevals.egg-info}/PKG-INFO +2 -2
  7. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals.egg-info/requires.txt +1 -1
  8. {autoevals-0.0.76 → autoevals-0.0.78}/setup.py +1 -1
  9. autoevals-0.0.76/py/autoevals/version.py +0 -1
  10. {autoevals-0.0.76 → autoevals-0.0.78}/LICENSE +0 -0
  11. {autoevals-0.0.76 → autoevals-0.0.78}/MANIFEST.in +0 -0
  12. {autoevals-0.0.76 → autoevals-0.0.78}/README.md +0 -0
  13. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/__init__.py +0 -0
  14. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/json.py +0 -0
  15. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/list.py +0 -0
  16. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/moderation.py +0 -0
  17. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/number.py +0 -0
  18. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/oai.py +0 -0
  19. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/partial.py +0 -0
  20. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/ragas.py +0 -0
  21. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/string.py +0 -0
  22. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/templates/battle.yaml +0 -0
  23. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/templates/closed_q_a.yaml +0 -0
  24. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/templates/factuality.yaml +0 -0
  25. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/templates/humor.yaml +0 -0
  26. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/templates/possible.yaml +0 -0
  27. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/templates/security.yaml +0 -0
  28. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/templates/sql.yaml +0 -0
  29. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/templates/summary.yaml +0 -0
  30. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/templates/translation.yaml +0 -0
  31. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/test_embeddings.py +0 -0
  32. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/test_json.py +0 -0
  33. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/test_moderation.py +0 -0
  34. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/test_ragas.py +0 -0
  35. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals/test_values.py +0 -0
  36. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals.egg-info/SOURCES.txt +0 -0
  37. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals.egg-info/dependency_links.txt +0 -0
  38. {autoevals-0.0.76 → autoevals-0.0.78}/py/autoevals.egg-info/top_level.txt +0 -0
  39. {autoevals-0.0.76 → autoevals-0.0.78}/pyproject.toml +0 -0
  40. {autoevals-0.0.76 → autoevals-0.0.78}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: autoevals
3
- Version: 0.0.76
3
+ Version: 0.0.78
4
4
  Summary: Universal library for evaluating AI models
5
5
  Home-page: https://www.braintrustdata.com
6
6
  Author: BrainTrust
@@ -14,7 +14,7 @@ License-File: LICENSE
14
14
  Requires-Dist: chevron
15
15
  Requires-Dist: levenshtein
16
16
  Requires-Dist: pyyaml
17
- Requires-Dist: braintrust_core==0.0.45
17
+ Requires-Dist: braintrust_core==0.0.46
18
18
  Requires-Dist: jsonschema
19
19
  Provides-Extra: dev
20
20
  Requires-Dist: black; extra == "dev"
@@ -29,6 +29,7 @@ single choice by setting the `choice` parameter to a single choice from {{__choi
29
29
  "\n", " "
30
30
  )
31
31
 
32
+ DEFAULT_MODEL = "gpt-4o"
32
33
 
33
34
  PLAIN_RESPONSE_SCHEMA = {
34
35
  "properties": {"choice": {"description": "The choice", "title": "Choice", "type": "string"}},
@@ -41,9 +42,8 @@ COT_RESPONSE_SCHEMA = {
41
42
  "properties": {
42
43
  "reasons": {
43
44
  "description": "Write out in a step by step manner your reasoning to be sure that your conclusion is correct. Avoid simply stating the correct answer at the outset.",
44
- "items": {"type": "string"},
45
- "title": "Reasons",
46
- "type": "array",
45
+ "title": "Reasoning",
46
+ "type": "string",
47
47
  },
48
48
  "choice": {"description": "The choice", "title": "Choice", "type": "string"},
49
49
  },
@@ -53,7 +53,7 @@ COT_RESPONSE_SCHEMA = {
53
53
  }
54
54
 
55
55
 
56
- def build_classification_functions(useCoT, choice_strings):
56
+ def build_classification_tools(useCoT, choice_strings):
57
57
  params = COT_RESPONSE_SCHEMA if useCoT else PLAIN_RESPONSE_SCHEMA
58
58
  enum_params = {
59
59
  **params,
@@ -63,7 +63,14 @@ def build_classification_functions(useCoT, choice_strings):
63
63
  },
64
64
  }
65
65
  return [
66
- {"name": "select_choice", "description": "Call this function to select a choice.", "parameters": enum_params}
66
+ {
67
+ "type": "function",
68
+ "function": {
69
+ "name": "select_choice",
70
+ "description": "Call this function to select a choice.",
71
+ "parameters": enum_params,
72
+ },
73
+ }
67
74
  ]
68
75
 
69
76
 
@@ -101,7 +108,7 @@ class OpenAILLMClassifier(OpenAILLMScorer):
101
108
  messages: List,
102
109
  model,
103
110
  choice_scores,
104
- classification_functions,
111
+ classification_tools,
105
112
  render_args=None,
106
113
  max_tokens=None,
107
114
  temperature=None,
@@ -130,7 +137,7 @@ class OpenAILLMClassifier(OpenAILLMScorer):
130
137
  self.render_args.update(render_args)
131
138
 
132
139
  self.choice_scores = choice_scores
133
- self.classification_functions = classification_functions
140
+ self.classification_tools = classification_tools
134
141
 
135
142
  def _name(self):
136
143
  return self.name
@@ -139,8 +146,8 @@ class OpenAILLMClassifier(OpenAILLMScorer):
139
146
  return dict(
140
147
  model=self.model,
141
148
  messages=self._render_messages(output=output, expected=expected, **kwargs),
142
- functions=self.classification_functions,
143
- function_call={"name": "select_choice"},
149
+ tools=self.classification_tools,
150
+ tool_choice={"type": "function", "function": {"name": "select_choice"}},
144
151
  )
145
152
 
146
153
  def _render_messages(self, **kwargs):
@@ -168,12 +175,17 @@ class OpenAILLMClassifier(OpenAILLMScorer):
168
175
 
169
176
  def _process_response(self, resp):
170
177
  metadata = {}
171
- args = json.loads(resp["function_call"]["arguments"])
178
+ if "tool_calls" not in resp:
179
+ raise ValueError("No tool call found in response")
180
+ tool_call = resp["tool_calls"][0]
181
+ if tool_call["function"]["name"] != "select_choice":
182
+ raise ValueError(f"Unexpected tool call ({tool_call['function']['name']}) found in response")
183
+ args = json.loads(tool_call["function"]["arguments"])
184
+
185
+ metadata["choice"] = args["choice"].strip()
172
186
  if "reasons" in args:
173
187
  metadata["rationale"] = "\n".join(args["reasons"])
174
- if "function_call" not in resp:
175
- raise ValueError("No function call found in response")
176
- metadata["choice"] = args["choice"].strip()
188
+
177
189
  score = self.choice_scores[metadata["choice"]]
178
190
  return Score(name=self.name, score=score, metadata=metadata)
179
191
 
@@ -212,7 +224,7 @@ class LLMClassifier(OpenAILLMClassifier):
212
224
  name,
213
225
  prompt_template,
214
226
  choice_scores,
215
- model="gpt-3.5-turbo",
227
+ model=DEFAULT_MODEL,
216
228
  use_cot=True,
217
229
  max_tokens=512,
218
230
  temperature=0,
@@ -236,7 +248,7 @@ class LLMClassifier(OpenAILLMClassifier):
236
248
  messages=messages,
237
249
  model=model,
238
250
  choice_scores=choice_scores,
239
- classification_functions=build_classification_functions(use_cot, choice_strings),
251
+ classification_tools=build_classification_tools(use_cot, choice_strings),
240
252
  max_tokens=max_tokens,
241
253
  temperature=temperature,
242
254
  engine=engine,
@@ -4,7 +4,7 @@ import os
4
4
  import chevron
5
5
 
6
6
  from autoevals.llm import *
7
- from autoevals.llm import build_classification_functions
7
+ from autoevals.llm import build_classification_tools
8
8
 
9
9
 
10
10
  def test_template_html():
@@ -41,7 +41,7 @@ the select_choice function with "1" or "2".""",
41
41
  ],
42
42
  model="gpt-3.5-turbo",
43
43
  choice_scores={"1": 1, "2": 0},
44
- classification_functions=build_classification_functions(useCoT=True, choice_strings=["1", "2"]),
44
+ classification_tools=build_classification_tools(useCoT=True, choice_strings=["1", "2"]),
45
45
  max_tokens=500,
46
46
  )
47
47
 
@@ -129,7 +129,7 @@ def test_battle():
129
129
  )
130
130
 
131
131
  print(response.as_json(indent=2))
132
- assert response.score == (1 if use_cot else 0)
132
+ assert response.score == 1
133
133
  assert response.error is None
134
134
 
135
135
  response = e(instructions="Add the following numbers: 1, 2, 3", output="6", expected="6")
@@ -7,12 +7,10 @@ def test_partial():
7
7
  levenshtein_partial = Levenshtein.partial(expected="abcd")()(output="abc")
8
8
  assert levenshtein_partial.score == levenshtein_basic.score
9
9
  assert levenshtein_partial.name == levenshtein_basic.name
10
- assert levenshtein_partial.metadata == levenshtein_basic.metadata
11
10
  assert levenshtein_partial.name == "Levenshtein"
12
11
 
13
12
  closedqa_basic = ClosedQA()(criteria="Is the answer correct?", input="What is 1+1?", output="2")
14
13
  closedqa_partial = ClosedQA.partial(criteria="Is the answer correct?")()(input="What is 1+1?", output="2")
15
14
  assert closedqa_partial.score == closedqa_basic.score
16
15
  assert closedqa_partial.name == closedqa_basic.name
17
- assert closedqa_partial.metadata == closedqa_basic.metadata
18
16
  assert closedqa_partial.name == "ClosedQA"
@@ -0,0 +1 @@
1
+ VERSION = "0.0.78"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: autoevals
3
- Version: 0.0.76
3
+ Version: 0.0.78
4
4
  Summary: Universal library for evaluating AI models
5
5
  Home-page: https://www.braintrustdata.com
6
6
  Author: BrainTrust
@@ -14,7 +14,7 @@ License-File: LICENSE
14
14
  Requires-Dist: chevron
15
15
  Requires-Dist: levenshtein
16
16
  Requires-Dist: pyyaml
17
- Requires-Dist: braintrust_core==0.0.45
17
+ Requires-Dist: braintrust_core==0.0.46
18
18
  Requires-Dist: jsonschema
19
19
  Provides-Extra: dev
20
20
  Requires-Dist: black; extra == "dev"
@@ -1,7 +1,7 @@
1
1
  chevron
2
2
  levenshtein
3
3
  pyyaml
4
- braintrust_core==0.0.45
4
+ braintrust_core==0.0.46
5
5
  jsonschema
6
6
 
7
7
  [all]
@@ -11,7 +11,7 @@ with open(os.path.join(dir_name, "py", "autoevals", "version.py"), encoding="utf
11
11
  with open(os.path.join(dir_name, "README.md"), "r", encoding="utf-8") as f:
12
12
  long_description = f.read()
13
13
 
14
- install_requires = ["chevron", "levenshtein", "pyyaml", "braintrust_core==0.0.45", "jsonschema"]
14
+ install_requires = ["chevron", "levenshtein", "pyyaml", "braintrust_core==0.0.46", "jsonschema"]
15
15
 
16
16
  extras_require = {
17
17
  "dev": [
@@ -1 +0,0 @@
1
- VERSION = "0.0.76"
File without changes
File without changes
File without changes
File without changes
File without changes