diff --git a/libs/langchain/langchain/agents/agent_toolkits/openapi/planner.py b/libs/langchain/langchain/agents/agent_toolkits/openapi/planner.py index d46d14b593..6e2ab4483d 100644 --- a/libs/langchain/langchain/agents/agent_toolkits/openapi/planner.py +++ b/libs/langchain/langchain/agents/agent_toolkits/openapi/planner.py @@ -66,7 +66,7 @@ def _get_default_llm_chain_factory( class RequestsGetToolWithParsing(BaseRequestsTool, BaseTool): """Requests GET tool with LLM-instructed extraction of truncated responses.""" - name = "requests_get" + name: str = "requests_get" """Tool name.""" description = REQUESTS_GET_TOOL_DESCRIPTION """Tool description.""" @@ -96,7 +96,7 @@ class RequestsGetToolWithParsing(BaseRequestsTool, BaseTool): class RequestsPostToolWithParsing(BaseRequestsTool, BaseTool): """Requests POST tool with LLM-instructed extraction of truncated responses.""" - name = "requests_post" + name: str = "requests_post" """Tool name.""" description = REQUESTS_POST_TOOL_DESCRIPTION """Tool description.""" @@ -125,7 +125,7 @@ class RequestsPostToolWithParsing(BaseRequestsTool, BaseTool): class RequestsPatchToolWithParsing(BaseRequestsTool, BaseTool): """Requests PATCH tool with LLM-instructed extraction of truncated responses.""" - name = "requests_patch" + name: str = "requests_patch" """Tool name.""" description = REQUESTS_PATCH_TOOL_DESCRIPTION """Tool description.""" @@ -154,7 +154,7 @@ class RequestsPatchToolWithParsing(BaseRequestsTool, BaseTool): class RequestsDeleteToolWithParsing(BaseRequestsTool, BaseTool): """A tool that sends a DELETE request and parses the response.""" - name = "requests_delete" + name: str = "requests_delete" """The name of the tool.""" description = REQUESTS_DELETE_TOOL_DESCRIPTION """The description of the tool.""" diff --git a/libs/langchain/langchain/agents/openai_functions_agent/agent_token_buffer_memory.py b/libs/langchain/langchain/agents/openai_functions_agent/agent_token_buffer_memory.py index d4e0fc9dc6..aa24454804 100644 --- a/libs/langchain/langchain/agents/openai_functions_agent/agent_token_buffer_memory.py +++ b/libs/langchain/langchain/agents/openai_functions_agent/agent_token_buffer_memory.py @@ -18,8 +18,8 @@ class AgentTokenBufferMemory(BaseChatMemory): """The max number of tokens to keep in the buffer. Once the buffer exceeds this many tokens, the oldest messages will be pruned.""" return_messages: bool = True - output_key = "output" - intermediate_steps_key = "intermediate_steps" + output_key: str = "output" + intermediate_steps_key: str = "intermediate_steps" @property def buffer(self) -> List[BaseMessage]: diff --git a/libs/langchain/langchain/agents/tools.py b/libs/langchain/langchain/agents/tools.py index e13acc42bd..91e80bc4ee 100644 --- a/libs/langchain/langchain/agents/tools.py +++ b/libs/langchain/langchain/agents/tools.py @@ -11,8 +11,8 @@ from langchain.tools.base import BaseTool, Tool, tool class InvalidTool(BaseTool): """Tool that is run when invalid tool name is encountered by agent.""" - name = "invalid_tool" - description = "Called when tool name is invalid. Suggests valid tool names." + name: str = "invalid_tool" + description: str = "Called when tool name is invalid. Suggests valid tool names." def _run( self, diff --git a/libs/langchain/langchain/callbacks/argilla_callback.py b/libs/langchain/langchain/callbacks/argilla_callback.py index 9420fb46d0..84a1596386 100644 --- a/libs/langchain/langchain/callbacks/argilla_callback.py +++ b/libs/langchain/langchain/callbacks/argilla_callback.py @@ -52,11 +52,11 @@ class ArgillaCallbackHandler(BaseCallbackHandler): "Argilla, no doubt about it." """ - REPO_URL = "https://github.com/argilla-io/argilla" - ISSUES_URL = f"{REPO_URL}/issues" - BLOG_URL = "https://docs.argilla.io/en/latest/guides/llms/practical_guides/use_argilla_callback_in_langchain.html" # noqa: E501 + REPO_URL: str = "https://github.com/argilla-io/argilla" + ISSUES_URL: str = f"{REPO_URL}/issues" + BLOG_URL: str = "https://docs.argilla.io/en/latest/guides/llms/practical_guides/use_argilla_callback_in_langchain.html" # noqa: E501 - DEFAULT_API_URL = "http://localhost:6900" + DEFAULT_API_URL: str = "http://localhost:6900" def __init__( self, diff --git a/libs/langchain/langchain/callbacks/labelstudio_callback.py b/libs/langchain/langchain/callbacks/labelstudio_callback.py index c3ba2f84e8..50e468aa57 100644 --- a/libs/langchain/langchain/callbacks/labelstudio_callback.py +++ b/libs/langchain/langchain/callbacks/labelstudio_callback.py @@ -97,7 +97,7 @@ class LabelStudioCallbackHandler(BaseCallbackHandler): >>> llm.predict('Tell me a story about a dog.') """ - DEFAULT_PROJECT_NAME = "LangChain-%Y-%m-%d" + DEFAULT_PROJECT_NAME: str = "LangChain-%Y-%m-%d" def __init__( self, diff --git a/libs/langchain/langchain/callbacks/tracers/evaluation.py b/libs/langchain/langchain/callbacks/tracers/evaluation.py index cd8252b49f..877836b0a5 100644 --- a/libs/langchain/langchain/callbacks/tracers/evaluation.py +++ b/libs/langchain/langchain/callbacks/tracers/evaluation.py @@ -62,7 +62,7 @@ class EvaluatorCallbackHandler(BaseTracer): The LangSmith project name to be organize eval chain runs under. """ - name = "evaluator_callback_handler" + name: str = "evaluator_callback_handler" def __init__( self, diff --git a/libs/langchain/langchain/callbacks/tracers/run_collector.py b/libs/langchain/langchain/callbacks/tracers/run_collector.py index 26e0174fe8..dc0d6eab1e 100644 --- a/libs/langchain/langchain/callbacks/tracers/run_collector.py +++ b/libs/langchain/langchain/callbacks/tracers/run_collector.py @@ -19,7 +19,7 @@ class RunCollectorCallbackHandler(BaseTracer): The ID of the example being traced. It can be either a UUID or a string. """ - name = "run-collector_callback_handler" + name: str = "run-collector_callback_handler" def __init__( self, example_id: Optional[Union[UUID, str]] = None, **kwargs: Any diff --git a/libs/langchain/langchain/callbacks/tracers/stdout.py b/libs/langchain/langchain/callbacks/tracers/stdout.py index 71e38c0e50..cd05f1898d 100644 --- a/libs/langchain/langchain/callbacks/tracers/stdout.py +++ b/libs/langchain/langchain/callbacks/tracers/stdout.py @@ -44,7 +44,7 @@ def elapsed(run: Any) -> str: class FunctionCallbackHandler(BaseTracer): """Tracer that calls a function with a single str parameter.""" - name = "function_callback_handler" + name: str = "function_callback_handler" def __init__(self, function: Callable[[str], None], **kwargs: Any) -> None: super().__init__(**kwargs) @@ -172,7 +172,7 @@ class FunctionCallbackHandler(BaseTracer): class ConsoleCallbackHandler(FunctionCallbackHandler): """Tracer that prints to the console.""" - name = "console_callback_handler" + name: str = "console_callback_handler" def __init__(self, **kwargs: Any) -> None: super().__init__(function=print, **kwargs) diff --git a/libs/langchain/langchain/chains/graph_qa/arangodb.py b/libs/langchain/langchain/chains/graph_qa/arangodb.py index d688114480..e9e6767a4c 100644 --- a/libs/langchain/langchain/chains/graph_qa/arangodb.py +++ b/libs/langchain/langchain/chains/graph_qa/arangodb.py @@ -29,10 +29,10 @@ class ArangoGraphQAChain(Chain): output_key: str = "result" #: :meta private: # Specifies the maximum number of AQL Query Results to return - top_k = 10 + top_k: int = 10 # Specifies the set of AQL Query Examples that promote few-shot-learning - aql_examples = "" + aql_examples: str = "" # Specify whether to return the AQL Query in the output dictionary return_aql_query: bool = False @@ -41,7 +41,7 @@ class ArangoGraphQAChain(Chain): return_aql_result: bool = False # Specify the maximum amount of AQL Generation attempts that should be made - max_aql_generation_attempts = 3 + max_aql_generation_attempts: int = 3 @property def input_keys(self) -> List[str]: diff --git a/libs/langchain/langchain/chat_models/azureml_endpoint.py b/libs/langchain/langchain/chat_models/azureml_endpoint.py index c0a1eeffea..9cd57fbcf8 100644 --- a/libs/langchain/langchain/chat_models/azureml_endpoint.py +++ b/libs/langchain/langchain/chat_models/azureml_endpoint.py @@ -18,7 +18,7 @@ from langchain.utils import get_from_dict_or_env class LlamaContentFormatter(ContentFormatterBase): """Content formatter for `LLaMA`.""" - SUPPORTED_ROLES = ["user", "assistant", "system"] + SUPPORTED_ROLES: List[str] = ["user", "assistant", "system"] @staticmethod def _convert_message_to_dict(message: BaseMessage) -> Dict: diff --git a/libs/langchain/langchain/llms/edenai.py b/libs/langchain/langchain/llms/edenai.py index 22926dd89b..e63c0776e5 100644 --- a/libs/langchain/langchain/llms/edenai.py +++ b/libs/langchain/langchain/llms/edenai.py @@ -30,7 +30,7 @@ class EdenAI(LLM): for api reference check edenai documentation: http://docs.edenai.co. """ - base_url = "https://api.edenai.run/v2" + base_url: str = "https://api.edenai.run/v2" edenai_api_key: Optional[str] = None diff --git a/libs/langchain/langchain/llms/ollama.py b/libs/langchain/langchain/llms/ollama.py index 66f9e7ab01..ec132c08b8 100644 --- a/libs/langchain/langchain/llms/ollama.py +++ b/libs/langchain/langchain/llms/ollama.py @@ -23,7 +23,7 @@ def _stream_response_to_generation_chunk( class _OllamaCommon(BaseLanguageModel): - base_url = "http://localhost:11434" + base_url: str = "http://localhost:11434" """Base url the model is hosted under.""" model: str = "llama2" diff --git a/libs/langchain/langchain/text_splitter.py b/libs/langchain/langchain/text_splitter.py index 638f0c830d..e804b93be9 100644 --- a/libs/langchain/langchain/text_splitter.py +++ b/libs/langchain/langchain/text_splitter.py @@ -592,7 +592,7 @@ class SentenceTransformersTokenTextSplitter(TextSplitter): def count_tokens(self, *, text: str) -> int: return len(self._encode(text)) - _max_length_equal_32_bit_integer = 2**32 + _max_length_equal_32_bit_integer: int = 2**32 def _encode(self, text: str) -> List[int]: token_ids_with_start_and_end_token_ids = self.tokenizer.encode( diff --git a/libs/langchain/langchain/tools/arxiv/tool.py b/libs/langchain/langchain/tools/arxiv/tool.py index f7fb0fdb26..c9b2f5caa9 100644 --- a/libs/langchain/langchain/tools/arxiv/tool.py +++ b/libs/langchain/langchain/tools/arxiv/tool.py @@ -11,8 +11,8 @@ from langchain.utilities.arxiv import ArxivAPIWrapper class ArxivQueryRun(BaseTool): """Tool that searches the Arxiv API.""" - name = "arxiv" - description = ( + name: str = "arxiv" + description: str = ( "A wrapper around Arxiv.org " "Useful for when you need to answer questions about Physics, Mathematics, " "Computer Science, Quantitative Biology, Quantitative Finance, Statistics, " diff --git a/libs/langchain/langchain/tools/azure_cognitive_services/form_recognizer.py b/libs/langchain/langchain/tools/azure_cognitive_services/form_recognizer.py index 74a0a33253..b5dce896e3 100644 --- a/libs/langchain/langchain/tools/azure_cognitive_services/form_recognizer.py +++ b/libs/langchain/langchain/tools/azure_cognitive_services/form_recognizer.py @@ -23,8 +23,8 @@ class AzureCogsFormRecognizerTool(BaseTool): azure_cogs_endpoint: str = "" #: :meta private: doc_analysis_client: Any #: :meta private: - name = "azure_cognitive_services_form_recognizer" - description = ( + name: str = "azure_cognitive_services_form_recognizer" + description: str = ( "A wrapper around Azure Cognitive Services Form Recognizer. " "Useful for when you need to " "extract text, tables, and key-value pairs from documents. " diff --git a/libs/langchain/langchain/tools/azure_cognitive_services/image_analysis.py b/libs/langchain/langchain/tools/azure_cognitive_services/image_analysis.py index 1dd2b0192e..b2032fcb99 100644 --- a/libs/langchain/langchain/tools/azure_cognitive_services/image_analysis.py +++ b/libs/langchain/langchain/tools/azure_cognitive_services/image_analysis.py @@ -24,8 +24,8 @@ class AzureCogsImageAnalysisTool(BaseTool): vision_service: Any #: :meta private: analysis_options: Any #: :meta private: - name = "azure_cognitive_services_image_analysis" - description = ( + name: str = "azure_cognitive_services_image_analysis" + description: str = ( "A wrapper around Azure Cognitive Services Image Analysis. " "Useful for when you need to analyze images. " "Input should be a url to an image." diff --git a/libs/langchain/langchain/tools/azure_cognitive_services/speech2text.py b/libs/langchain/langchain/tools/azure_cognitive_services/speech2text.py index 57283b979b..0f7f82937e 100644 --- a/libs/langchain/langchain/tools/azure_cognitive_services/speech2text.py +++ b/libs/langchain/langchain/tools/azure_cognitive_services/speech2text.py @@ -28,8 +28,8 @@ class AzureCogsSpeech2TextTool(BaseTool): speech_language: str = "en-US" #: :meta private: speech_config: Any #: :meta private: - name = "azure_cognitive_services_speech2text" - description = ( + name: str = "azure_cognitive_services_speech2text" + description: str = ( "A wrapper around Azure Cognitive Services Speech2Text. " "Useful for when you need to transcribe audio to text. " "Input should be a url to an audio file." diff --git a/libs/langchain/langchain/tools/azure_cognitive_services/text2speech.py b/libs/langchain/langchain/tools/azure_cognitive_services/text2speech.py index 2049440d20..fee35591f3 100644 --- a/libs/langchain/langchain/tools/azure_cognitive_services/text2speech.py +++ b/libs/langchain/langchain/tools/azure_cognitive_services/text2speech.py @@ -24,8 +24,8 @@ class AzureCogsText2SpeechTool(BaseTool): speech_language: str = "en-US" #: :meta private: speech_config: Any #: :meta private: - name = "azure_cognitive_services_text2speech" - description = ( + name: str = "azure_cognitive_services_text2speech" + description: str = ( "A wrapper around Azure Cognitive Services Text2Speech. " "Useful for when you need to convert text to speech. " ) diff --git a/libs/langchain/langchain/tools/base.py b/libs/langchain/langchain/tools/base.py index 2ba99140c6..7c24c01b3a 100644 --- a/libs/langchain/langchain/tools/base.py +++ b/libs/langchain/langchain/tools/base.py @@ -55,8 +55,8 @@ def _get_filtered_args( class _SchemaConfig: """Configuration for the pydantic model.""" - extra = Extra.forbid - arbitrary_types_allowed = True + extra: Any = Extra.forbid + arbitrary_types_allowed: bool = True def create_schema_from_function( diff --git a/libs/langchain/langchain/tools/bing_search/tool.py b/libs/langchain/langchain/tools/bing_search/tool.py index a8556ae30b..4d73b5a0d9 100644 --- a/libs/langchain/langchain/tools/bing_search/tool.py +++ b/libs/langchain/langchain/tools/bing_search/tool.py @@ -10,8 +10,8 @@ from langchain.utilities.bing_search import BingSearchAPIWrapper class BingSearchRun(BaseTool): """Tool that queries the Bing search API.""" - name = "bing_search" - description = ( + name: str = "bing_search" + description: str = ( "A wrapper around Bing Search. " "Useful for when you need to answer questions about current events. " "Input should be a search query." @@ -30,8 +30,8 @@ class BingSearchRun(BaseTool): class BingSearchResults(BaseTool): """Tool that queries the Bing Search API and gets back json.""" - name = "Bing Search Results JSON" - description = ( + name: str = "Bing Search Results JSON" + description: str = ( "A wrapper around Bing Search. " "Useful for when you need to answer questions about current events. " "Input should be a search query. Output is a JSON array of the query results" diff --git a/libs/langchain/langchain/tools/brave_search/tool.py b/libs/langchain/langchain/tools/brave_search/tool.py index 8a0f887fbf..15ec34f942 100644 --- a/libs/langchain/langchain/tools/brave_search/tool.py +++ b/libs/langchain/langchain/tools/brave_search/tool.py @@ -10,8 +10,8 @@ from langchain.utilities.brave_search import BraveSearchWrapper class BraveSearch(BaseTool): """Tool that queries the BraveSearch.""" - name = "brave_search" - description = ( + name: str = "brave_search" + description: str = ( "a search engine. " "useful for when you need to answer questions about current events." " input should be a search query." diff --git a/libs/langchain/langchain/tools/dataforseo_api_search/tool.py b/libs/langchain/langchain/tools/dataforseo_api_search/tool.py index f029da17ef..6b2cf5a3e9 100644 --- a/libs/langchain/langchain/tools/dataforseo_api_search/tool.py +++ b/libs/langchain/langchain/tools/dataforseo_api_search/tool.py @@ -14,8 +14,8 @@ from langchain.utilities.dataforseo_api_search import DataForSeoAPIWrapper class DataForSeoAPISearchRun(BaseTool): """Tool that queries the DataForSeo Google search API.""" - name = "dataforseo_api_search" - description = ( + name: str = "dataforseo_api_search" + description: str = ( "A robust Google Search API provided by DataForSeo." "This tool is handy when you need information about trending topics " "or current events." @@ -43,8 +43,8 @@ class DataForSeoAPISearchResults(BaseTool): """Tool that queries the DataForSeo Google Search API and get back json.""" - name = "DataForSeo Results JSON" - description = ( + name: str = "DataForSeo Results JSON" + description: str = ( "A comprehensive Google Search API provided by DataForSeo." "This tool is useful for obtaining real-time data on current events " "or popular searches." diff --git a/libs/langchain/langchain/tools/ddg_search/tool.py b/libs/langchain/langchain/tools/ddg_search/tool.py index 7d55b60119..d148bf468c 100644 --- a/libs/langchain/langchain/tools/ddg_search/tool.py +++ b/libs/langchain/langchain/tools/ddg_search/tool.py @@ -12,8 +12,8 @@ from langchain.utilities.duckduckgo_search import DuckDuckGoSearchAPIWrapper class DuckDuckGoSearchRun(BaseTool): """Tool that queries the DuckDuckGo search API.""" - name = "duckduckgo_search" - description = ( + name: str = "duckduckgo_search" + description: str = ( "A wrapper around DuckDuckGo Search. " "Useful for when you need to answer questions about current events. " "Input should be a search query." @@ -34,8 +34,8 @@ class DuckDuckGoSearchRun(BaseTool): class DuckDuckGoSearchResults(BaseTool): """Tool that queries the DuckDuckGo search API and gets back json.""" - name = "DuckDuckGo Results JSON" - description = ( + name: str = "DuckDuckGo Results JSON" + description: str = ( "A wrapper around Duck Duck Go Search. " "Useful for when you need to answer questions about current events. " "Input should be a search query. Output is a JSON array of the query results" diff --git a/libs/langchain/langchain/tools/github/tool.py b/libs/langchain/langchain/tools/github/tool.py index 4de7fa1c66..ec67fd2b33 100644 --- a/libs/langchain/langchain/tools/github/tool.py +++ b/libs/langchain/langchain/tools/github/tool.py @@ -20,8 +20,8 @@ class GitHubAction(BaseTool): api_wrapper: GitHubAPIWrapper = Field(default_factory=GitHubAPIWrapper) mode: str - name = "" - description = "" + name: str = "" + description: str = "" def _run( self, diff --git a/libs/langchain/langchain/tools/golden_query/tool.py b/libs/langchain/langchain/tools/golden_query/tool.py index 9b12c1af12..c84bec9188 100644 --- a/libs/langchain/langchain/tools/golden_query/tool.py +++ b/libs/langchain/langchain/tools/golden_query/tool.py @@ -10,8 +10,8 @@ from langchain.utilities.golden_query import GoldenQueryAPIWrapper class GoldenQueryRun(BaseTool): """Tool that adds the capability to query using the Golden API and get back JSON.""" - name = "Golden Query" - description = ( + name: str = "Golden Query" + description: str = ( "A wrapper around Golden Query API." " Useful for getting entities that match" " a natural language query from Golden's Knowledge Base." diff --git a/libs/langchain/langchain/tools/google_search/tool.py b/libs/langchain/langchain/tools/google_search/tool.py index 038b496e8a..3f9a268e3d 100644 --- a/libs/langchain/langchain/tools/google_search/tool.py +++ b/libs/langchain/langchain/tools/google_search/tool.py @@ -10,8 +10,8 @@ from langchain.utilities.google_search import GoogleSearchAPIWrapper class GoogleSearchRun(BaseTool): """Tool that queries the Google search API.""" - name = "google_search" - description = ( + name: str = "google_search" + description: str = ( "A wrapper around Google Search. " "Useful for when you need to answer questions about current events. " "Input should be a search query." @@ -30,8 +30,8 @@ class GoogleSearchRun(BaseTool): class GoogleSearchResults(BaseTool): """Tool that queries the Google Search API and gets back json.""" - name = "Google Search Results JSON" - description = ( + name: str = "Google Search Results JSON" + description: str = ( "A wrapper around Google Search. " "Useful for when you need to answer questions about current events. " "Input should be a search query. Output is a JSON array of the query results" diff --git a/libs/langchain/langchain/tools/google_serper/tool.py b/libs/langchain/langchain/tools/google_serper/tool.py index 6c6e251bbe..f2489e294f 100644 --- a/libs/langchain/langchain/tools/google_serper/tool.py +++ b/libs/langchain/langchain/tools/google_serper/tool.py @@ -14,8 +14,8 @@ from langchain.utilities.google_serper import GoogleSerperAPIWrapper class GoogleSerperRun(BaseTool): """Tool that queries the Serper.dev Google search API.""" - name = "google_serper" - description = ( + name: str = "google_serper" + description: str = ( "A low-cost Google Search API." "Useful for when you need to answer questions about current events." "Input should be a search query." @@ -43,8 +43,8 @@ class GoogleSerperResults(BaseTool): """Tool that queries the Serper.dev Google Search API and get back json.""" - name = "google_serrper_results_json" - description = ( + name: str = "google_serrper_results_json" + description: str = ( "A low-cost Google Search API." "Useful for when you need to answer questions about current events." "Input should be a search query. Output is a JSON object of the query results" diff --git a/libs/langchain/langchain/tools/graphql/tool.py b/libs/langchain/langchain/tools/graphql/tool.py index b73ed3178f..bad3bcd822 100644 --- a/libs/langchain/langchain/tools/graphql/tool.py +++ b/libs/langchain/langchain/tools/graphql/tool.py @@ -11,8 +11,8 @@ class BaseGraphQLTool(BaseTool): graphql_wrapper: GraphQLAPIWrapper - name = "query_graphql" - description = """\ + name: str = "query_graphql" + description: str = """\ Input to this tool is a detailed and correct GraphQL query, output is a result from the API. If the query is not correct, an error message will be returned. If an error is returned with 'Bad request' in it, rewrite the query and try again. diff --git a/libs/langchain/langchain/tools/human/tool.py b/libs/langchain/langchain/tools/human/tool.py index e8d25340df..30591c004d 100644 --- a/libs/langchain/langchain/tools/human/tool.py +++ b/libs/langchain/langchain/tools/human/tool.py @@ -15,8 +15,8 @@ def _print_func(text: str) -> None: class HumanInputRun(BaseTool): """Tool that asks user for input.""" - name = "human" - description = ( + name: str = "human" + description: str = ( "You can ask a human for guidance when you think you " "got stuck or you are not sure what to do next. " "The input should be a question for the human." diff --git a/libs/langchain/langchain/tools/jira/tool.py b/libs/langchain/langchain/tools/jira/tool.py index 5ff55a340e..533b701b8c 100644 --- a/libs/langchain/langchain/tools/jira/tool.py +++ b/libs/langchain/langchain/tools/jira/tool.py @@ -41,8 +41,8 @@ class JiraAction(BaseTool): api_wrapper: JiraAPIWrapper = Field(default_factory=JiraAPIWrapper) mode: str - name = "" - description = "" + name: str = "" + description: str = "" def _run( self, diff --git a/libs/langchain/langchain/tools/metaphor_search/tool.py b/libs/langchain/langchain/tools/metaphor_search/tool.py index 64cb3cd235..e957aeb43c 100644 --- a/libs/langchain/langchain/tools/metaphor_search/tool.py +++ b/libs/langchain/langchain/tools/metaphor_search/tool.py @@ -13,8 +13,8 @@ from langchain.utilities.metaphor_search import MetaphorSearchAPIWrapper class MetaphorSearchResults(BaseTool): """Tool that queries the Metaphor Search API and gets back json.""" - name = "metaphor_search_results_json" - description = ( + name: str = "metaphor_search_results_json" + description: str = ( "A wrapper around Metaphor Search. " "Input should be a Metaphor-optimized query. " "Output is a JSON array of the query results" diff --git a/libs/langchain/langchain/tools/openweathermap/tool.py b/libs/langchain/langchain/tools/openweathermap/tool.py index 2aa7ad1ba2..4e122b13d2 100644 --- a/libs/langchain/langchain/tools/openweathermap/tool.py +++ b/libs/langchain/langchain/tools/openweathermap/tool.py @@ -15,8 +15,8 @@ class OpenWeatherMapQueryRun(BaseTool): default_factory=OpenWeatherMapAPIWrapper ) - name = "OpenWeatherMap" - description = ( + name: str = "OpenWeatherMap" + description: str = ( "A wrapper around OpenWeatherMap API. " "Useful for fetching current weather information for a specified location. " "Input should be a location string (e.g. London,GB)." diff --git a/libs/langchain/langchain/tools/powerbi/tool.py b/libs/langchain/langchain/tools/powerbi/tool.py index 017e64a20f..c52f695c21 100644 --- a/libs/langchain/langchain/tools/powerbi/tool.py +++ b/libs/langchain/langchain/tools/powerbi/tool.py @@ -24,8 +24,8 @@ logger = logging.getLogger(__name__) class QueryPowerBITool(BaseTool): """Tool for querying a Power BI Dataset.""" - name = "query_powerbi" - description = """ + name: str = "query_powerbi" + description: str = """ Input to this tool is a detailed question about the dataset, output is a result from the dataset. It will try to answer the question using the dataset, and if it cannot, it will ask for clarification. Example Input: "How many rows are in table1?" @@ -217,8 +217,8 @@ class QueryPowerBITool(BaseTool): class InfoPowerBITool(BaseTool): """Tool for getting metadata about a PowerBI Dataset.""" - name = "schema_powerbi" - description = """ + name: str = "schema_powerbi" + description: str = """ Input to this tool is a comma-separated list of tables, output is the schema and sample rows for those tables. Be sure that the tables actually exist by calling list_tables_powerbi first! @@ -250,8 +250,8 @@ class InfoPowerBITool(BaseTool): class ListPowerBITool(BaseTool): """Tool for getting tables names.""" - name = "list_tables_powerbi" - description = "Input is an empty string, output is a comma separated list of tables in the database." # noqa: E501 # pylint: disable=C0301 + name: str = "list_tables_powerbi" + description: str = "Input is an empty string, output is a comma separated list of tables in the database." # noqa: E501 # pylint: disable=C0301 powerbi: PowerBIDataset = Field(exclude=True) class Config: diff --git a/libs/langchain/langchain/tools/pubmed/tool.py b/libs/langchain/langchain/tools/pubmed/tool.py index e5907a8269..84bfa72db6 100644 --- a/libs/langchain/langchain/tools/pubmed/tool.py +++ b/libs/langchain/langchain/tools/pubmed/tool.py @@ -9,8 +9,8 @@ from langchain.utilities.pubmed import PubMedAPIWrapper class PubmedQueryRun(BaseTool): """Tool that searches the PubMed API.""" - name = "PubMed" - description = ( + name: str = "PubMed" + description: str = ( "A wrapper around PubMed. " "Useful for when you need to answer questions about medicine, health, " "and biomedical topics " diff --git a/libs/langchain/langchain/tools/python/tool.py b/libs/langchain/langchain/tools/python/tool.py index 1a13466fd6..402a115ce9 100644 --- a/libs/langchain/langchain/tools/python/tool.py +++ b/libs/langchain/langchain/tools/python/tool.py @@ -42,8 +42,8 @@ def sanitize_input(query: str) -> str: class PythonREPLTool(BaseTool): """A tool for running python code in a REPL.""" - name = "Python_REPL" - description = ( + name: str = "Python_REPL" + description: str = ( "A Python shell. Use this to execute python commands. " "Input should be a valid python command. " "If you want to see the output of a value, you should print it out " @@ -80,8 +80,8 @@ class PythonREPLTool(BaseTool): class PythonAstREPLTool(BaseTool): """A tool for running python code in a REPL.""" - name = "python_repl_ast" - description = ( + name: str = "python_repl_ast" + description: str = ( "A Python shell. Use this to execute python commands. " "Input should be a valid python command. " "When using this tool, sometimes output is abbreviated - " diff --git a/libs/langchain/langchain/tools/searx_search/tool.py b/libs/langchain/langchain/tools/searx_search/tool.py index a6ff60a3f1..7dc1dcbd0c 100644 --- a/libs/langchain/langchain/tools/searx_search/tool.py +++ b/libs/langchain/langchain/tools/searx_search/tool.py @@ -13,8 +13,8 @@ from langchain.utilities.searx_search import SearxSearchWrapper class SearxSearchRun(BaseTool): """Tool that queries a Searx instance.""" - name = "searx_search" - description = ( + name: str = "searx_search" + description: str = ( "A meta search engine." "Useful for when you need to answer questions about current events." "Input should be a search query." @@ -42,8 +42,8 @@ class SearxSearchRun(BaseTool): class SearxSearchResults(BaseTool): """Tool that queries a Searx instance and gets back json.""" - name = "Searx Search Results" - description = ( + name: str = "Searx Search Results" + description: str = ( "A meta search engine." "Useful for when you need to answer questions about current events." "Input should be a search query. Output is a JSON array of the query results" diff --git a/libs/langchain/langchain/tools/steamship_image_generation/tool.py b/libs/langchain/langchain/tools/steamship_image_generation/tool.py index e6c4789200..abd38c8d29 100644 --- a/libs/langchain/langchain/tools/steamship_image_generation/tool.py +++ b/libs/langchain/langchain/tools/steamship_image_generation/tool.py @@ -48,8 +48,8 @@ class SteamshipImageGenerationTool(BaseTool): steamship: Steamship return_urls: Optional[bool] = False - name = "GenerateImage" - description = ( + name: str = "GenerateImage" + description: str = ( "Useful for when you need to generate an image." "Input: A detailed text-2-image prompt describing an image" "Output: the UUID of a generated image" diff --git a/libs/langchain/langchain/tools/wikipedia/tool.py b/libs/langchain/langchain/tools/wikipedia/tool.py index f9e3d653c0..60db606d1a 100644 --- a/libs/langchain/langchain/tools/wikipedia/tool.py +++ b/libs/langchain/langchain/tools/wikipedia/tool.py @@ -10,8 +10,8 @@ from langchain.utilities.wikipedia import WikipediaAPIWrapper class WikipediaQueryRun(BaseTool): """Tool that searches the Wikipedia API.""" - name = "Wikipedia" - description = ( + name: str = "Wikipedia" + description: str = ( "A wrapper around Wikipedia. " "Useful for when you need to answer general questions about " "people, places, companies, facts, historical events, or other subjects. " diff --git a/libs/langchain/langchain/tools/wolfram_alpha/tool.py b/libs/langchain/langchain/tools/wolfram_alpha/tool.py index dd7be399ec..2d5353e5ea 100644 --- a/libs/langchain/langchain/tools/wolfram_alpha/tool.py +++ b/libs/langchain/langchain/tools/wolfram_alpha/tool.py @@ -10,8 +10,8 @@ from langchain.utilities.wolfram_alpha import WolframAlphaAPIWrapper class WolframAlphaQueryRun(BaseTool): """Tool that queries using the Wolfram Alpha SDK.""" - name = "wolfram_alpha" - description = ( + name: str = "wolfram_alpha" + description: str = ( "A wrapper around Wolfram Alpha. " "Useful for when you need to answer questions about Math, " "Science, Technology, Culture, Society and Everyday Life. " diff --git a/libs/langchain/langchain/tools/youtube/search.py b/libs/langchain/langchain/tools/youtube/search.py index 6d66b3b2cc..310eb37aa0 100644 --- a/libs/langchain/langchain/tools/youtube/search.py +++ b/libs/langchain/langchain/tools/youtube/search.py @@ -18,8 +18,8 @@ from langchain.tools import BaseTool class YouTubeSearchTool(BaseTool): """Tool that queries YouTube.""" - name = "youtube_search" - description = ( + name: str = "youtube_search" + description: str = ( "search for youtube videos associated with a person. " "the input to this tool should be a comma separated list, " "the first part contains a person name and the second a " diff --git a/libs/langchain/langchain/tools/zapier/tool.py b/libs/langchain/langchain/tools/zapier/tool.py index 37f8d58163..636ea3c636 100644 --- a/libs/langchain/langchain/tools/zapier/tool.py +++ b/libs/langchain/langchain/tools/zapier/tool.py @@ -108,8 +108,8 @@ class ZapierNLARunAction(BaseTool): base_prompt: str = BASE_ZAPIER_TOOL_PROMPT zapier_description: str params_schema: Dict[str, str] = Field(default_factory=dict) - name = "" - description = "" + name: str = "" + description: str = "" @root_validator def set_name_description(cls, values: Dict[str, Any]) -> Dict[str, Any]: @@ -167,8 +167,8 @@ class ZapierNLAListActions(BaseTool): """ - name = "ZapierNLA_list_actions" - description = BASE_ZAPIER_TOOL_PROMPT + ( + name: str = "ZapierNLA_list_actions" + description: str = BASE_ZAPIER_TOOL_PROMPT + ( "This tool returns a list of the user's exposed actions." ) api_wrapper: ZapierNLAWrapper = Field(default_factory=ZapierNLAWrapper) diff --git a/libs/langchain/tests/unit_tests/tools/test_base.py b/libs/langchain/tests/unit_tests/tools/test_base.py index 2cbdca2eda..a66953a066 100644 --- a/libs/langchain/tests/unit_tests/tools/test_base.py +++ b/libs/langchain/tests/unit_tests/tools/test_base.py @@ -43,9 +43,9 @@ class _MockSchema(BaseModel): class _MockStructuredTool(BaseTool): - name = "structured_api" + name: str = "structured_api" args_schema: Type[BaseModel] = _MockSchema - description = "A Structured Tool" + description: str = "A Structured Tool" def _run(self, arg1: int, arg2: bool, arg3: Optional[dict] = None) -> str: return f"{arg1} {arg2} {arg3}" @@ -69,10 +69,10 @@ def test_misannotated_base_tool_raises_error() -> None: with pytest.raises(SchemaAnnotationError): class _MisAnnotatedTool(BaseTool): - name = "structured_api" + name: str = "structured_api" # This would silently be ignored without the custom metaclass args_schema: BaseModel = _MockSchema # type: ignore - description = "A Structured Tool" + description: str = "A Structured Tool" def _run(self, arg1: int, arg2: bool, arg3: Optional[dict] = None) -> str: return f"{arg1} {arg2} {arg3}" @@ -87,9 +87,9 @@ def test_forward_ref_annotated_base_tool_accepted() -> None: """Test that a using forward ref annotation syntax is accepted.""" "" class _ForwardRefAnnotatedTool(BaseTool): - name = "structured_api" + name: str = "structured_api" args_schema: "Type[BaseModel]" = _MockSchema - description = "A Structured Tool" + description: str = "A Structured Tool" def _run(self, arg1: int, arg2: bool, arg3: Optional[dict] = None) -> str: return f"{arg1} {arg2} {arg3}" @@ -104,9 +104,9 @@ def test_subclass_annotated_base_tool_accepted() -> None: """Test BaseTool child w/ custom schema isn't overwritten.""" class _ForwardRefAnnotatedTool(BaseTool): - name = "structured_api" + name: str = "structured_api" args_schema: Type[_MockSchema] = _MockSchema - description = "A Structured Tool" + description: str = "A Structured Tool" def _run(self, arg1: int, arg2: bool, arg3: Optional[dict] = None) -> str: return f"{arg1} {arg2} {arg3}" @@ -154,8 +154,8 @@ def test_decorated_function_schema_equivalent() -> None: def test_args_kwargs_filtered() -> None: class _SingleArgToolWithKwargs(BaseTool): - name = "single_arg_tool" - description = "A single arged tool with kwargs" + name: str = "single_arg_tool" + description: str = "A single arged tool with kwargs" def _run( self, @@ -177,8 +177,8 @@ def test_args_kwargs_filtered() -> None: assert tool.is_single_input class _VarArgToolWithKwargs(BaseTool): - name = "single_arg_tool" - description = "A single arged tool with kwargs" + name: str = "single_arg_tool" + description: str = "A single arged tool with kwargs" def _run( self, @@ -269,8 +269,8 @@ def test_base_tool_inheritance_base_schema() -> None: """Test schema is correctly inferred when inheriting from BaseTool.""" class _MockSimpleTool(BaseTool): - name = "simple_tool" - description = "A Simple Tool" + name: str = "simple_tool" + description: str = "A Simple Tool" def _run(self, tool_input: str) -> str: return f"{tool_input}" @@ -593,8 +593,8 @@ async def test_create_async_tool() -> None: class _FakeExceptionTool(BaseTool): - name = "exception" - description = "an exception-throwing tool" + name: str = "exception" + description: str = "an exception-throwing tool" exception: Exception = ToolException() def _run(self) -> str: