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

get_openapi_chain throws error when running example from docs #10733

Closed
2 of 14 tasks
rubensmau opened this issue Sep 18, 2023 · 18 comments
Closed
2 of 14 tasks

get_openapi_chain throws error when running example from docs #10733

rubensmau opened this issue Sep 18, 2023 · 18 comments
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@rubensmau
Copy link
Contributor

System Info

pydantic '1.10.0' or '2.3.0'
langchain '0.0.292'
python '3.11.5'

Who can help?

@hwchase17
@agola11

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

from langchain.chains.openai_functions.openapi import get_openapi_chain
chain = get_openapi_chain("https://www.klarna.com/us/shopping/public/openai/v0/api-docs/")
chain("What are some options for a men's large blue button down shirt")

Error message when running with pydantic 1
Unable to parse spec from source https://chat-web3-plugin.alchemy.com/openapi.yaml error

Error message when running with pydantic 2
AttributeError: type object 'OpenAPISpec' has no attribute 'from_url'

Expected behavior

normal execution without errors

@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Sep 18, 2023
@dosubot
Copy link

dosubot bot commented Sep 18, 2023

🤖

Hello,

Thank you for bringing this issue to our attention. It seems like you're encountering an error when trying to use the get_openapi_chain function from the LangChain library.

From the error messages you provided, it appears that the issue might be related to the OpenAPI specification parsing. The error message "Unable to parse spec from source" suggests that there might be an issue with the OpenAPI specification at the provided URL. This could be due to the specification not being valid, not being accessible, or not being compatible with the version of the OpenAPI parser used by LangChain.

The second error message "AttributeError: type object 'OpenAPISpec' has no attribute 'from_url'" suggests that the from_url method is not found in the OpenAPISpec class. This could be due to a version mismatch between LangChain and the version of the OpenAPI parser it relies on.

To help us better understand and resolve the issue, could you please provide the following additional information:

  1. The exact version of the OpenAPI parser you're using.
  2. The OpenAPI specification at the provided URL, if it's publicly accessible.
  3. The exact code you're using to call the get_openapi_chain function.

In the meantime, you might want to try using a different version of the OpenAPI parser, or check if the OpenAPI specification at the provided URL is valid and accessible.

Thank you for your patience and cooperation. We're looking forward to resolving this issue for you.

Best,
Dosu

Sources


This response is meant to be useful and save you time. 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.

If you want to continue the conversation, start your reply with @dosu-bot.

@kirankc
Copy link

kirankc commented Oct 2, 2023

Any fix for this? I used examples from the latest OpenAPI version - 3.1.0 and the issue still persists with the error "Unable to parse spec from source".

OpenAPI version - 3.1.0 Examples
https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v3.1/webhook-example.yaml

@kirankc
Copy link

kirankc commented Oct 3, 2023

If anyone runs into the same issue, I was able to resolve it by installing "openapi-schema-pydantic"

@kai-majerus
Copy link

I'm getting this error using the same basic example https://python.langchain.com/docs/use_cases/apis. I tried installing openapi-schema-pydantic and unfortunately that didn't fix it for me

@landxman
Copy link

pip uninstall pydantic
pip install pydantic==1.10.9

@mzheng-sb
Copy link

same issue here...

@wingleungchoi
Copy link

wingleungchoi commented Oct 18, 2023

fixed the issue by adding openapi-schema-pydantic and downgrading pydantic to 1.10.9

poetry add openapi-schema-pydantic
poetry add pydantic==1.10.9

My environment

python = "^3.10"
langchain = "^0.0.316"
openai = "^0.28.1"
...
pydantic = "1.10.9"
openapi-schema-pydantic = "^1.2.4"

thank @landxman and @kirankc

@hpnrep6
Copy link

hpnrep6 commented Oct 24, 2023

#9408 made the OpenAPI Spec dependency optional and #11936 carried over the optionality when openapi_schema_pydantic was switched to openapi_pydantic.

Although after installing openapi_pydantic, I'm not getting any output other than the warning for some reason.

Attempting to load an OpenAPI 3.0.1 spec.  This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support.

Related: #9520

@cesdaile-te
Copy link

Still have the same issue with clean install on Colab following the example in langchain docs. workaround above did not resolve the Unable to parse spec from source error

@benm4nn
Copy link

benm4nn commented Nov 5, 2023

same issue here... :-(

@3cha1n
Copy link

3cha1n commented Nov 16, 2023

Solution for me on Colab at least (but maybe relevant to anyone with this issue) is that after noticing that pip install openapi_schema_pydantic simply didn't work (pip can't find the package, no doubt because there's no PyPi package for the Colab OS) I installed the package from github and that worked fine:

pip install git+https://github.com/kuimono/openapi-schema-pydantic.git@master

My specs:

Python 3.10.12
pydantic: 1.10.12
openapi-schema-pydantic: 1.2.4
langchain: 0.0.316
openai: 0.28.1

@cesdaile-te @benm4nn

@amirhoseinsh
Copy link

@3cha1n It did not work for me even after I installed openapi-schema-pydantic.

@3cha1n
Copy link

3cha1n commented Nov 20, 2023

@nofrish
Copy link

nofrish commented Dec 1, 2023

@3cha1n It did not work for me even after I installed openapi-schema-pydantic.

Have you solved this problem yet?

@Manouchehri
Copy link

Still having this issue. This is my requirements.txt:

langchain
openapi-schema-pydantic==1.2.4
pydantic==1.10.9

@3cha1n
Copy link

3cha1n commented Dec 7, 2023

@Manouchehri

  • What's your Python version and what are your other package versions? Mine are mentioned above 👆🏼

  • Did you check openapi-schema-pydantic was installed successfully? I had to install openapi-schema-pydantic manually as follows:

pip install git+https://github.com/kuimono/openapi-schema-pydantic.git@master

@fquellec
Copy link

None of the above solutions worked for me. It seems that for the latest versions of langchain, you need to install openapi-pydantic :

pip install openapi-pydantic

@YoHoSo
Copy link

YoHoSo commented Dec 26, 2023

None of the above solutions worked for me. It seems that for the latest versions of langchain, you need to install openapi-pydantic :

pip install openapi-pydantic

@fquellec's solution works for me. python version is 3.10.13

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Mar 26, 2024
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 2, 2024
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Apr 2, 2024
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
Projects
None yet
Development

No branches or pull requests