forked from Archives/langchain
[searx-search] helper method to get cached results
This commit is contained in:
parent
734755e019
commit
c73a145ba2
@ -169,7 +169,7 @@ class SearxSearchWrapper(BaseModel):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_result: SearxResults = PrivateAttr()
|
_results: SearxResults = PrivateAttr()
|
||||||
searx_host: str = ""
|
searx_host: str = ""
|
||||||
unsecure: bool = False
|
unsecure: bool = False
|
||||||
params: dict = Field(default_factory=_get_default_params)
|
params: dict = Field(default_factory=_get_default_params)
|
||||||
@ -233,7 +233,7 @@ class SearxSearchWrapper(BaseModel):
|
|||||||
if not raw_result.ok:
|
if not raw_result.ok:
|
||||||
raise ValueError("Searx API returned an error: ", raw_result.text)
|
raise ValueError("Searx API returned an error: ", raw_result.text)
|
||||||
res = SearxResults(raw_result.text)
|
res = SearxResults(raw_result.text)
|
||||||
self._result = res
|
self._results = res
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def run(self, query: str, engines: List[str] = [], **kwargs: Any) -> str:
|
def run(self, query: str, engines: List[str] = [], **kwargs: Any) -> str:
|
||||||
@ -319,3 +319,8 @@ class SearxSearchWrapper(BaseModel):
|
|||||||
metadata_results.append(metadata_result)
|
metadata_results.append(metadata_result)
|
||||||
|
|
||||||
return metadata_results
|
return metadata_results
|
||||||
|
|
||||||
|
@property
|
||||||
|
def raw_results(self) -> SearxResults:
|
||||||
|
"""Cached searx results from the last query in a dict like object."""
|
||||||
|
return self._results
|
||||||
|
Loading…
Reference in New Issue
Block a user