id stringlengths 14 15 | text stringlengths 44 2.47k | source stringlengths 61 181 |
|---|---|---|
ed1117263049-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/wolfram_alpha/tool.html |
e2e6ba16917f-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")
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/human/tool.html |
1b636638737b-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/searx_search/tool.html |
1b636638737b-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."""
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/searx_search/tool.html |
4af5417870c5-0 | Source code for langchain.tools.nuclia.tool
"""Tool for the Nuclia Understanding API.
Installation:
```bash
pip install --upgrade protobuf
pip install nucliadb-protos
```
"""
import asyncio
import base64
import logging
import mimetypes
import os
from typing import Any, Dict, Optional, Type, Union
import request... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/nuclia/tool.html |
4af5417870c5-1 | """Tool to process files with the Nuclia Understanding API."""
name: str = "nuclia_understanding_api"
description: str = (
"A wrapper around Nuclia Understanding API endpoints. "
"Useful for when you need to extract text from any kind of files. "
)
args_schema: Type[BaseModel] = NUASchem... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/nuclia/tool.html |
4af5417870c5-2 | self,
action: str,
id: str,
path: Optional[str] = None,
text: Optional[str] = None,
run_manager: Optional[AsyncCallbackManagerForToolRun] = None,
) -> str:
"""Use the tool asynchronously."""
self._check_params(path, text)
if path:
self._pus... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/nuclia/tool.html |
4af5417870c5-3 | )
return ""
else:
field = {
"filefield": {"file": f"{response.text}"},
"processing_options": {"ml_text": self._config["enable_ml"]},
}
return self._pushField(id, field)
def _pushField(self, id: str, f... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/nuclia/tool.html |
4af5417870c5-4 | try:
from nucliadb_protos.writer_pb2 import BrokerMessage
except ImportError as e:
raise ImportError(
"nucliadb-protos is not installed. "
"Run `pip install nucliadb-protos` to install."
) from e
try:
from google.protobuf.js... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/nuclia/tool.html |
4af5417870c5-5 | if result["uuid"] == uuid:
return id
return None
def _check_params(self, path: Optional[str], text: Optional[str]) -> None:
if not path and not text:
raise ValueError("File path or text is required")
if path and text:
raise ValueError("Cannot process b... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/nuclia/tool.html |
7aa64b0e8cb6-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gitlab/tool.html |
9c3a4200f388-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 ... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/graphql/tool.html |
0aa1d1d2bcc7-0 | Source code for langchain.tools.sql_database.tool
# flake8: noqa
"""Tools for interacting with a SQL database."""
from typing import Any, Dict, Optional
from langchain.pydantic_v1 import BaseModel, Extra, Field, root_validator
from langchain.schema.language_model import BaseLanguageModel
from langchain.callbacks.manage... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/sql_database/tool.html |
0aa1d1d2bcc7-1 | """Execute the query, return the results or an error message."""
return self.db.run_no_throw(query)
[docs]class InfoSQLDatabaseTool(BaseSQLDatabaseTool, BaseTool):
"""Tool for getting metadata about a SQL database."""
name: str = "sql_db_schema"
description: str = """
Input to this tool is a com... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/sql_database/tool.html |
0aa1d1d2bcc7-2 | template: str = QUERY_CHECKER
llm: BaseLanguageModel
llm_chain: LLMChain = Field(init=False)
name: str = "sql_db_query_checker"
description: str = """
Use this tool to double check if your query is correct before executing it.
Always use this tool before executing a query with sql_db_query!
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/sql_database/tool.html |
0aa1d1d2bcc7-3 | query=query,
dialect=self.db.dialect,
callbacks=run_manager.get_child() if run_manager else None,
) | https://api.python.langchain.com/en/latest/_modules/langchain/tools/sql_database/tool.html |
4f3747990d76-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 ... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/steamship_image_generation/utils.html |
73c1ef07edc5-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://api.python.langchain.com/en/latest/_modules/langchain/tools/steamship_image_generation/tool.html |
73c1ef07edc5-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/steamship_image_generation/tool.html |
73c1ef07edc5-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!") | https://api.python.langchain.com/en/latest/_modules/langchain/tools/steamship_image_generation/tool.html |
f084f7adf6ac-0 | Source code for langchain.tools.powerbi.tool
"""Tools for interacting with a Power BI dataset."""
import logging
from time import perf_counter
from typing import Any, Dict, Optional, Tuple
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.chain... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html |
f084f7adf6ac-1 | class Config:
"""Configuration for this pydantic object."""
arbitrary_types_allowed = True
@validator("llm_chain")
def validate_llm_chain_input_variables( # pylint: disable=E0213
cls, llm_chain: LLMChain
) -> LLMChain:
"""Make sure the LLM chain has the correct input variabl... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html |
f084f7adf6ac-2 | query = self.llm_chain.predict(
tool_input=tool_input,
tables=self.powerbi.get_table_names(),
schemas=self.powerbi.get_schemas(),
examples=self.examples,
callbacks=run_manager.get_child() if run_manager else None,
)
exce... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html |
f084f7adf6ac-3 | result if result else BAD_REQUEST_RESPONSE.format(error=error)
)
return self.session_cache[tool_input]
async def _arun(
self,
tool_input: str,
run_manager: Optional[AsyncCallbackManagerForToolRun] = None,
**kwargs: Any,
) -> str:
"""Execute the query, retu... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html |
f084f7adf6ac-4 | result, error = self._parse_output(pbi_result)
if error is not None and ("TokenExpired" in error or "TokenError" in error):
self.session_cache[
tool_input
] = "Authentication token expired or invalid, please try to reauthenticate or check the scope of the credential." # ... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html |
f084f7adf6ac-5 | if too_long:
return (
f"Result too large, please try to be more specific or use the `TOPN` function. The result is {length} tokens long, the limit is {self.output_token_limit} tokens.", # noqa: E501
None,
)
return result, None
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html |
f084f7adf6ac-6 | powerbi: PowerBIDataset = Field(exclude=True)
class Config:
"""Configuration for this pydantic object."""
arbitrary_types_allowed = True
def _run(
self,
tool_input: str,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> str:
"""Get the schema for t... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html |
f084f7adf6ac-7 | ) -> str:
"""Get the names of the tables."""
return ", ".join(self.powerbi.get_table_names()) | https://api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html |
9405862ac3f4-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/bing_search/tool.html |
ed2436a417f0-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/github/tool.html |
7721fb5bb44c-0 | Source code for langchain.tools.jira.tool
"""
This tool allows agents to interact with the atlassian-python-api library
and operate on a Jira instance. For more information on the
atlassian-python-api library, see https://atlassian-python-api.readthedocs.io/jira.html
To use this tool, you must first set as environment ... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/jira/tool.html |
7721fb5bb44c-1 | ) -> str:
"""Use the Atlassian Jira API to run an operation."""
return self.api_wrapper.run(self.mode, instructions) | https://api.python.langchain.com/en/latest/_modules/langchain/tools/jira/tool.html |
6356f0c00943-0 | Source code for langchain.tools.python.tool
"""A tool for running python code in a REPL."""
import ast
import asyncio
import re
import sys
from contextlib import redirect_stdout
from io import StringIO
from typing import Any, Dict, Optional, Type
from langchain.callbacks.manager import (
AsyncCallbackManagerForTool... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/python/tool.html |
6356f0c00943-1 | python_repl: PythonREPL = Field(default_factory=_get_default_python_repl)
sanitize_input: bool = True
def _run(
self,
query: str,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> Any:
"""Use the tool."""
if self.sanitize_input:
query = sanitiz... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/python/tool.html |
6356f0c00943-2 | def validate_python_version(cls, values: Dict) -> Dict:
"""Validate valid python version."""
if sys.version_info < (3, 9):
raise ValueError(
"This tool relies on Python 3.9 or higher "
"(as it uses new functionality in the `ast` module, "
f"you... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/python/tool.html |
6356f0c00943-3 | ) -> Any:
"""Use the tool asynchronously."""
loop = asyncio.get_running_loop()
result = await loop.run_in_executor(None, self._run, query)
return result | https://api.python.langchain.com/en/latest/_modules/langchain/tools/python/tool.html |
b8d8ff6cdc74-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/utils.html |
b8d8ff6cdc74-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 | https://api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/utils.html |
5cdd66d8a93c-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/read.html |
043c9ac75940-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/write.html |
043c9ac75940-1 | except Exception as e:
return "Error: " + str(e)
# TODO: Add aiofiles method | https://api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/write.html |
d6484bdbd5ff-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/list_dir.html |
9989644ad91e-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/delete.html |
5f1a8c7e0402-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/copy.html |
5f1a8c7e0402-1 | except Exception as e:
return "Error: " + str(e)
# TODO: Add aiofiles method | https://api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/copy.html |
3e702f7eff46-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/file_search.html |
3e702f7eff46-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:
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/file_search.html |
a13af17a6bb8-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/move.html |
a13af17a6bb8-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 | https://api.python.langchain.com/en/latest/_modules/langchain/tools/file_management/move.html |
7699d13de0e5-0 | Source code for langchain.tools.shell.tool
import asyncio
import platform
import warnings
from typing import List, Optional, Type, Union
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import BaseModel, Field, root_validator
from ... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/shell/tool.html |
7699d13de0e5-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://api.python.langchain.com/en/latest/_modules/langchain/tools/shell/tool.html |
b6c1a8e0d511-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/closest_airport.html |
b6c1a8e0d511-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)... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/closest_airport.html |
12f273f1662d-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/utils.html |
0eb8874b4117-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/base.html |
314d6e0c295d-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/flight_search.html |
314d6e0c295d-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/flight_search.html |
314d6e0c295d-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, "
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/flight_search.html |
314d6e0c295d-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:
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/flight_search.html |
4fc176d11a1f-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/scenexplain/tool.html |
220beb0f9140-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):
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/wikipedia/tool.html |
101ae0279014-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/utils.html |
5897849b4f6c-0 | Source code for langchain.tools.azure_cognitive_services.image_analysis
from __future__ import annotations
import logging
from typing import Any, Dict, Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import root_validator
from langchain.tools.azure_cognitive_service... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/image_analysis.html |
5897849b4f6c-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://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/image_analysis.html |
5897849b4f6c-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://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/image_analysis.html |
5897849b4f6c-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}") | https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/image_analysis.html |
0c9afbf4f473-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_... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html |
0c9afbf4f473-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://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html |
0c9afbf4f473-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://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html |
0c9afbf4f473-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://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html |
7fb4ebb97a68-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 langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import root_validator
from langchain.tools.base impor... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/text2speech.html |
7fb4ebb97a68-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://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/text2speech.html |
7fb4ebb97a68-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://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/text2speech.html |
97968f4dbe63-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/speech2text.html |
97968f4dbe63-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://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/speech2text.html |
97968f4dbe63-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://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/speech2text.html |
d64f8eacfc8e-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/brave_search/tool.html |
f87def5a51c3-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)... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/golden_query/tool.html |
ae02ac58b730-0 | Source code for langchain.tools.ddg_search.tool
"""Tool for the DuckDuckGo search API."""
import warnings
from typing import Any, Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import Field
from langchain.tools.base import BaseTool
from langchain.utilities.duckduck... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ddg_search/tool.html |
ae02ac58b730-1 | default_factory=DuckDuckGoSearchAPIWrapper
)
backend: str = "api"
def _run(
self,
query: str,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> str:
"""Use the tool."""
res = self.api_wrapper.results(query, self.num_results, backend=self.backend)
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ddg_search/tool.html |
b607b701715a-0 | Source code for langchain.tools.ainetwork.transfer
import json
from typing import Optional, Type
from langchain.callbacks.manager import AsyncCallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.ainetwork.base import AINBaseTool
[docs]class TransferSchema(BaseModel):
add... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/transfer.html |
06b3ebc8c8e0-0 | Source code for langchain.tools.ainetwork.rule
import builtins
import json
from typing import Optional, Type
from langchain.callbacks.manager import AsyncCallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.ainetwork.base import AINBaseTool, OperationType
[docs]class RuleSch... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/rule.html |
06b3ebc8c8e0-1 | - path: /apps/langchain_project_1/$from/$to/$img
- eval: auth.addr===$from&&!getValue('/apps/image_db/'+$img)
## GET Example
- type: GET
- path: /apps/langchain_project_1
""" # noqa: E501
args_schema: Type[BaseModel] = RuleSchema
async def _arun(
self,
type: OperationType,
path: str,
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/rule.html |
d3c338174a31-0 | Source code for langchain.tools.ainetwork.utils
"""AINetwork Blockchain tool utils."""
from __future__ import annotations
import os
from typing import TYPE_CHECKING, Literal, Optional
if TYPE_CHECKING:
from ain.ain import Ain
[docs]def authenticate(network: Optional[Literal["mainnet", "testnet"]] = "testnet") -> Ai... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/utils.html |
d3c338174a31-1 | and "AIN_BLOCKCHAIN_ACCOUNT_PRIVATE_KEY" in os.environ
):
provider_url = os.environ["AIN_BLOCKCHAIN_PROVIDER_URL"]
chain_id = int(os.environ["AIN_BLOCKCHAIN_CHAIN_ID"])
private_key = os.environ["AIN_BLOCKCHAIN_ACCOUNT_PRIVATE_KEY"]
else:
raise EnvironmentE... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/utils.html |
5fefbd8f66e5-0 | Source code for langchain.tools.ainetwork.owner
import builtins
import json
from typing import List, Optional, Type, Union
from langchain.callbacks.manager import AsyncCallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.ainetwork.base import AINBaseTool, OperationType
[docs... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/owner.html |
5fefbd8f66e5-1 | - *: All addresses permitted
- Defaults to the current session's address
## SET
- `SET` alters permissions for specific addresses, while other addresses remain unaffected.
- When removing an address of `owner`, set all authorities for that address to false.
- message `write_owner permission evaluated false` if fail
###... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/owner.html |
5fefbd8f66e5-2 | address: {
"write_owner": write_owner or False,
"write_rule": write_rule or False,
"write_function": write_function or False,
"branch_owner": branch_owner or Fa... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/owner.html |
efef8fecb709-0 | Source code for langchain.tools.ainetwork.app
import builtins
import json
from enum import Enum
from typing import List, Optional, Type, Union
from langchain.callbacks.manager import AsyncCallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.ainetwork.base import AINBaseTool
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/app.html |
efef8fecb709-1 | 2. Current session's address registered as admin.
## SET_ADMIN Example 2
- type: SET_ADMIN
- appName: test_project
- address: [<address1>, <address2>]
### Result:
1. Path /apps/test_project created.
2. <address1> and <address2> registered as admin.
""" # noqa: E501
args_schema: Type[BaseModel] = AppSchema
asyn... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/app.html |
d02fc84769a0-0 | Source code for langchain.tools.ainetwork.base
"""Base class for AINetwork tools."""
from __future__ import annotations
import asyncio
import threading
from enum import Enum
from typing import TYPE_CHECKING, Any, Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 impor... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/base.html |
d02fc84769a0-1 | new_loop.close()
thread = threading.Thread(target=thread_target)
thread.start()
thread.join()
result = result_container[0]
if isinstance(result, Exception):
raise result
return result
else:
result = loop.run_unti... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/base.html |
f2c20f450b35-0 | Source code for langchain.tools.ainetwork.value
import builtins
import json
from typing import Optional, Type, Union
from langchain.callbacks.manager import AsyncCallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.ainetwork.base import AINBaseTool, OperationType
[docs]class... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/value.html |
f2c20f450b35-1 | - `/token/symbol`: Token symbol
- `/token/total_supply`: Token total supply
- `/transfer/<address from>/<address to>/<key>/value`: Transfer
- `/withdraw/<service id>/<address>/<withdraw id>`: Withdraw
"""
args_schema: Type[BaseModel] = ValueSchema
async def _arun(
self,
type: OperationType,
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/value.html |
e299fc1fc43c-0 | Source code for langchain.tools.sleep.tool
"""Tool for agent to sleep."""
from asyncio import sleep as asleep
from time import sleep
from typing import Optional, Type
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import BaseMode... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/sleep/tool.html |
c3b19ce59410-0 | Source code for langchain.tools.youtube.search
"""
Adapted from https://github.com/venuv/langchain_yt_tools
CustomYTSearchTool searches YouTube videos related to a person
and returns a specified number of video URLs.
Input to this tool should be a comma separated list,
- the first part contains a person name
- and th... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/youtube/search.html |
c3b19ce59410-1 | person = values[0]
if len(values) > 1:
num_results = int(values[1])
else:
num_results = 2
return self._search(person, num_results) | https://api.python.langchain.com/en/latest/_modules/langchain/tools/youtube/search.html |
01b74ded7868-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.... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/vectorstore/tool.html |
01b74ded7868-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/vectorstore/tool.html |
01b74ded7868-2 | chain(
{chain.question_key: query},
return_only_outputs=True,
callbacks=run_manager.get_child() if run_manager else None,
)
) | https://api.python.langchain.com/en/latest/_modules/langchain/tools/vectorstore/tool.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.