id
stringlengths
14
16
text
stringlengths
29
2.73k
source
stringlengths
49
117
26ee24e4ac3e-0
Source code for langchain.tools.ifttt """From https://github.com/SidU/teams-langchain-js/wiki/Connecting-IFTTT-Services. # Creating a webhook - Go to https://ifttt.com/create # Configuring the "If This" - Click on the "If This" button in the IFTTT interface. - Search for "Webhooks" in the search bar. - Choose the first...
https://python.langchain.com/en/latest/_modules/langchain/tools/ifttt.html
26ee24e4ac3e-1
- To get your webhook URL go to https://ifttt.com/maker_webhooks/settings - Copy the IFTTT key value from there. The URL is of the form https://maker.ifttt.com/use/YOUR_IFTTT_KEY. Grab the YOUR_IFTTT_KEY value. """ from typing import Optional import requests from langchain.callbacks.manager import ( AsyncCallbackMa...
https://python.langchain.com/en/latest/_modules/langchain/tools/ifttt.html
8c201d0f0d86-0
Source code for langchain.tools.base """Base implementation for tools or skills.""" from __future__ import annotations import warnings from abc import ABC, abstractmethod from inspect import signature from typing import Any, Awaitable, Callable, Dict, Optional, Tuple, Type, Union from pydantic import ( BaseModel, ...
https://python.langchain.com/en/latest/_modules/langchain/tools/base.html
8c201d0f0d86-1
... args_schema: Type[BaseModel] = SchemaClass ...""" raise SchemaAnnotationError( f"Tool definition for {name} must include valid type annotations" f" for argument 'args_schema' to behave as expected.\n" f"Expected annotation of 'Type[...
https://python.langchain.com/en/latest/_modules/langchain/tools/base.html
8c201d0f0d86-2
func: Callable, ) -> Type[BaseModel]: """Create a pydantic schema from a function's signature.""" validated = validate_arguments(func, config=_SchemaConfig) # type: ignore inferred_model = validated.model # type: ignore if "run_manager" in inferred_model.__fields__: del inferred_model.__fields...
https://python.langchain.com/en/latest/_modules/langchain/tools/base.html
8c201d0f0d86-3
""" verbose: bool = False """Whether to log the tool's progress.""" callbacks: Callbacks = Field(default=None, exclude=True) """Callbacks to be called during tool execution.""" callback_manager: Optional[BaseCallbackManager] = Field(default=None, exclude=True) """Deprecated. Please use callbacks...
https://python.langchain.com/en/latest/_modules/langchain/tools/base.html
8c201d0f0d86-4
if input_args is not None: result = input_args.parse_obj(tool_input) return {k: v for k, v in result.dict().items() if k in tool_input} return tool_input @root_validator() def raise_deprecation(cls, values: Dict) -> Dict: """Raise deprecation warning if callback_m...
https://python.langchain.com/en/latest/_modules/langchain/tools/base.html
8c201d0f0d86-5
verbose: Optional[bool] = None, start_color: Optional[str] = "green", color: Optional[str] = "green", callbacks: Callbacks = None, **kwargs: Any, ) -> Any: """Run the tool.""" parsed_input = self._parse_input(tool_input) if not self.verbose and verbose is not ...
https://python.langchain.com/en/latest/_modules/langchain/tools/base.html
8c201d0f0d86-6
observation = self.handle_tool_error(e) else: raise ValueError( f"Got unexpected type of `handle_tool_error`. Expected bool, str " f"or callable. Received: {self.handle_tool_error}" ) run_manager.on_tool_end( ...
https://python.langchain.com/en/latest/_modules/langchain/tools/base.html
8c201d0f0d86-7
try: # We then call the tool on the tool input to get an observation tool_args, tool_kwargs = self._to_args_and_kwargs(parsed_input) observation = ( await self._arun(*tool_args, run_manager=run_manager, **tool_kwargs) if new_arg_supported ...
https://python.langchain.com/en/latest/_modules/langchain/tools/base.html
8c201d0f0d86-8
"""Tool that takes in function or coroutine directly.""" description: str = "" func: Callable[..., str] """The function to run when the tool is called.""" coroutine: Optional[Callable[..., Awaitable[str]]] = None """The asynchronous version of the function.""" @property def args(self) -> dic...
https://python.langchain.com/en/latest/_modules/langchain/tools/base.html
8c201d0f0d86-9
**kwargs, ) if new_argument_supported else self.func(*args, **kwargs) ) async def _arun( self, *args: Any, run_manager: Optional[AsyncCallbackManagerForToolRun] = None, **kwargs: Any, ) -> Any: """Use the tool asynchronously."""...
https://python.langchain.com/en/latest/_modules/langchain/tools/base.html
8c201d0f0d86-10
return_direct=return_direct, args_schema=args_schema, **kwargs, ) [docs]class StructuredTool(BaseTool): """Tool that can operate on any number of inputs.""" description: str = "" args_schema: Type[BaseModel] = Field(..., description="The tool schema.") """The input argume...
https://python.langchain.com/en/latest/_modules/langchain/tools/base.html
8c201d0f0d86-11
) return ( await self.coroutine( *args, callbacks=run_manager.get_child() if run_manager else None, **kwargs, ) if new_argument_supported else await self.coroutine(*args, **kwargs) ...
https://python.langchain.com/en/latest/_modules/langchain/tools/base.html
8c201d0f0d86-12
infer_schema: bool = True, ) -> Callable: """Make tools out of functions, can be used with or without arguments. Args: *args: The arguments to the tool. return_direct: Whether to return directly from the tool rather than continuing the agent loop. args_schema: optional argume...
https://python.langchain.com/en/latest/_modules/langchain/tools/base.html
8c201d0f0d86-13
return_direct=return_direct, ) return _make_tool if len(args) == 1 and isinstance(args[0], str): # if the argument is a string, then we use the string as the tool name # Example usage: @tool("search", return_direct=True) return _make_with_name(args[0]) elif len(args) ...
https://python.langchain.com/en/latest/_modules/langchain/tools/base.html
b046fb0c9039-0
Source code for langchain.tools.plugin from __future__ import annotations import json from typing import Optional, Type import requests import yaml from pydantic import BaseModel from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base impo...
https://python.langchain.com/en/latest/_modules/langchain/tools/plugin.html
b046fb0c9039-1
plugin = AIPlugin.from_url(url) description = ( f"Call this tool to get the OpenAPI spec (and usage guide) " f"for interacting with the {plugin.name_for_human} API. " f"You should only call this ONCE! What is the " f"{plugin.name_for_human} API useful for? " ...
https://python.langchain.com/en/latest/_modules/langchain/tools/plugin.html
ba5ab962815e-0
Source code for langchain.tools.google_search.tool """Tool for the Google search API.""" from typing import Optional from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langchain.utilities.google_search import Goog...
https://python.langchain.com/en/latest/_modules/langchain/tools/google_search/tool.html
ba5ab962815e-1
api_wrapper: GoogleSearchAPIWrapper def _run( self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the tool.""" return str(self.api_wrapper.results(query, self.num_results)) async def _arun( self, query: str, ...
https://python.langchain.com/en/latest/_modules/langchain/tools/google_search/tool.html
a1ad065e50d3-0
Source code for langchain.tools.vectorstore.tool """Tools for interacting with vectorstores.""" import json from typing import Any, Dict, Optional from pydantic import BaseModel, Field from langchain.base_language import BaseLanguageModel from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, ...
https://python.langchain.com/en/latest/_modules/langchain/tools/vectorstore/tool.html
a1ad065e50d3-1
def _run( self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the tool.""" chain = RetrievalQA.from_chain_type( self.llm, retriever=self.vectorstore.as_retriever() ) return chain.run(query) async def _aru...
https://python.langchain.com/en/latest/_modules/langchain/tools/vectorstore/tool.html
a1ad065e50d3-2
self.llm, retriever=self.vectorstore.as_retriever() ) return json.dumps(chain({chain.question_key: query}, return_only_outputs=True)) async def _arun( self, query: str, run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> str: """Use the tool asynchr...
https://python.langchain.com/en/latest/_modules/langchain/tools/vectorstore/tool.html
b23d04c8ed41-0
Source code for langchain.tools.bing_search.tool """Tool for the Bing search API.""" from typing import Optional from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langchain.utilities.bing_search import BingSearch...
https://python.langchain.com/en/latest/_modules/langchain/tools/bing_search/tool.html
b23d04c8ed41-1
api_wrapper: BingSearchAPIWrapper def _run( self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the tool.""" return str(self.api_wrapper.results(query, self.num_results)) async def _arun( self, query: str, ...
https://python.langchain.com/en/latest/_modules/langchain/tools/bing_search/tool.html
936f510ba12e-0
Source code for langchain.tools.azure_cognitive_services.speech2text from __future__ import annotations import logging import time from typing import Any, Dict, Optional from pydantic import root_validator from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) fro...
https://python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/speech2text.html
936f510ba12e-1
) azure_cogs_region = get_from_dict_or_env( values, "azure_cogs_region", "AZURE_COGS_REGION" ) try: import azure.cognitiveservices.speech as speechsdk values["speech_config"] = speechsdk.SpeechConfig( subscription=azure_cogs_key, region=azure_c...
https://python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/speech2text.html
936f510ba12e-2
except ImportError: pass audio_src_type = detect_file_src_type(audio_path) if audio_src_type == "local": audio_config = speechsdk.AudioConfig(filename=audio_path) elif audio_src_type == "remote": tmp_audio_path = download_audio_from_url(audio_path) ...
https://python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/speech2text.html
ef9f66cfa751-0
Source code for langchain.tools.azure_cognitive_services.image_analysis from __future__ import annotations import logging from typing import Any, Dict, Optional from pydantic import root_validator from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langcha...
https://python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/image_analysis.html
ef9f66cfa751-1
) try: import azure.ai.vision as sdk values["vision_service"] = sdk.VisionServiceOptions( endpoint=azure_cogs_endpoint, key=azure_cogs_key ) values["analysis_options"] = sdk.ImageAnalysisOptions() values["analysis_options"].features = (...
https://python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/image_analysis.html
ef9f66cfa751-2
res_dict["tags"] = [tag.name for tag in result.tags] if result.text is not None: res_dict["text"] = [line.content for line in result.text.lines] else: error_details = sdk.ImageAnalysisErrorDetails.from_result(result) raise RuntimeError( f"Image...
https://python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/image_analysis.html
ef9f66cfa751-3
if not image_analysis_result: return "No good image analysis result was found" return self._format_image_analysis_result(image_analysis_result) except Exception as e: raise RuntimeError(f"Error while running AzureCogsImageAnalysisTool: {e}") async def _arun( s...
https://python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/image_analysis.html
4ffc6ef92e8c-0
Source code for langchain.tools.azure_cognitive_services.text2speech from __future__ import annotations import logging import tempfile from typing import Any, Dict, Optional from pydantic import root_validator from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, )...
https://python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/text2speech.html
4ffc6ef92e8c-1
) try: import azure.cognitiveservices.speech as speechsdk values["speech_config"] = speechsdk.SpeechConfig( subscription=azure_cogs_key, region=azure_cogs_region ) except ImportError: raise ImportError( "azure-cognitiveservi...
https://python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/text2speech.html
4ffc6ef92e8c-2
def _run( self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the tool.""" try: speech_file = self._text2speech(query, self.speech_language) return speech_file except Exception as e: raise Run...
https://python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/text2speech.html
1d369fc9dd5d-0
Source code for langchain.tools.azure_cognitive_services.form_recognizer from __future__ import annotations import logging from typing import Any, Dict, List, Optional from pydantic import root_validator from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from ...
https://python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html
1d369fc9dd5d-1
) azure_cogs_endpoint = get_from_dict_or_env( values, "azure_cogs_endpoint", "AZURE_COGS_ENDPOINT" ) try: from azure.ai.formrecognizer import DocumentAnalysisClient from azure.core.credentials import AzureKeyCredential values["doc_analysis_client"]...
https://python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html
1d369fc9dd5d-2
"prebuilt-document", document ) elif document_src_type == "remote": poller = self.doc_analysis_client.begin_analyze_document_from_url( "prebuilt-document", document_path ) else: raise ValueError(f"Invalid document path: {document_path}"...
https://python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html
1d369fc9dd5d-3
) -> str: """Use the tool.""" try: document_analysis_result = self._document_analysis(query) if not document_analysis_result: return "No good document analysis result was found" return self._format_document_analysis_result(document_analysis_result) ...
https://python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html
d3952edafc49-0
Source code for langchain.tools.ddg_search.tool """Tool for the DuckDuckGo search API.""" import warnings from typing import Any, Optional from pydantic import Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool f...
https://python.langchain.com/en/latest/_modules/langchain/tools/ddg_search/tool.html
d3952edafc49-1
description = ( "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" ) num_results: int = 4 api_wrapper: DuckDuckGoSearchAPIWrapper = Field( ...
https://python.langchain.com/en/latest/_modules/langchain/tools/ddg_search/tool.html
48f24bd5cba7-0
Source code for langchain.tools.gmail.send_message """Send Gmail messages.""" import base64 from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from typing import Any, Dict, List, Optional from pydantic import BaseModel, Field from langchain.callbacks.manager import ( AsyncCallbackMa...
https://python.langchain.com/en/latest/_modules/langchain/tools/gmail/send_message.html
48f24bd5cba7-1
mime_message["To"] = ", ".join(to) mime_message["Subject"] = subject if cc is not None: mime_message["Cc"] = ", ".join(cc) if bcc is not None: mime_message["Bcc"] = ", ".join(bcc) encoded_message = base64.urlsafe_b64encode(mime_message.as_bytes()).decode() ...
https://python.langchain.com/en/latest/_modules/langchain/tools/gmail/send_message.html
48f24bd5cba7-2
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/_modules/langchain/tools/gmail/send_message.html
87cb82f9fb0d-0
Source code for langchain.tools.gmail.get_message import base64 import email from typing import Dict, Optional, Type from pydantic import BaseModel, Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.gmail.base import GmailBaseTool f...
https://python.langchain.com/en/latest/_modules/langchain/tools/gmail/get_message.html
87cb82f9fb0d-1
"snippet": message_data["snippet"], "body": body, "subject": subject, "sender": sender, } async def _arun( self, message_id: str, run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> Dict: """Run the tool.""" raise...
https://python.langchain.com/en/latest/_modules/langchain/tools/gmail/get_message.html
0ea65ce5e1ee-0
Source code for langchain.tools.gmail.search import base64 import email from enum import Enum from typing import Any, Dict, List, Optional, Type from pydantic import BaseModel, Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.gmail...
https://python.langchain.com/en/latest/_modules/langchain/tools/gmail/search.html
0ea65ce5e1ee-1
name: str = "search_gmail" description: str = ( "Use this tool to search for email messages or threads." " The input must be a valid Gmail query." " The output is a JSON list of the requested resource." ) args_schema: Type[SearchArgsSchema] = SearchArgsSchema def _parse_threads(s...
https://python.langchain.com/en/latest/_modules/langchain/tools/gmail/search.html
0ea65ce5e1ee-2
body = clean_email_body(message_body) results.append( { "id": message["id"], "threadId": message_data["threadId"], "snippet": message_data["snippet"], "body": body, "subject": subject, ...
https://python.langchain.com/en/latest/_modules/langchain/tools/gmail/search.html
946e580542f8-0
Source code for langchain.tools.gmail.create_draft import base64 from email.message import EmailMessage from typing import List, Optional, Type from pydantic import BaseModel, Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.gmail....
https://python.langchain.com/en/latest/_modules/langchain/tools/gmail/create_draft.html
946e580542f8-1
draft_message["Subject"] = subject if cc is not None: draft_message["Cc"] = ", ".join(cc) if bcc is not None: draft_message["Bcc"] = ", ".join(bcc) encoded_message = base64.urlsafe_b64encode(draft_message.as_bytes()).decode() return {"message": {"raw": encoded_mes...
https://python.langchain.com/en/latest/_modules/langchain/tools/gmail/create_draft.html
c868d2c8b7c0-0
Source code for langchain.tools.gmail.get_thread from typing import Dict, Optional, Type from pydantic import BaseModel, Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.gmail.base import GmailBaseTool class GetThreadSchema(BaseMod...
https://python.langchain.com/en/latest/_modules/langchain/tools/gmail/get_thread.html
c868d2c8b7c0-1
) return thread_data async def _arun( self, thread_id: str, run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> Dict: """Run the tool.""" raise NotImplementedError By Harrison Chase © Copyright 2023, Harrison Chase. Last updated ...
https://python.langchain.com/en/latest/_modules/langchain/tools/gmail/get_thread.html
de9e854d0b8f-0
Source code for langchain.tools.zapier.tool """## Zapier Natural Language Actions API \ Full docs here: https://nla.zapier.com/api/v1/docs **Zapier Natural Language Actions** gives you access to the 5k+ apps, 20k+ actions on Zapier's platform through a natural language API interface. NLA supports apps like Gmail, Sales...
https://python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html
de9e854d0b8f-1
2. Use LLMChain to generate a draft reply to (1) 3. Use NLA to send the draft reply (2) to someone in Slack via direct message In code, below: ```python import os # get from https://platform.openai.com/ os.environ["OPENAI_API_KEY"] = os.environ.get("OPENAI_API_KEY", "") # get from https://nla.zapier.com/demo/provid...
https://python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html
de9e854d0b8f-2
agent = initialize_agent( toolkit.get_tools(), llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True ) agent.run(("Summarize the last email I received regarding Silicon Valley Bank. " "Send the summary to the #test-zapier channel in slack.")) ``` """ from typing import Any, Dict, Optional f...
https://python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html
de9e854d0b8f-3
name = "" description = "" @root_validator def set_name_description(cls, values: Dict[str, Any]) -> Dict[str, Any]: zapier_description = values["zapier_description"] params_schema = values["params_schema"] if "instructions" in params_schema: del params_schema["instruction...
https://python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html
de9e854d0b8f-4
) # other useful actions [docs]class ZapierNLAListActions(BaseTool): """ Args: None """ name = "Zapier NLA: List Actions" description = BASE_ZAPIER_TOOL_PROMPT + ( "This tool returns a list of the user's exposed actions." ) api_wrapper: ZapierNLAWrapper = Field(default_factor...
https://python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html
e90f8c720bc3-0
Source code for langchain.tools.human.tool """Tool for asking human input.""" from typing import Callable, Optional from pydantic import Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool def _print_func(text: st...
https://python.langchain.com/en/latest/_modules/langchain/tools/human/tool.html
d62f7b345389-0
Source code for langchain.tools.google_serper.tool """Tool for the Serper.dev Google Search API.""" from typing import Optional from pydantic.fields import Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from ...
https://python.langchain.com/en/latest/_modules/langchain/tools/google_serper/tool.html
d62f7b345389-1
) api_wrapper: GoogleSerperAPIWrapper = Field(default_factory=GoogleSerperAPIWrapper) def _run( self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the tool.""" return str(self.api_wrapper.results(query)) async def _arun( ...
https://python.langchain.com/en/latest/_modules/langchain/tools/google_serper/tool.html
9990314b41f7-0
Source code for langchain.tools.powerbi.tool """Tools for interacting with a Power BI dataset.""" from typing import Any, Dict, Optional, Tuple from pydantic import Field, validator from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.chains.llm i...
https://python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html
9990314b41f7-1
cls, llm_chain: LLMChain ) -> LLMChain: """Make sure the LLM chain has the correct input variables.""" if llm_chain.prompt.input_variables != [ "tool_input", "tables", "schemas", "examples", ]: raise ValueError( "LLM...
https://python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html
9990314b41f7-2
return self.session_cache[tool_input] if query == "I cannot answer this": self.session_cache[tool_input] = query return self.session_cache[tool_input] pbi_result = self.powerbi.run(command=query) result, error = self._parse_output(pbi_result) iterations = kwargs.g...
https://python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html
9990314b41f7-3
return self.session_cache[tool_input] pbi_result = await self.powerbi.arun(command=query) result, error = self._parse_output(pbi_result) iterations = kwargs.get("iterations", 0) if error and iterations < self.max_iterations: return await self._arun( tool_input...
https://python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html
9990314b41f7-4
Be sure that the tables actually exist by calling list_tables_powerbi first! Example Input: "table1, table2, table3" """ # noqa: E501 powerbi: PowerBIDataset = Field(exclude=True) class Config: """Configuration for this pydantic object.""" arbitrary_types_allowed = True def _run( ...
https://python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html
9990314b41f7-5
self, tool_input: Optional[str] = None, run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> str: """Get the names of the tables.""" return ", ".join(self.powerbi.get_table_names()) By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on ...
https://python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html
dfd9570c3381-0
Source code for langchain.tools.shell.tool import asyncio import platform import warnings from typing import List, Optional, Type, Union from pydantic import BaseModel, Field, root_validator from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.too...
https://python.langchain.com/en/latest/_modules/langchain/tools/shell/tool.html
dfd9570c3381-1
name: str = "terminal" """Name of tool.""" description: str = f"Run shell commands on this {_get_platform()} machine." """Description of tool.""" args_schema: Type[BaseModel] = ShellInput """Schema for input arguments.""" def _run( self, commands: Union[str, List[str]], r...
https://python.langchain.com/en/latest/_modules/langchain/tools/shell/tool.html
27cfe31bf8c5-0
Source code for langchain.tools.google_places.tool """Tool for the Google search API.""" from typing import Optional from pydantic import BaseModel, Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langcha...
https://python.langchain.com/en/latest/_modules/langchain/tools/google_places/tool.html
c759b75c474a-0
Source code for langchain.tools.wikipedia.tool """Tool for the Wikipedia API.""" from typing import Optional from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langchain.utilities.wikipedia import WikipediaAPIWrap...
https://python.langchain.com/en/latest/_modules/langchain/tools/wikipedia/tool.html
aa4cdebd7510-0
Source code for langchain.tools.openweathermap.tool """Tool for the OpenWeatherMap API.""" from typing import Optional from pydantic import Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langchain.utilit...
https://python.langchain.com/en/latest/_modules/langchain/tools/openweathermap/tool.html
2445501ed876-0
Source code for langchain.tools.steamship_image_generation.tool """This tool allows agents to generate images using Steamship. Steamship offers access to different third party image generation APIs using a single API key. Today the following models are supported: - Dall-E - Stable Diffusion To use this tool, you must f...
https://python.langchain.com/en/latest/_modules/langchain/tools/steamship_image_generation/tool.html
2445501ed876-1
description = ( "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" ) @root_validator(pre=True) def validate_size(cls, values: Dict) -> Dict: if "size" in values: size...
https://python.langchain.com/en/latest/_modules/langchain/tools/steamship_image_generation/tool.html
2445501ed876-2
) task = image_generator.generate(text=query, append_output_to_file=True) task.wait() blocks = task.output.blocks if len(blocks) > 0: if self.return_urls: return make_image_public(self.steamship, blocks[0]) else: return blocks[0].id...
https://python.langchain.com/en/latest/_modules/langchain/tools/steamship_image_generation/tool.html
e440fc98e039-0
Source code for langchain.tools.wolfram_alpha.tool """Tool for the Wolfram Alpha API.""" from typing import Optional from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langchain.utilities.wolfram_alpha import Wolf...
https://python.langchain.com/en/latest/_modules/langchain/tools/wolfram_alpha/tool.html
fae9278192dc-0
Source code for langchain.tools.file_management.move import shutil from typing import Optional, Type from pydantic import BaseModel, Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langchain.tools.file_ma...
https://python.langchain.com/en/latest/_modules/langchain/tools/file_management/move.html
fae9278192dc-1
shutil.move(str(source_path_), destination_path_) return f"File moved successfully from {source_path} to {destination_path}." except Exception as e: return "Error: " + str(e) async def _arun( self, source_path: str, destination_path: str, run_manager: ...
https://python.langchain.com/en/latest/_modules/langchain/tools/file_management/move.html
69395e3157d9-0
Source code for langchain.tools.file_management.read from typing import Optional, Type from pydantic import BaseModel, Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langchain.tools.file_management.utils...
https://python.langchain.com/en/latest/_modules/langchain/tools/file_management/read.html
69395e3157d9-1
# TODO: Add aiofiles method raise NotImplementedError By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/_modules/langchain/tools/file_management/read.html
d19dedff3156-0
Source code for langchain.tools.file_management.write from typing import Optional, Type from pydantic import BaseModel, Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langchain.tools.file_management.util...
https://python.langchain.com/en/latest/_modules/langchain/tools/file_management/write.html
d19dedff3156-1
except Exception as e: return "Error: " + str(e) async def _arun( self, file_path: str, text: str, append: bool = False, run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> str: # TODO: Add aiofiles method raise NotImplementedErr...
https://python.langchain.com/en/latest/_modules/langchain/tools/file_management/write.html
3339904884ea-0
Source code for langchain.tools.file_management.file_search import fnmatch import os from typing import Optional, Type from pydantic import BaseModel, Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langc...
https://python.langchain.com/en/latest/_modules/langchain/tools/file_management/file_search.html
3339904884ea-1
matches.append(relative_path) if matches: return "\n".join(matches) else: return f"No files found for pattern {pattern} in directory {dir_path}" except Exception as e: return "Error: " + str(e) async def _arun( self, dir_pat...
https://python.langchain.com/en/latest/_modules/langchain/tools/file_management/file_search.html
323cf0e93f08-0
Source code for langchain.tools.file_management.delete import os from typing import Optional, Type from pydantic import BaseModel, Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langchain.tools.file_mana...
https://python.langchain.com/en/latest/_modules/langchain/tools/file_management/delete.html
323cf0e93f08-1
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/_modules/langchain/tools/file_management/delete.html
7f194b9531dd-0
Source code for langchain.tools.file_management.list_dir import os from typing import Optional, Type from pydantic import BaseModel, Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langchain.tools.file_ma...
https://python.langchain.com/en/latest/_modules/langchain/tools/file_management/list_dir.html
7f194b9531dd-1
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/_modules/langchain/tools/file_management/list_dir.html
80a400fbfc4d-0
Source code for langchain.tools.file_management.copy import shutil from typing import Optional, Type from pydantic import BaseModel, Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langchain.tools.file_ma...
https://python.langchain.com/en/latest/_modules/langchain/tools/file_management/copy.html
80a400fbfc4d-1
except Exception as e: return "Error: " + str(e) async def _arun( self, source_path: str, destination_path: str, run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> str: # TODO: Add aiofiles method raise NotImplementedError By Harrison C...
https://python.langchain.com/en/latest/_modules/langchain/tools/file_management/copy.html
24346cdc0b56-0
Source code for langchain.tools.openapi.utils.openapi_utils """Utility functions for parsing an OpenAPI spec.""" import copy import json import logging import re from enum import Enum from pathlib import Path from typing import Dict, List, Optional, Union import requests import yaml from openapi_schema_pydantic import ...
https://python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/openapi_utils.html
24346cdc0b56-1
@property def _components_strict(self) -> Components: """Get components or err.""" if self.components is None: raise ValueError("No components found in spec. ") return self.components @property def _parameters_strict(self) -> Dict[str, Union[Parameter, Reference]]: ...
https://python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/openapi_utils.html
24346cdc0b56-2
parameter = self._get_referenced_parameter(ref) while isinstance(parameter, Reference): parameter = self._get_referenced_parameter(parameter) return parameter [docs] def get_referenced_schema(self, ref: Reference) -> Schema: """Get a schema (or nested reference) or err.""" ...
https://python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/openapi_utils.html
24346cdc0b56-3
"""Alert if the spec is not supported.""" warning_message = ( " This may result in degraded performance." + " Convert your OpenAPI spec to 3.1.* spec" + " for better support." ) swagger_version = obj.get("swagger") openapi_version = obj.get("openapi") ...
https://python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/openapi_utils.html
24346cdc0b56-4
def from_spec_dict(cls, spec_dict: dict) -> "OpenAPISpec": """Get an OpenAPI spec from a dict.""" return cls.parse_obj(spec_dict) [docs] @classmethod def from_text(cls, text: str) -> "OpenAPISpec": """Get an OpenAPI spec from a text.""" try: spec_dict = json.loads(text...
https://python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/openapi_utils.html
24346cdc0b56-5
if isinstance(operation, Operation): results.append(method.value) return results [docs] def get_operation(self, path: str, method: str) -> Operation: """Get the operation object for a given path and HTTP method.""" path_item = self._get_path_strict(path) operation_obj ...
https://python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/openapi_utils.html
24346cdc0b56-6
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/openapi_utils.html
74f1c3d3e9b2-0
Source code for langchain.tools.openapi.utils.api_models """Pydantic models for parsing an OpenAPI spec.""" import logging from enum import Enum from typing import Any, Dict, List, Optional, Sequence, Tuple, Type, Union from openapi_schema_pydantic import MediaType, Parameter, Reference, RequestBody, Schema from pydant...
https://python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
74f1c3d3e9b2-1
) SCHEMA_TYPE = Union[str, Type, tuple, None, Enum] class APIPropertyBase(BaseModel): """Base model for an API property.""" # The name of the parameter is required and is case sensitive. # If "in" is "path", the "name" field must correspond to a template expression # within the path field in the Paths O...
https://python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
74f1c3d3e9b2-2
if not isinstance(type_, list): return type_ else: return tuple(type_) @staticmethod def _get_schema_type_for_enum(parameter: Parameter, schema: Schema) -> Enum: """Get the schema type when the parameter is an enum.""" param_name = f"{parameter.name}Enum" ...
https://python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html