id stringlengths 14 16 | text stringlengths 13 2.7k | source stringlengths 57 178 |
|---|---|---|
57499370aff0-0 | Source code for langchain.tools.azure_cognitive_services.utils
import os
import tempfile
from urllib.parse import urlparse
import requests
[docs]def detect_file_src_type(file_path: str) -> str:
"""Detect if the file is local or remote."""
if os.path.isfile(file_path):
return "local"
parsed_url = url... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/utils.html |
73981b62e4c1-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 langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import root_validator
from langchain.tools.azure_cognitive_... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html |
73981b62e4c1-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"]... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html |
73981b62e4c1-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}"... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html |
73981b62e4c1-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)
... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html |
b3d4eace6ccc-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 langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import root_validator
from langchain.tools.azure_cognitiv... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/speech2text.html |
b3d4eace6ccc-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... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/speech2text.html |
b3d4eace6ccc-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)
... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/speech2text.html |
fa6806bed0f2-0 | Source code for langchain.tools.searx_search.tool
"""Tool for the SearxNG search API."""
from typing import Optional
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import Extra
from langchain.tools.base import BaseTool, Field
fro... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/searx_search/tool.html |
fa6806bed0f2-1 | "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"
)
wrapper: SearxSearchWrapper
num_results: int = 4
kwargs: dict = Field(default_factory=dict)
class Config:
"""Pydantic config."""
... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/searx_search/tool.html |
9ae102c83393-0 | Source code for langchain.tools.google_cloud.texttospeech
from __future__ import annotations
import tempfile
from typing import TYPE_CHECKING, Any, Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.base import BaseTool
from langchain.utilities.vertexai import get_client_inf... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/google_cloud/texttospeech.html |
9ae102c83393-1 | "Useful for when you need to synthesize audio from text. "
"It supports multiple languages, including English, German, Polish, "
"Spanish, Italian, French, Portuguese, and Hindi. "
)
_client: Any
def __init__(self, **kwargs: Any) -> None:
"""Initializes private fields."""
tex... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/google_cloud/texttospeech.html |
6dfd76183f01-0 | Source code for langchain.tools.dataforseo_api_search.tool
"""Tool for the DataForSeo SERP API."""
from typing import Optional
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import Field
from langchain.tools.base import BaseTool
... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/dataforseo_api_search/tool.html |
6dfd76183f01-1 | "A comprehensive Google Search API provided by DataForSeo."
"This tool is useful for obtaining real-time data on current events "
"or popular searches."
"The input should be a search query and the output is a JSON object "
"of the query results."
)
api_wrapper: DataForSeoAPIWrapp... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/dataforseo_api_search/tool.html |
4fbc5d20edd8-0 | Source code for langchain.tools.shell.tool
import asyncio
import platform
import warnings
from typing import Any, List, Optional, Type, Union
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import BaseModel, Field, root_validator
... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/shell/tool.html |
4fbc5d20edd8-1 | if system == "Darwin":
return "MacOS"
return system
[docs]class ShellTool(BaseTool):
"""Tool to run shell commands."""
process: Any = Field(default_factory=_get_default_bash_process)
"""Bash process to run commands."""
name: str = "terminal"
"""Name of tool."""
description: str = f"R... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/shell/tool.html |
dc8ff6bfd0e4-0 | Source code for langchain.tools.arxiv.tool
"""Tool for the Arxiv API."""
from typing import Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.base import BaseTool
from langchain.utilities.arxiv import ArxivAPIWrapper
... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/arxiv/tool.html |
3bd838f78c59-0 | Source code for langchain.tools.vectorstore.tool
"""Tools for interacting with vectorstores."""
import json
from typing import Any, Dict, Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.llms.openai import OpenAI
from langchain.pydantic_v1 import BaseModel, Field
from langchain.... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/vectorstore/tool.html |
3bd838f78c59-1 | ) -> str:
"""Use the tool."""
from langchain.chains.retrieval_qa.base import RetrievalQA
chain = RetrievalQA.from_chain_type(
self.llm, retriever=self.vectorstore.as_retriever()
)
return chain.run(
query, callbacks=run_manager.get_child() if run_manager el... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/vectorstore/tool.html |
3bd838f78c59-2 | chain(
{chain.question_key: query},
return_only_outputs=True,
callbacks=run_manager.get_child() if run_manager else None,
)
) | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/vectorstore/tool.html |
4ab265332186-0 | Source code for langchain.tools.tavily_search.tool
"""Tool for the Tavily search API."""
from typing import Dict, List, Optional, Type, Union
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import BaseModel, Field
from langchain.t... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/tavily_search/tool.html |
4ab265332186-1 | ) -> Union[List[Dict], str]:
"""Use the tool asynchronously."""
try:
return await self.api_wrapper.results_async(
query,
self.max_results,
)
except Exception as e:
return repr(e)
[docs]class TavilyAnswer(BaseTool):
"""Tool t... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/tavily_search/tool.html |
4ab265332186-2 | include_answer=True,
search_depth="basic",
)
return result["answer"]
except Exception as e:
return repr(e) | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/tavily_search/tool.html |
8f83d25e35a0-0 | Source code for langchain.tools.brave_search.tool
from __future__ import annotations
from typing import Any, Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.base import BaseTool
from langchain.utilities.brave_search import BraveSearchWrapper
[docs]class BraveSearch(BaseTo... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/brave_search/tool.html |
10362b008378-0 | Source code for langchain.tools.wolfram_alpha.tool
"""Tool for the Wolfram Alpha API."""
from typing import Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.base import BaseTool
from langchain.utilities.wolfram_alpha import WolframAlphaAPIWrapper
[docs]class WolframAlphaQu... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/wolfram_alpha/tool.html |
f9055a41460c-0 | Source code for langchain.tools.multion.update_session
import asyncio
from typing import TYPE_CHECKING, Optional, Type
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.base import BaseTo... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/multion/update_session.html |
f9055a41460c-1 | Note: sessionId must be received from previous Browser window creation."""
args_schema: Type[UpdateSessionSchema] = UpdateSessionSchema
sessionId: str = ""
def _run(
self,
sessionId: str,
query: str,
url: Optional[str] = "https://www.google.com/",
run_manager: Optiona... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/multion/update_session.html |
90503e55fca2-0 | Source code for langchain.tools.multion.close_session
import asyncio
from typing import TYPE_CHECKING, Optional, Type
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.base import BaseToo... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/multion/close_session.html |
90503e55fca2-1 | try:
try:
multion.close_session(sessionId)
except Exception as e:
print(f"{e}, retrying...")
except Exception as e:
raise Exception(f"An error occurred: {e}")
async def _arun(
self,
sessionId: str,
run_manager: Optio... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/multion/close_session.html |
0b7caf9990bd-0 | Source code for langchain.tools.multion.create_session
import asyncio
from typing import TYPE_CHECKING, Optional, Type
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.base import BaseTo... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/multion/create_session.html |
0b7caf9990bd-1 | Use this tool to create a new Browser Window with provided fields. \
Always the first step to run any activities that can be done using browser.
"""
args_schema: Type[CreateSessionSchema] = CreateSessionSchema
def _run(
self,
query: str,
url: Optional[str] = "https://www.... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/multion/create_session.html |
5231524ad71d-0 | Source code for langchain.tools.gitlab.tool
"""
This tool allows agents to interact with the python-gitlab library
and operate on a GitLab repository.
To use this tool, you must first set as environment variables:
GITLAB_PRIVATE_ACCESS_TOKEN
GITLAB_REPOSITORY -> format: {owner}/{repo}
"""
from typing import Opt... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/gitlab/tool.html |
5cf89e210966-0 | Source code for langchain.tools.google_search.tool
"""Tool for the Google search API."""
from typing import Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.base import BaseTool
from langchain.utilities.google_search import GoogleSearchAPIWrapper
[docs]class GoogleSearchRu... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/google_search/tool.html |
bd7b3d95bb74-0 | Source code for langchain.tools.amadeus.closest_airport
from typing import Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.chains import LLMChain
from langchain.chat_models import ChatOpenAI
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.amadeus.b... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/closest_airport.html |
bd7b3d95bb74-1 | " What is the nearest airport to {location}? Please respond with the "
" airport's International Air Transport Association (IATA) Location "
' Identifier in the following JSON format. JSON: "iataCode": "IATA '
' Location Identifier" '
)
llm = ChatOpenAI(temperature=0)... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/closest_airport.html |
63dd58d12bf2-0 | Source code for langchain.tools.amadeus.base
"""Base class for Amadeus tools."""
from __future__ import annotations
from typing import TYPE_CHECKING
from langchain.pydantic_v1 import Field
from langchain.tools.amadeus.utils import authenticate
from langchain.tools.base import BaseTool
if TYPE_CHECKING:
from amadeus... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/base.html |
b9afbc091f38-0 | Source code for langchain.tools.amadeus.utils
"""O365 tool utils."""
from __future__ import annotations
import logging
import os
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from amadeus import Client
logger = logging.getLogger(__name__)
[docs]def authenticate() -> Client:
"""Authenticate using the Amadeu... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/utils.html |
829e1cda5b17-0 | Source code for langchain.tools.amadeus.flight_search
import logging
from datetime import datetime as dt
from typing import Dict, Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.amadeus.base import AmadeusBaseTool
l... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/flight_search.html |
829e1cda5b17-1 | ' components. For example: "2023-06-09T10:30:00" represents '
" June 9th, 2023, at 10:30 AM. "
)
)
page_number: int = Field(
default=1,
description="The specific page number of flight results to retrieve",
)
[docs]class AmadeusFlightSearch(AmadeusBaseTool):
"""Tool fo... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/flight_search.html |
829e1cda5b17-2 | if earliestDeparture.date() != latestDeparture.date():
logger.error(
" Error: Earliest and latest departure dates need to be the "
" same date. If you're trying to search for round-trip "
" flights, call this function for the outbound flight first, "
... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/flight_search.html |
829e1cda5b17-3 | output.append(itinerary)
# Filter out flights after latest departure time
for index, offer in enumerate(output):
offerDeparture = dt.strptime(
offer["segments"][0]["departure"]["at"], "%Y-%m-%dT%H:%M:%S"
)
if offerDeparture > latestDeparture:
... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/flight_search.html |
8bb4d6faf9ec-0 | Source code for langchain.tools.wikipedia.tool
"""Tool for the Wikipedia API."""
from typing import Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.base import BaseTool
from langchain.utilities.wikipedia import WikipediaAPIWrapper
[docs]class WikipediaQueryRun(BaseTool):
... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/wikipedia/tool.html |
5fe15d3b6404-0 | Source code for langchain.tools.ddg_search.tool
"""Tool for the DuckDuckGo search API."""
import warnings
from typing import Any, Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.base import BaseTool
from langchain.u... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ddg_search/tool.html |
5fe15d3b6404-1 | "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(
default_factory=DuckDuckGoSearchAPIWrapper
)
backend: str = "api... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ddg_search/tool.html |
54cc83b52a55-0 | Source code for langchain.tools.zapier.tool
"""[DEPRECATED]
## Zapier Natural Language Actions API
\
Full docs here: https://nla.zapier.com/start/
**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 Gmai... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html |
54cc83b52a55-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/docs/authen... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html |
54cc83b52a55-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... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html |
54cc83b52a55-3 | zapier_description: str
params_schema: Dict[str, str] = Field(default_factory=dict)
name: str = ""
description: str = ""
@root_validator
def set_name_description(cls, values: Dict[str, Any]) -> Dict[str, Any]:
zapier_description = values["zapier_description"]
params_schema = values["... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html |
54cc83b52a55-4 | async def _arun(
self,
instructions: str,
run_manager: Optional[AsyncCallbackManagerForToolRun] = None,
) -> str:
"""Use the Zapier NLA tool to return a list of all exposed user actions."""
warn_deprecated(
since="0.0.319",
message=(
"T... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html |
54cc83b52a55-5 | "This tool will be deprecated on 2023-11-17. See "
"https://nla.zapier.com/sunset/ for details"
),
)
return self.api_wrapper.list_as_str()
async def _arun(
self,
_: str = "",
run_manager: Optional[AsyncCallbackManagerForToolRun] = None,
) -> st... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html |
f20d73799131-0 | Source code for langchain.tools.human.tool
"""Tool for asking human input."""
from typing import Callable, Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import Field
from langchain.tools.base import BaseTool
def _print_func(text: str) -> None:
print("\n")
... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/human/tool.html |
7c3dd439a675-0 | Source code for langchain.tools.google_scholar.tool
"""Tool for the Google Scholar"""
from typing import Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.base import BaseTool
from langchain.utilities.google_scholar import GoogleScholarAPIWrapper
[docs]class GoogleScholarQu... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/google_scholar/tool.html |
e427bc56e571-0 | Source code for langchain.tools.openweathermap.tool
"""Tool for the OpenWeatherMap API."""
from typing import Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import Field
from langchain.tools.base import BaseTool
from langchain.utilities.openweathermap import OpenWe... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/openweathermap/tool.html |
1fdc82817ead-0 | Source code for langchain.tools.github.tool
"""
This tool allows agents to interact with the pygithub library
and operate on a GitHub repository.
To use this tool, you must first set as environment variables:
GITHUB_API_TOKEN
GITHUB_REPOSITORY -> format: {owner}/{repo}
"""
from typing import Optional
from langc... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/github/tool.html |
4095470d038f-0 | Source code for langchain.tools.bing_search.tool
"""Tool for the Bing search API."""
from typing import Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.base import BaseTool
from langchain.utilities.bing_search import BingSearchAPIWrapper
[docs]class BingSearchRun(BaseTool... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/bing_search/tool.html |
585f35aaaa0e-0 | Source code for langchain.tools.file_management.delete
import os
from typing import Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.base import BaseTool
from langchain.tools.file_management.utils import (
INVALI... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/delete.html |
a67ad6ada9db-0 | Source code for langchain.tools.file_management.file_search
import fnmatch
import os
from typing import Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.base import BaseTool
from langchain.tools.file_management.utils... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/file_search.html |
a67ad6ada9db-1 | relative_path = os.path.relpath(absolute_path, dir_path_)
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:
... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/file_search.html |
5c54631c0afc-0 | Source code for langchain.tools.file_management.write
from typing import Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.base import BaseTool
from langchain.tools.file_management.utils import (
INVALID_PATH_TEMP... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/write.html |
5c54631c0afc-1 | except Exception as e:
return "Error: " + str(e)
# TODO: Add aiofiles method | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/write.html |
4ba36ae3e0b2-0 | Source code for langchain.tools.file_management.move
import shutil
from typing import Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.base import BaseTool
from langchain.tools.file_management.utils import (
INVA... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/move.html |
4ba36ae3e0b2-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)
# TODO: Add aiofiles method | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/move.html |
f67ed732d2ea-0 | Source code for langchain.tools.file_management.list_dir
import os
from typing import Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.base import BaseTool
from langchain.tools.file_management.utils import (
INVA... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/list_dir.html |
166782aea96a-0 | Source code for langchain.tools.file_management.utils
import sys
from pathlib import Path
from typing import Optional
from langchain.pydantic_v1 import BaseModel
[docs]def is_relative_to(path: Path, root: Path) -> bool:
"""Check if path is relative to root."""
if sys.version_info >= (3, 9):
# No need fo... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/utils.html |
166782aea96a-1 | root = root.resolve()
full_path = (root / user_path).resolve()
if not is_relative_to(full_path, root):
raise FileValidationError(
f"Path {user_path} is outside of the allowed directory {root}"
)
return full_path | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/utils.html |
1a3199e458f9-0 | Source code for langchain.tools.file_management.read
from typing import Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.base import BaseTool
from langchain.tools.file_management.utils import (
INVALID_PATH_TEMPL... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/read.html |
874b6e505903-0 | Source code for langchain.tools.file_management.copy
import shutil
from typing import Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.base import BaseTool
from langchain.tools.file_management.utils import (
INVA... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/copy.html |
874b6e505903-1 | except Exception as e:
return "Error: " + str(e)
# TODO: Add aiofiles method | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/copy.html |
bc307d7725e4-0 | Source code for langchain.tools.golden_query.tool
"""Tool for the Golden API."""
from typing import Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.base import BaseTool
from langchain.utilities.golden_query import GoldenQueryAPIWrapper
[docs]class GoldenQueryRun(BaseTool)... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/golden_query/tool.html |
84959a5700b8-0 | Source code for langchain.tools.graphql.tool
import json
from typing import Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.base import BaseTool
from langchain.utilities.graphql import GraphQLAPIWrapper
[docs]class BaseGraphQLTool(BaseTool):
"""Base tool for querying ... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/graphql/tool.html |
fe0eaa926e54-0 | Source code for langchain.tools.pubmed.tool
from typing import Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import Field
from langchain.tools.base import BaseTool
from langchain.utilities.pubmed import PubMedAPIWrapper
[docs]class PubmedQueryRun(BaseTool):
""... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/pubmed/tool.html |
f480dfd9d7c7-0 | Source code for langchain.tools.clickup.tool
"""
This tool allows agents to interact with the clickup library
and operate on a Clickup instance.
To use this tool, you must first set as environment variables:
client_secret
client_id
code
Below is a sample script that uses the Clickup tool:
```python
from lan... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/clickup/tool.html |
66c7d766cd71-0 | Source code for langchain.tools.office365.events_search
"""Util that Searches calendar events in Office 365.
Free, but setup is required. See link below.
https://learn.microsoft.com/en-us/graph/auth/
"""
from datetime import datetime as dt
from typing import Any, Dict, List, Optional, Type
from langchain.callbacks.mana... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/office365/events_search.html |
66c7d766cd71-1 | " components, and the time zone offset is specified as ±hh:mm. "
' For example: "2023-06-09T10:30:00+03:00" represents June 9th, '
" 2023, at 10:30 AM in a time zone with a positive offset of 3 "
" hours from Coordinated Universal Time (UTC)."
)
)
max_results: int = F... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/office365/events_search.html |
66c7d766cd71-2 | extra = Extra.forbid
def _run(
self,
start_datetime: str,
end_datetime: str,
max_results: int = 10,
truncate: bool = True,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> List[Dict[str, Any]]:
TRUNCATE_LIMIT = 150
# Get calendar objec... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/office365/events_search.html |
66c7d766cd71-3 | "%Y-%m-%dT%H:%M:%S%z"
)
output_event["end_datetime"] = event.end.astimezone(time_zone).strftime(
"%Y-%m-%dT%H:%M:%S%z"
)
output_event["modified_date"] = event.modified.astimezone(
time_zone
).strftime("%Y-%m-%dT%H:%M:%S%z")
... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/office365/events_search.html |
fa91763b4587-0 | Source code for langchain.tools.office365.messages_search
"""Util that Searches email messages in Office 365.
Free, but setup is required. See link below.
https://learn.microsoft.com/en-us/graph/auth/
"""
from typing import Any, Dict, List, Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRu... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/office365/messages_search.html |
fa91763b4587-1 | "range example: received:2023-06-08..2023-06-09 matching example: "
"from:amy OR from:david."
)
)
max_results: int = Field(
default=10,
description="The maximum number of results to return.",
)
truncate: bool = Field(
default=True,
description=(
... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/office365/messages_search.html |
fa91763b4587-2 | if folder != "":
mailbox = mailbox.get_folder(folder_name=folder)
# Retrieve messages based on query
query = mailbox.q().search(query)
messages = mailbox.get_messages(limit=max_results, query=query)
# Generate output dict
output_messages = []
for message in me... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/office365/messages_search.html |
1c0a809e75b0-0 | Source code for langchain.tools.office365.base
"""Base class for Office 365 tools."""
from __future__ import annotations
from typing import TYPE_CHECKING
from langchain.pydantic_v1 import Field
from langchain.tools.base import BaseTool
from langchain.tools.office365.utils import authenticate
if TYPE_CHECKING:
from ... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/office365/base.html |
ffb82181d36e-0 | Source code for langchain.tools.office365.utils
"""O365 tool utils."""
from __future__ import annotations
import logging
import os
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from O365 import Account
logger = logging.getLogger(__name__)
[docs]def clean_body(body: str) -> str:
"""Clean body of a message o... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/office365/utils.html |
ffb82181d36e-1 | if account.is_authenticated is False:
if not account.authenticate(
scopes=[
"https://graph.microsoft.com/Mail.ReadWrite",
"https://graph.microsoft.com/Mail.Send",
"https://graph.microsoft.com/Calendars.ReadWrite",
"https://graph.microso... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/office365/utils.html |
e5746c0d3b5b-0 | Source code for langchain.tools.office365.send_message
from typing import List, Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.office365.base import O365BaseTool
[docs]class SendMessageSchema(BaseModel):
"""Inp... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/office365/send_message.html |
e5746c0d3b5b-1 | # Assign message values
message.body = body
message.subject = subject
message.to.add(to)
if cc is not None:
message.cc.add(cc)
if bcc is not None:
message.bcc.add(cc)
message.send()
output = "Message sent: " + str(message)
return ou... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/office365/send_message.html |
018b3b4bea7c-0 | Source code for langchain.tools.office365.create_draft_message
from typing import List, Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.office365.base import O365BaseTool
[docs]class CreateDraftMessageSchema(BaseMod... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/office365/create_draft_message.html |
018b3b4bea7c-1 | message = mailbox.new_message()
# Assign message values
message.body = body
message.subject = subject
message.to.add(to)
if cc is not None:
message.cc.add(cc)
if bcc is not None:
message.bcc.add(cc)
message.save_draft()
output = "Dr... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/office365/create_draft_message.html |
473cac5b30ed-0 | Source code for langchain.tools.office365.send_event
"""Util that sends calendar events in Office 365.
Free, but setup is required. See link below.
https://learn.microsoft.com/en-us/graph/auth/
"""
from datetime import datetime as dt
from typing import List, Optional, Type
from langchain.callbacks.manager import Callba... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/office365/send_event.html |
473cac5b30ed-1 | " components, and the time zone offset is specified as ±hh:mm. "
' For example: "2023-06-09T10:30:00+03:00" represents June 9th, '
" 2023, at 10:30 AM in a time zone with a positive offset of 3 "
" hours from Coordinated Universal Time (UTC).",
)
[docs]class O365SendEvent(O365BaseTool):
... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/office365/send_event.html |
2c4c72925337-0 | Source code for langchain.tools.eleven_labs.text2speech
import tempfile
from enum import Enum
from typing import Any, Dict, Optional, Union
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import root_validator
from langchain.tools.base import BaseTool
from langchain.utils im... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/eleven_labs/text2speech.html |
2c4c72925337-1 | """Validate that api key exists in environment."""
_ = get_from_dict_or_env(values, "eleven_api_key", "ELEVEN_API_KEY")
return values
def _run(
self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None
) -> str:
"""Use the tool."""
elevenlabs = _import_ele... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/eleven_labs/text2speech.html |
4cc0aba8d2e7-0 | Source code for langchain.tools.eleven_labs.models
from enum import Enum
[docs]class ElevenLabsModel(str, Enum):
"""Models available for Eleven Labs Text2Speech."""
MULTI_LINGUAL = "eleven_multilingual_v1"
MONO_LINGUAL = "eleven_monolingual_v1" | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/eleven_labs/models.html |
1479ae1a8dcf-0 | Source code for langchain.tools.scenexplain.tool
"""Tool for the SceneXplain API."""
from typing import Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.base import BaseTool
from langchain.utilities.scenexplain import Scen... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/scenexplain/tool.html |
36e82d8d2372-0 | Source code for langchain.tools.memorize.tool
from abc import abstractmethod
from typing import Any, Optional, Protocol, Sequence, runtime_checkable
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.llms.gradient_ai import TrainResult
from lang... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/memorize/tool.html |
36e82d8d2372-1 | async def _arun(
self,
information_to_learn: str,
run_manager: Optional[AsyncCallbackManagerForToolRun] = None,
) -> str:
train_result = await self.llm.atrain_unsupervised((information_to_learn,))
return f"Train complete. Loss: {train_result['loss']}" | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/memorize/tool.html |
7fa35eda7111-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... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/steamship_image_generation/tool.html |
7fa35eda7111-1 | "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 = values["size"]
model_name = values["model_name"]
if si... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/steamship_image_generation/tool.html |
7fa35eda7111-2 | 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
raise RuntimeError(f"[{self.name}] Tool unable to generate image!") | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/steamship_image_generation/tool.html |
ec14b03036ee-0 | Source code for langchain.tools.steamship_image_generation.utils
"""Steamship Utils."""
from __future__ import annotations
import uuid
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from steamship import Block, Steamship
[docs]def make_image_public(client: Steamship, block: Block) -> str:
"""Upload a block ... | lang/api.python.langchain.com/en/latest/_modules/langchain/tools/steamship_image_generation/utils.html |
42f369046712-0 | Source code for langchain.indexes.vectorstore
from typing import Any, Dict, List, Optional, Type
from langchain.chains.qa_with_sources.retrieval import RetrievalQAWithSourcesChain
from langchain.chains.retrieval_qa.base import RetrievalQA
from langchain.document_loaders.base import BaseLoader
from langchain.embeddings.... | lang/api.python.langchain.com/en/latest/_modules/langchain/indexes/vectorstore.html |
42f369046712-1 | )
return chain.run(question)
[docs] def query_with_sources(
self,
question: str,
llm: Optional[BaseLanguageModel] = None,
retriever_kwargs: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> dict:
"""Query the vectorstore and get back sources."""
... | lang/api.python.langchain.com/en/latest/_modules/langchain/indexes/vectorstore.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.