langchain-ai / langchain

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

DuckDuckGoSearchRun time limit adversely affects search results #25422

Open lawrenceztang opened 2 months ago

lawrenceztang commented 2 months ago

Checked other resources

Example Code

from langchain_community.tools import DuckDuckGoSearchRun
from langchain_community.utilities import DuckDuckGoSearchAPIWrapper

ddg = DuckDuckGoSearchRun(api_wrapper=DuckDuckGoSearchAPIWrapper())
run = ddg.run("What was Steph Curry's PPG in 2006-2007?")
print(run)

Error Message and Stack Trace (if applicable)

No response

Description

DuckDuckGoSearchRun runs poorly when it runs with ddgs.text(timelimit='y'). See demo code for example.

We implement a quick fix by going to DuckDuckGoSearchAPIWrapper and changing time: Optional[str] = "y" to time: Optional[str] = "n". The time variable should be y by default. Furthermore, the time variable should be able to be passed in DuckDuckGoSearchRun, which currently isn't possible.

System Info


System Information
------------------
> OS:  Darwin
> OS Version:  Darwin Kernel Version 22.5.0: Mon Apr 24 20:40:17 PDT 2023; root:xnu-8796.121.2~3/RELEASE_ARM64_T8112
> Python Version:  3.11.8 | packaged by conda-forge | (main, Feb 16 2024, 20:49:36) [Clang 16.0.6 ]

Package Information
-------------------
> langchain_core: 0.2.29
> langchain: 0.2.11
> langchain_community: 0.2.10
> langsmith: 0.1.93
> langchain_google_community: 1.0.7
> langchain_openai: 0.1.21
> langchain_text_splitters: 0.2.2
> langchainhub: 0.1.20
> langgraph: 0.2.3

Optional packages not installed
-------------------------------
> langserve

Other Dependencies
------------------
> aiohttp: 3.9.5
> async-timeout: Installed. No version info available.
> beautifulsoup4: 4.12.3
> dataclasses-json: 0.6.7
> db-dtypes: Installed. No version info available.
> gapic-google-longrunning: Installed. No version info available.
> google-api-core: 2.19.1
> google-api-python-client: 2.140.0
> google-auth-httplib2: 0.2.0
> google-auth-oauthlib: 1.2.1
> google-cloud-aiplatform: Installed. No version info available.
> google-cloud-bigquery: Installed. No version info available.
> google-cloud-bigquery-storage: Installed. No version info available.
> google-cloud-contentwarehouse: Installed. No version info available.
> google-cloud-discoveryengine: Installed. No version info available.
> google-cloud-documentai: Installed. No version info available.
> google-cloud-documentai-toolbox: Installed. No version info available.
> google-cloud-speech: Installed. No version info available.
> google-cloud-storage: Installed. No version info available.
> google-cloud-texttospeech: Installed. No version info available.
> google-cloud-translate: Installed. No version info available.
> google-cloud-vision: Installed. No version info available.
> googlemaps: Installed. No version info available.
> grpcio: 1.65.4
> jsonpatch: 1.33
> langgraph-checkpoint: 1.0.2
> numpy: 1.26.4
> openai: 1.40.3
> orjson: 3.9.15
> packaging: 24.1
> pandas: 2.2.2
> pyarrow: 17.0.0
> pydantic: 2.5.3
> PyYAML: 6.0.1
> requests: 2.32.3
> SQLAlchemy: 2.0.31
> tenacity: 8.5.0
> tiktoken: 0.7.0
> types-requests: 2.32.0.20240712
> typing-extensions: 4.11.0
suryanshgupta9933 commented 2 months ago

Can you assign this to me? I am new to open source and want to contribute in langchain.

keenborder786 commented 2 months ago

@lawrenceztang No need of updating the code base to pass in the time parameter directly to the tool since that is a configuration which need to be passed to DuckDuckGoSearchAPIWrapper