langchain
langchain copied to clipboard
fix: provider the latest duckduckgo_search API
Provider the latest duckduckgo_search API
The Git commit contents involve two files related to some DuckDuckGo query operations, and an upgrade of the DuckDuckGo module to version 3.2.0. A suitable commit message could be "Upgrade DuckDuckGo module to version 3.2.0, including query operations". Specifically, in the duckduckgo_search.py file, a DDGS() class instance is newly added to replace the previous ddg() function, and the time parameter name in the get_snippets() and results() methods is changed from "time" to "timelimit" to accommodate recent changes. In the pyproject.toml file, the duckduckgo-search module is upgraded to version 3.2.0.
Who can review?
@vowelparrot
duckduckgo_search readme attention: Versions before v2.9.4 no longer work as of May 12, 2023
@vowelparrot I wonder why duckduckgo_search
has release v3.2.0
but checks failed and said Because langchain depends on duckduckgo-search (^3.2.0) which doesn't match any versions, version solving failed.
The poetry.lock
file needs to be updated as well! (running poetry lock
will update)
@vowelparrot I got the following problem. Do you have ideas to solve the problem?
And because weaviate-client (3.19.0) depends on requests (>=2.28.0,<2.29.0)
and weaviate-client (3.19.1) depends on requests (>=2.28.0,<2.29.0), weaviate-client (>=3.15.5,<4) requires requests (>=2.28.0,<2.29.0).
And because duckduckgo-search (3.2.0) depends on requests (>=2.31.0)
and no versions of duckduckgo-search match >3.2.0,<4.0.0, weaviate-client (>=3.15.5,<4) is incompatible with duckduckgo-search (>=3.2.0,<4.0.0).
So, because langchain depends on both weaviate-client (>=3.15.5,<4) and duckduckgo-search (^3.2.0), version solving failed.
I'll try to get back to this later - opened a PR on the weaviate client to bump the upper bound. the Dep resolution issue seems fairly common : https://github.com/python-poetry/poetry/issues/697
Oh I see. It's a very common problem.
We can harness the self.max_results
to limit the search results, for example:
for i, res in enumerate(results, 1):
snippets.append(res['body'])
if i == self.max_results:
break
return snippets
Generator
is much simple:
...
for i, res in enumerate(results, 1):
yield res['body']
if i == self.max_results:
return
...
In the latest version of duckduckgo_search, it is recommand to use context manager with DDGS
:
with DDGS() as ddgs:
ddgs.text(...)
ok I fix it later. Previously, due to dependency version conflicts, I was unable to pass the test.
@Undertone0809 is attempting to deploy a commit to the LangChain Team on Vercel.
A member of the Team first needs to authorize it.
Oh, I don't know why make so many commit. Perhaps I should create a new PR #6409