mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-30 17:29:56 +00:00
community: add args_schema to SearxSearch (#22954)
This change adds args_schema (pydantic BaseModel) to SearxSearchRun for correct schema formatting on LLM function calls Issue: currently using SearxSearchRun with OpenAI function calling returns the following error "TypeError: SearxSearchRun._run() got an unexpected keyword argument '__arg1' ". This happens because the schema sent to the LLM is "input: '{"__arg1":"foobar"}'" while the method should be called with the "query" parameter. --------- Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
This commit is contained in:
parent
01783d67fc
commit
226802f0c4
@ -1,16 +1,22 @@
|
||||
"""Tool for the SearxNG search API."""
|
||||
from typing import Optional
|
||||
from typing import Optional, Type
|
||||
|
||||
from langchain_core.callbacks import (
|
||||
AsyncCallbackManagerForToolRun,
|
||||
CallbackManagerForToolRun,
|
||||
)
|
||||
from langchain_core.pydantic_v1 import Extra, Field
|
||||
from langchain_core.pydantic_v1 import BaseModel, Extra, Field
|
||||
from langchain_core.tools import BaseTool
|
||||
|
||||
from langchain_community.utilities.searx_search import SearxSearchWrapper
|
||||
|
||||
|
||||
class SearxSearchQueryInput(BaseModel):
|
||||
"""Input for the SearxSearch tool."""
|
||||
|
||||
query: str = Field(description="query to look up on searx")
|
||||
|
||||
|
||||
class SearxSearchRun(BaseTool):
|
||||
"""Tool that queries a Searx instance."""
|
||||
|
||||
@ -22,6 +28,7 @@ class SearxSearchRun(BaseTool):
|
||||
)
|
||||
wrapper: SearxSearchWrapper
|
||||
kwargs: dict = Field(default_factory=dict)
|
||||
args_schema: Type[BaseModel] = SearxSearchQueryInput
|
||||
|
||||
def _run(
|
||||
self,
|
||||
|
Loading…
Reference in New Issue
Block a user