langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
93.99k stars 15.15k forks source link

GoogleScholarAPIWrapper issue when initializing, pydantic_core._pydantic_core.ValidationError #27557

Open speralta-burwood opened 3 days ago

speralta-burwood commented 3 days ago

Checked other resources

Example Code

import os from langchain_community.tools.google_scholar import GoogleScholarQueryRun from langchain_community.utilities.google_scholar import GoogleScholarAPIWrapper

os.environ["SERP_API_KEY"] = "my-key"

new_scholar = GoogleScholarAPIWrapper()

tool = GoogleScholarQueryRun(api_wrapper=new_scholar) result = tool.run("LLM Models") print(result)

Error Message and Stack Trace (if applicable)

Traceback (most recent call last): File "googlescholar.py", line 9, in new_scholar = GoogleScholarAPIWrapper() File ".venv/lib/python3.13/site-packages/pydantic/main.py", line 212, in init validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self) pydantic_core._pydantic_core.ValidationError: 2 validation errors for GoogleScholarAPIWrapper SERP_API_KEY Extra inputs are not permitted [type=extra_forbidden, input_value='2d2dd691e41cc3135c34c8ea...e40d9edf183c92213960ef2', input_type=str] For further information visit https://errors.pydantic.dev/2.9/v/extra_forbidden google_scholar_engine Extra inputs are not permitted [type=extra_forbidden, input_value=<class 'serpapi.google_sc...ch.GoogleScholarSearch'>, input_type=type] For further information visit https://errors.pydantic.dev/2.9/v/extra_forbidden

Description

I am trying to use the Google Scholar API Wrapper for testing.

I am following these links: https://python.langchain.com/docs/integrations/tools/google_scholar/

https://api.python.langchain.com/en/latest/utilities/langchain_community.utilities.google_scholar.GoogleScholarAPIWrapper.html

I am stuck initializing it as it says "extra inputs are not permitted". I don't want to use my own class as I will be using this in a jupter notebook for testing and learning.

System Info

aiohappyeyeballs==2.4.3 aiohttp==3.10.10 aiosignal==1.3.1 annotated-types==0.7.0 anyio==4.6.2.post1 attrs==24.2.0 cachetools==5.5.0 certifi==2024.8.30 charset-normalizer==3.4.0 dataclasses-json==0.6.7 docstring_parser==0.16 frozenlist==1.4.1 google-api-core==2.21.0 google-auth==2.35.0 google-cloud-aiplatform==1.70.0 google-cloud-bigquery==3.26.0 google-cloud-core==2.4.1 google-cloud-resource-manager==1.12.5 google-cloud-storage==2.18.2 google-crc32c==1.6.0 google-resumable-media==2.7.2 google_search_results==2.4.2 googleapis-common-protos==1.65.0 grpc-google-iam-v1==0.13.1 grpcio==1.67.0 grpcio-status==1.67.0 h11==0.14.0 httpcore==1.0.6 httpx==0.27.2 httpx-sse==0.4.0 idna==3.10 jsonpatch==1.33 jsonpointer==3.0.0 langchain==0.3.4 langchain-community==0.3.3 langchain-core==0.3.12 langchain-google-vertexai==2.0.5 langchain-text-splitters==0.3.0 langsmith==0.1.136 marshmallow==3.23.0 multidict==6.1.0 mypy-extensions==1.0.0 numpy==1.26.4 orjson==3.10.10 packaging==24.1 propcache==0.2.0 proto-plus==1.24.0 protobuf==5.28.2 pyasn1==0.6.1 pyasn1_modules==0.4.1 pydantic==2.9.2 pydantic-settings==2.6.0 pydantic_core==2.23.4 python-dateutil==2.9.0.post0 python-dotenv==1.0.1 PyYAML==6.0.2 requests==2.32.3 requests-toolbelt==1.0.0 rsa==4.9 shapely==2.0.6 six==1.16.0 sniffio==1.3.1 SQLAlchemy==2.0.36 tenacity==9.0.0 typing-inspect==0.9.0 typing_extensions==4.12.2 urllib3==2.2.3 yarl==1.16.0

JackyJi-hub commented 3 days ago

Hello, I've tested your code and confirmed that this is a problem. I'm a member of a team at University of Toronto and we're going to take a look at this issue and hopefully have a working pull request soon.