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

Incompatibility with latest Anthropic Client #6883

Closed
1 of 14 tasks
rasharab opened this issue Jun 28, 2023 · 5 comments
Closed
1 of 14 tasks

Incompatibility with latest Anthropic Client #6883

rasharab opened this issue Jun 28, 2023 · 5 comments
Labels
01 bug Confirmed bug 11 breaking PR introduces a breaking change

Comments

@rasharab
Copy link

rasharab commented Jun 28, 2023

System Info

Massive client changes as of this pr:
anthropics/anthropic-sdk-python@8d1d6af

Installing the latest anthropic client will cause langchain Anthropic LLM utiltiies to fail.
Looks like api_url no longer exists (they've moved to base_url).

   ???
E   pydantic.error_wrappers.ValidationError: 1 validation error for ChatAnthropic
E   __root__
E     __init__() got an unexpected keyword argument 'api_url' (type=type_error)

Who can help?

@hwchase17

Information

  • The official example notebooks/scripts
  • My own modified scripts

Related Components

  • LLMs/Chat Models
  • Embedding Models
  • Prompts / Prompt Templates / Prompt Selectors
  • Output Parsers
  • Document Loaders
  • Vector Stores / Retrievers
  • Memory
  • Agents / Agent Executors
  • Tools / Toolkits
  • Chains
  • Callbacks/Tracing
  • Async

Reproduction

  1. Install latest version of anthropic.
  2. Attempt to run Anthropic LLM and it will produce a runtime failure about api_url which no longer exists in the Anthropic client initializer.

Expected behavior

Should work with latest release of Anthropic client.

@dosubot dosubot bot added 11 breaking PR introduces a breaking change 01 bug Confirmed bug labels Jun 28, 2023
@dosubot
Copy link

dosubot bot commented Jun 28, 2023

Answer generated by a 🤖

Answer

The error message indicates that the api_url argument is no longer accepted by the anthropic.Client initializer. This is due to the recent changes in the Anthropic client where api_url has been replaced with base_url.

To fix this issue, you need to replace api_url with base_url in the Anthropic class in your LangChain code. Here's how you can do it:

Replace this code:

values["client"] = anthropic.Client(
                api_url=anthropic_api_url,
                api_key=anthropic_api_key,
                default_request_timeout=values["default_request_timeout"],
            )

With this:

values["client"] = anthropic.Client(
                base_url=anthropic_api_url,
                api_key=anthropic_api_key,
                default_request_timeout=values["default_request_timeout"],
            )

This change should resolve the issue and make LangChain compatible with the latest version of the Anthropic client.

Sources


This response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

@jmkuebler
Copy link

For those just needing a quick work-around. pip install anthropic==0.2.10 get's you back to the latest version before this change.

@adityamookerjee
Copy link

@jmkuebler Do you happen to know if this was addressed in another issue/commit to the langchain library?

@jmkuebler
Copy link

@jmkuebler Do you happen to know if this was addressed in another issue/commit to the langchain library?

@adityamookerjee No I am not aware of another issue that could be linked.

@dosubot
Copy link

dosubot bot commented Oct 10, 2023

Hi, @rasharab! I'm Dosu, and I'm helping the LangChain team manage our backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, the latest version of the Anthropic client is incompatible with the langchain Anthropic LLM utilities due to a change in the client's API. The api_url parameter has been removed and replaced with base_url. I provided a solution in the comments, suggesting to replace api_url with base_url in the Anthropic class in the LangChain code. Another user, jmkuebler, suggested a quick workaround by installing the previous version of the Anthropic client (0.2.10). There is a question from adityamookerjee asking if this issue was addressed in another issue/commit to the langchain library, to which jmkuebler replied that they are not aware of any other related issue.

Now, we would like to know if this issue is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days.

Thank you for your understanding and cooperation. Let us know if you have any further questions or concerns!

Best regards,
Dosu

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Oct 10, 2023
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2023
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
01 bug Confirmed bug 11 breaking PR introduces a breaking change
Projects
None yet
Development

No branches or pull requests

3 participants