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: OpenAIChatGenerator - do not pass tools to the OpenAI client when none are provided #8702

Merged
merged 3 commits into from
Jan 10, 2025

Conversation

anakin87
Copy link
Member

@anakin87 anakin87 commented Jan 10, 2025

Related Issues

In the OpenAIChatGenerator, when no tools are provided, we pass None to the client.
This is problematic for OpenAI-compatible APIs which do not support tools.
This issue was encountered in deepset-ai/haystack-core-integrations#1274

Proposed Changes:

  • do not pass tools to the OpenAI client when none are provided

How did you test it?

CI, adapted existing tests to check whether we pass tools or not

Checklist

  • I have read the contributors guidelines and the code of conduct
  • I have updated the related issue with new insights and changes
  • I added unit tests and updated the docstrings
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I documented my code
  • I ran pre-commit hooks and fixed any issue

@anakin87 anakin87 changed the title fix: do not pass tools to the OpenAI client if None fix: do not pass tools to the OpenAI client when none are provided Jan 10, 2025
@anakin87 anakin87 changed the title fix: do not pass tools to the OpenAI client when none are provided fix: OpenAIChatGenerator - do not pass tools to the OpenAI client when none are provided Jan 10, 2025
@anakin87 anakin87 marked this pull request as ready for review January 10, 2025 12:16
@anakin87 anakin87 requested review from a team as code owners January 10, 2025 12:16
@anakin87 anakin87 requested review from dfokina, vblagoje and julian-risch and removed request for a team January 10, 2025 12:16
@anakin87 anakin87 added this to the 2.9.0 milestone Jan 10, 2025
@anakin87 anakin87 self-assigned this Jan 10, 2025
@coveralls
Copy link
Collaborator

coveralls commented Jan 10, 2025

Pull Request Test Coverage Report for Build 12709332184

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.001%) to 91.1%

Files with Coverage Reduction New Missed Lines %
components/generators/chat/openai.py 2 96.27%
Totals Coverage Status
Change from base Build 12708466879: 0.001%
Covered Lines: 8660
Relevant Lines: 9506

💛 - Coveralls

@anakin87 anakin87 merged commit 741ce5d into main Jan 10, 2025
33 checks passed
@anakin87 anakin87 deleted the openai-pass-tools-to-client-if-not-null branch January 10, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants