-
Notifications
You must be signed in to change notification settings - Fork 51
Add reasoningEffort/reasoning_effort parameter support #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+271
−1
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| import { expect, test, describe } from "vitest"; | ||
| import { LLMClassifierFromTemplate } from "./llm"; | ||
| import { Score } from "./score"; | ||
|
|
||
| describe("reasoning parameters", () => { | ||
| test("accepts reasoningEffort in LLMArgs", () => { | ||
| // This test just verifies that the type system accepts reasoningEffort | ||
| // We don't actually call the API to avoid requiring credentials in tests | ||
| const classifier = LLMClassifierFromTemplate({ | ||
| name: "test", | ||
| promptTemplate: "Evaluate: {{output}}", | ||
| choiceScores: { good: 1, bad: 0 }, | ||
| model: "o3-mini", | ||
| reasoningEffort: "high", | ||
| }); | ||
|
|
||
| expect(classifier).toBeDefined(); | ||
| expect(typeof classifier).toBe("function"); | ||
| }); | ||
|
|
||
| test("accepts all valid reasoningEffort values", () => { | ||
| const validValues: Array< | ||
| "minimal" | "low" | "medium" | "high" | null | undefined | ||
| > = ["minimal", "low", "medium", "high", null, undefined]; | ||
|
|
||
| for (const value of validValues) { | ||
| const classifier = LLMClassifierFromTemplate({ | ||
| name: "test", | ||
| promptTemplate: "Evaluate: {{output}}", | ||
| choiceScores: { good: 1, bad: 0 }, | ||
| model: "o3-mini", | ||
| reasoningEffort: value, | ||
| }); | ||
|
|
||
| expect(classifier).toBeDefined(); | ||
| } | ||
| }); | ||
|
|
||
| test("reasoningEffort can be passed at runtime", () => { | ||
| const classifier = LLMClassifierFromTemplate({ | ||
| name: "test", | ||
| promptTemplate: "Evaluate: {{output}}", | ||
| choiceScores: { good: 1, bad: 0 }, | ||
| model: "o3-mini", | ||
| }); | ||
|
|
||
| // TypeScript should allow passing reasoningEffort at runtime | ||
| // This verifies the type allows it (actual API call would require credentials) | ||
| expect(classifier).toBeDefined(); | ||
| }); | ||
|
|
||
| test("accepts reasoningEnabled parameter", () => { | ||
| // Test that the type system accepts reasoningEnabled | ||
| const classifier = LLMClassifierFromTemplate({ | ||
| name: "test", | ||
| promptTemplate: "Evaluate: {{output}}", | ||
| choiceScores: { good: 1, bad: 0 }, | ||
| model: "claude-3-5-sonnet-20241022", | ||
| reasoningEnabled: true, | ||
| }); | ||
|
|
||
| expect(classifier).toBeDefined(); | ||
| expect(typeof classifier).toBe("function"); | ||
| }); | ||
|
|
||
| test("accepts reasoningBudget parameter", () => { | ||
| // Test that the type system accepts reasoningBudget | ||
| const classifier = LLMClassifierFromTemplate({ | ||
| name: "test", | ||
| promptTemplate: "Evaluate: {{output}}", | ||
| choiceScores: { good: 1, bad: 0 }, | ||
| model: "claude-3-5-sonnet-20241022", | ||
| reasoningBudget: 2048, | ||
| }); | ||
|
|
||
| expect(classifier).toBeDefined(); | ||
| expect(typeof classifier).toBe("function"); | ||
| }); | ||
|
|
||
| test("accepts all reasoning parameters together", () => { | ||
| // Test that all reasoning parameters can be used together | ||
| const classifier = LLMClassifierFromTemplate({ | ||
| name: "test", | ||
| promptTemplate: "Evaluate: {{output}}", | ||
| choiceScores: { good: 1, bad: 0 }, | ||
| model: "o3-mini", | ||
| reasoningEffort: "high", | ||
| reasoningEnabled: true, | ||
| reasoningBudget: 4096, | ||
| }); | ||
|
|
||
| expect(classifier).toBeDefined(); | ||
| expect(typeof classifier).toBe("function"); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| """Tests for reasoning parameter support.""" | ||
|
|
||
| import pytest | ||
|
|
||
| from autoevals.llm import LLMClassifier | ||
|
|
||
|
|
||
| def test_reasoning_effort_in_constructor(): | ||
| """Test that LLMClassifier accepts reasoning_effort parameter.""" | ||
| classifier = LLMClassifier( | ||
| name="test", | ||
| prompt_template="Evaluate: {{output}}", | ||
| choice_scores={"good": 1, "bad": 0}, | ||
| model="o3-mini", | ||
| reasoning_effort="high", | ||
| ) | ||
|
|
||
| assert classifier is not None | ||
| assert classifier.extra_args.get("reasoning_effort") == "high" | ||
|
|
||
|
|
||
| def test_reasoning_effort_values(): | ||
| """Test that all valid reasoning_effort values are accepted.""" | ||
| valid_values = ["minimal", "low", "medium", "high", None] | ||
|
|
||
| for value in valid_values: | ||
| classifier = LLMClassifier( | ||
| name="test", | ||
| prompt_template="Evaluate: {{output}}", | ||
| choice_scores={"good": 1, "bad": 0}, | ||
| model="o3-mini", | ||
| reasoning_effort=value, | ||
| ) | ||
|
|
||
| assert classifier is not None | ||
| if value is not None: | ||
| assert classifier.extra_args.get("reasoning_effort") == value | ||
| else: | ||
| assert "reasoning_effort" not in classifier.extra_args | ||
|
|
||
|
|
||
| def test_reasoning_effort_not_set_by_default(): | ||
| """Test that reasoning_effort is not set when not provided.""" | ||
| classifier = LLMClassifier( | ||
| name="test", | ||
| prompt_template="Evaluate: {{output}}", | ||
| choice_scores={"good": 1, "bad": 0}, | ||
| model="o3-mini", | ||
| ) | ||
|
|
||
| assert "reasoning_effort" not in classifier.extra_args | ||
|
|
||
|
|
||
| def test_reasoning_enabled_in_constructor(): | ||
| """Test that LLMClassifier accepts reasoning_enabled parameter.""" | ||
| classifier = LLMClassifier( | ||
| name="test", | ||
| prompt_template="Evaluate: {{output}}", | ||
| choice_scores={"good": 1, "bad": 0}, | ||
| model="claude-3-5-sonnet-20241022", | ||
| reasoning_enabled=True, | ||
| ) | ||
|
|
||
| assert classifier is not None | ||
| assert classifier.extra_args.get("reasoning_enabled") is True | ||
|
|
||
|
|
||
| def test_reasoning_budget_in_constructor(): | ||
| """Test that LLMClassifier accepts reasoning_budget parameter.""" | ||
| classifier = LLMClassifier( | ||
| name="test", | ||
| prompt_template="Evaluate: {{output}}", | ||
| choice_scores={"good": 1, "bad": 0}, | ||
| model="claude-3-5-sonnet-20241022", | ||
| reasoning_budget=2048, | ||
| ) | ||
|
|
||
| assert classifier is not None | ||
| assert classifier.extra_args.get("reasoning_budget") == 2048 | ||
|
|
||
|
|
||
| def test_all_reasoning_parameters(): | ||
| """Test that all reasoning parameters can be used together.""" | ||
| classifier = LLMClassifier( | ||
| name="test", | ||
| prompt_template="Evaluate: {{output}}", | ||
| choice_scores={"good": 1, "bad": 0}, | ||
| model="o3-mini", | ||
| reasoning_effort="high", | ||
| reasoning_enabled=True, | ||
| reasoning_budget=4096, | ||
| ) | ||
|
|
||
| assert classifier is not None | ||
| assert classifier.extra_args.get("reasoning_effort") == "high" | ||
| assert classifier.extra_args.get("reasoning_enabled") is True | ||
| assert classifier.extra_args.get("reasoning_budget") == 4096 | ||
|
|
||
|
|
||
| def test_reasoning_enabled_not_set_by_default(): | ||
| """Test that reasoning_enabled is not set when not provided.""" | ||
| classifier = LLMClassifier( | ||
| name="test", | ||
| prompt_template="Evaluate: {{output}}", | ||
| choice_scores={"good": 1, "bad": 0}, | ||
| model="claude-3-5-sonnet-20241022", | ||
| ) | ||
|
|
||
| assert "reasoning_enabled" not in classifier.extra_args | ||
|
|
||
|
|
||
| def test_reasoning_budget_not_set_by_default(): | ||
| """Test that reasoning_budget is not set when not provided.""" | ||
| classifier = LLMClassifier( | ||
| name="test", | ||
| prompt_template="Evaluate: {{output}}", | ||
| choice_scores={"good": 1, "bad": 0}, | ||
| model="claude-3-5-sonnet-20241022", | ||
| ) | ||
|
|
||
| assert "reasoning_budget" not in classifier.extra_args |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.