Skip to content

Commit

Permalink
fix: forcing response format to be JSON valid (#7692)
Browse files Browse the repository at this point in the history
* forcing response format to be JSON valid

* adding release notes

* cleaning up

* Update haystack/components/evaluators/llm_evaluator.py

Co-authored-by: Madeesh Kannan <[email protected]>

---------

Co-authored-by: Madeesh Kannan <[email protected]>
  • Loading branch information
davidsbatista and shadeMe authored May 14, 2024
1 parent a2be90b commit 75cf35c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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.

0 comments on commit 75cf35c

Please sign in to comment.