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

tool_choice='required' is now supported by Azure but blocked in langchain #25864

Closed
5 tasks done
meliascosta opened this issue Aug 29, 2024 · 4 comments
Closed
5 tasks done
Assignees
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature investigate

Comments

@meliascosta
Copy link

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

In line 662 here: https://github.com/langchain-ai/langchain/blob/master/libs/partners/openai/langchain_openai/chat_models/azure.py#L662

we can see that tool_choice = 'required' is explicitly filtered out

and a note in a comment saying:
# As of 05/2024 Azure OpenAI doesn't support tool_choice="required".
# TODO: Update this condition once tool_choice="required" is supported.

It is now supported in the preview API from July https://learn.microsoft.com/en-us/rest/api/azureopenai/operation-groups?view=rest-azureopenai-2024-07-01-preview&preserve-view=true

Error Message and Stack Trace (if applicable)

ValueError("Azure OpenAI does not currently support tool_choice='required'. Should be one of 'auto', 'none', or the name of the tool to call.")

Description

I would like to use the setting

System Info

System Information

OS: Linux
OS Version: #1 SMP Fri Mar 29 23:14:13 UTC 2024
Python Version: 3.12.3 (main, May 23 2024, 22:52:35) [GCC 9.4.0]

Package Information

langchain_core: 0.2.33
langchain: 0.2.14
langchain_community: 0.2.12
langsmith: 0.1.99
langchain_openai: 0.1.22
langchain_postgres: 0.0.6
langchain_text_splitters: 0.2.2
langgraph: 0.0.65
langserve: 0.2.2

Other Dependencies

aiohttp: 3.10.3
async-timeout: Installed. No version info available.
dataclasses-json: 0.6.7
fastapi: 0.109.2
httpx: 0.27.0
jsonpatch: 1.33
numpy: 1.26.4
openai: 1.41.0
orjson: 3.10.7
packaging: 24.1
pgvector: 0.2.5
psycopg: 3.2.1
psycopg-pool: 3.2.2
pydantic: 2.8.2
pyproject-toml: 0.0.10
PyYAML: 6.0.2
requests: 2.32.3
sqlalchemy: 2.0.32
SQLAlchemy: 2.0.32
sse-starlette: 1.8.2
tenacity: 8.5.0
tiktoken: 0.7.0
typing-extensions: 4.12.2

@langcarl langcarl bot added the investigate label Aug 29, 2024
@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Aug 29, 2024
@prasanjeevi
Copy link

I'm also facing the same issue

@kftam1994
Copy link

It limits the usage of more than one tool with “required” tool choice
Would it be updated in the coming versions?

@baskaryan
Copy link
Collaborator

should be fixed as of #26599 which was released in langchain-openai 0.2.2. @meliascosta @prasanjeevi @kftam1994 let me know if you're still seeing issues!

@meliascosta
Copy link
Author

Great! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature investigate
Projects
None yet
Development

No branches or pull requests

4 participants