Skip to content
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

fix: forcing response format to be JSON valid #7692

Merged
merged 5 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion haystack/components/evaluators/llm_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ def __init__(
self.api_key = api_key

if api == "openai":
self.generator = OpenAIGenerator(api_key=api_key)
self.generator = OpenAIGenerator(
api_key=api_key, generation_kwargs={"response_format": {"type": "json_object"}}
)
else:
raise ValueError(f"Unsupported API: {api}")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

enhancements:
- |
Enforce JSON mode on OpenAI LLM-based evaluators so that the they always return valid JSON output.
This is to ensure that the output is always in a consistent format, regardless of the input.