-
Notifications
You must be signed in to change notification settings - Fork 0
chore: change llm provider to groq #91
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
Changes from all commits
7ee3b4f
84c15e9
0530b8c
3c32ac3
1e9bd17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,14 +37,16 @@ def parse_inline_review(text: str) -> Dict[str, Any]: | |
| Raises: | ||
| ValueError: If JSON is invalid or schema doesn't match | ||
| """ | ||
| # Strip markdown code blocks if present (e.g., ```json\n{...}\n```) | ||
| # Use regex to handle variations: ```json, ```, ````json, etc. | ||
| text = text.strip() | ||
| # Remove opening fence: ```json or ``` or ````json (optional language identifier) | ||
| text = re.sub(r'^```+(?:json)?\s*\n?', '', text, flags=re.IGNORECASE) | ||
| # Remove closing fence: ``` or ```` | ||
| text = re.sub(r'\n?```+\s*$', '', text) | ||
| text = text.strip() | ||
| # Extract JSON if it's wrapped in markdown blocks ANYWHERE in the text | ||
| match = re.search(r'```(?:json)?\s*(.*?)\s*```', text, flags=re.IGNORECASE | re.DOTALL) | ||
| if match: | ||
| text = match.group(1).strip() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🐛 Potential bug: The |
||
| else: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✨ Code style improvement: The regular expression used to extract JSON from markdown blocks could be more efficient. Consider using a more specific pattern to avoid potential false positives. |
||
| # Fallback: Extract from the first '{' to the last '}' | ||
| start = text.find('{') | ||
| end = text.rfind('}') | ||
| if start != -1 and end != -1 and end > start: | ||
| text = text[start:end+1] | ||
|
|
||
| # Try to parse JSON | ||
| try: | ||
|
|
@@ -101,11 +103,14 @@ def parse_inline_review(text: str) -> Dict[str, Any]: | |
| ) | ||
|
|
||
| # Validate severity value (case-insensitive) | ||
| # Note: We intentionally coerce invalid severities to "other" instead of raising an exception. | ||
| # This prevents open-source LLMs that hallucinate unsupported severities (e.g., "config") | ||
| # from crashing the entire inline review parsing process. | ||
| if comment["severity"].lower() not in VALID_SEVERITIES: | ||
| raise ValueError( | ||
| f"Comment [{i}] invalid severity: '{comment['severity']}'. " | ||
| f"Must be one of: {', '.join(VALID_SEVERITIES)}" | ||
| logger.warning( | ||
| f"Comment [{i}] invalid severity: '{comment['severity']}'. Coercing to 'other'." | ||
| ) | ||
| comment["severity"] = "other" | ||
|
|
||
| # Validate line number is positive | ||
| if comment["line"] <= 0: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Potential bug: The 'groq_api_key' is being used directly from secrets. Ensure that this key is properly secured and not exposed in the workflow file.