-
Notifications
You must be signed in to change notification settings - Fork 1
Fixes issues when running Goose on Windows. #16
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
Open
valerie-autumn-skye
wants to merge
21
commits into
main
Choose a base branch
from
literature-eval-issues
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
cd95918
Enforce UTF-8 for Goose session files.
a791ce5
Fixes issue #15. Prevents divide by zero errors and cleans up summari…
49891a3
Cleaned up output by using consistent printing methods.
46ad344
Fixes Issue #18 by implementing metric downgrades to Claude if OpenAP…
fc7ba41
Satisfied ruff's bizarre rules.
54dd3d3
Added extra logging and test for goose UTF-8 handling.
72f586c
Added metacoder configuration test cases for claude downgrade and no …
d7beb19
Added unit test for claude downgrade to support Issue #18. Cleaned up…
d88ca90
Added unit test for claude downgrade to support Issue #18. Cleaned up…
e7bba40
Added assertion to confirm that ClaudeJudge completed scoring the met…
d27277b
Added assertion to force test to fail on Exception. Increased logging…
3f22fc6
Fixed runtime issues related to metric downgrade from CorrectnessMetr…
d6e1e44
Added test coverage of new evaluation judge functionality. Added test…
882a3d9
Reduced logging verbosity. Added Anthropic quota check. Added automat…
c98c9d7
Fixed issue #23. Forced processes to be launched with UTF-8 encoding …
4761d19
Addressed ruff formatting issue.
6b64a79
Added output file check to fail if the output file already exists. Ot…
c436e7f
Modified save_results to append to existing output file rather than o…
b0b1c8b
Updated ClaudeJudge model to claude-sonnet-4-20250514.
a7e71e3
Revert "Modified save_results to append to existing output file rathe…
7e143da
Added UTF-8 encoding to prevent character mangling during YAML export…
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
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
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,93 @@ | ||
| # metacoder/evals/judges.py | ||
| import logging | ||
| import os | ||
|
|
||
| from anthropic import Anthropic | ||
| from anthropic.types import MessageParam, TextBlockParam, TextBlock | ||
|
|
||
| from deepeval.models.base_model import DeepEvalBaseLLM | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class ClaudeJudge(DeepEvalBaseLLM): | ||
| """ | ||
| Wraps Anthropic's Claude models so they can be used as | ||
| the `model` parameter to DeepEval metrics like GEval. | ||
| """ | ||
|
|
||
| # Note: Anthropic models can be listed via: | ||
| # curl https://api.anthropic.com/v1/models --header "x-api-key: %ANTHROPIC_API_KEY%" --header "anthropic-version: 2023-06-01" | ||
| # {"data": [{"type": "model", "id": "claude-opus-4-1-20250805", "display_name": "Claude Opus 4.1", "created_at": "2025-08-05T00:00:00Z"}, ... ]} | ||
| # Current list (September 3, 2025): | ||
| # claude-opus-4-1-20250805, claude-opus-4-20250514, claude-sonnet-4-20250514, claude-3-7-sonnet-20250219, | ||
| # claude-3-5-sonnet-20241022, claude-3-5-haiku-20241022, claude-3-5-sonnet-20240620, claude-3-haiku-20240307, | ||
| # claude-3-opus-20240229 | ||
|
|
||
| def __init__( | ||
| self, | ||
| model_name: str = "claude-sonnet-4-20250514", | ||
| max_tokens: int = 1024, | ||
| temperature: float = 0.0, | ||
| ): | ||
| super().__init__() | ||
| api_key = os.getenv("ANTHROPIC_API_KEY") | ||
| if not api_key: | ||
| raise Exception("ANTHROPIC_API_KEY is not set in environment") | ||
| self.client = Anthropic(api_key=api_key) | ||
| self.model_name = model_name | ||
| self.max_tokens = max_tokens | ||
| self.temperature = temperature | ||
|
|
||
| def load_model(self): | ||
| return self | ||
|
|
||
| def generate(self, prompt: str) -> str: | ||
| # Build typed content blocks and messages to satisfy the SDK's type hints | ||
| content: list[TextBlockParam] = [{"type": "text", "text": prompt}] | ||
| messages: list[MessageParam] = [{"role": "user", "content": content}] | ||
| resp = self.client.messages.create( | ||
| model=self.model_name, | ||
| max_tokens=self.max_tokens, | ||
| temperature=self.temperature, | ||
| messages=messages, | ||
| ) | ||
| # anthropic returns a list of content blocks; collect only the text blocks. | ||
| parts: list[str] = [] | ||
| for block in resp.content: | ||
| if isinstance(block, TextBlock): | ||
| parts.append(block.text) | ||
| return "".join(parts) | ||
|
|
||
| async def a_generate(self, prompt: str) -> str: | ||
| # for now just call the sync path | ||
| return self.generate(prompt) | ||
|
|
||
| def get_model_name(self) -> str: | ||
| return self.model_name | ||
|
|
||
| def has_available_quota(self) -> bool: | ||
| """ | ||
| Try a very lightweight request to check if quota is available. | ||
| Returns True if quota exists, False if Anthropic responds with | ||
| quota-related errors. | ||
| """ | ||
| try: | ||
| # Use a minimal "ping" request | ||
| content: list[TextBlockParam] = [{"type": "text", "text": "ping"}] | ||
| messages: list[MessageParam] = [{"role": "user", "content": content}] | ||
| self.client.messages.create( | ||
| model=self.model_name, | ||
| max_tokens=1, # cheapest possible | ||
| temperature=0.0, | ||
| messages=messages, | ||
| ) | ||
| return True | ||
| except Exception as e: | ||
| msg = str(e).lower() | ||
| # Check for insufficient quota: | ||
| # 400 Bad Request. Message: Your credit balance is too low to access the Anthropic API. Please go to Plans & Billing to upgrade or purchase credits. | ||
| if "credit balance is too low" in msg or "400" in msg: | ||
| logger.warning(f"ClaudeJudge quota check failed: {e}") | ||
| return False | ||
| raise | ||
Oops, something went wrong.
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.