id stringlengths 14 15 | text stringlengths 49 2.47k | source stringlengths 61 166 |
|---|---|---|
3352bfa08017-1 | end_published_date,
use_autoprompt,
)
except Exception as e:
return repr(e)
async def _arun(
self,
query: str,
num_results: int,
include_domains: Optional[List[str]] = None,
exclude_domains: Optional[List[str]] = None,
s... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/metaphor_search/tool.html |
e4bf285781f9-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
from pydantic import Field, root_validator
from langchain.callbacks.manager imp... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/python/tool.html |
e4bf285781f9-1 | sanitize_input: bool = True
def _run(
self,
query: str,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> Any:
"""Use the tool."""
if self.sanitize_input:
query = sanitize_input(query)
return self.python_repl.run(query)
async def _arun(... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/python/tool.html |
e4bf285781f9-2 | "(as it uses new functionality in the `ast` module, "
f"you have Python version: {sys.version}"
)
return values
def _run(
self,
query: str,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> str:
"""Use the tool."""
try:
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/python/tool.html |
461e8dec0b59-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 |
fc27832111a4-0 | Source code for langchain.tools.spark_sql.tool
# flake8: noqa
"""Tools for interacting with Spark SQL."""
from typing import Any, Dict, Optional
from pydantic import BaseModel, Extra, Field, root_validator
from langchain.schema.language_model import BaseLanguageModel
from langchain.callbacks.manager import (
AsyncC... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/spark_sql/tool.html |
fc27832111a4-1 | """Execute the query, return the results or an error message."""
return self.db.run_no_throw(query)
[docs]class InfoSparkSQLTool(BaseSparkSQLTool, BaseTool):
"""Tool for getting metadata about a Spark SQL."""
name = "schema_sql_db"
description = """
Input to this tool is a comma-separated list o... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/spark_sql/tool.html |
fc27832111a4-2 | template: str = QUERY_CHECKER
llm: BaseLanguageModel
llm_chain: LLMChain = Field(init=False)
name = "query_checker_sql_db"
description = """
Use this tool to double check if your query is correct before executing it.
Always use this tool before executing a query with query_sql_db!
"""
@r... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/spark_sql/tool.html |
0ba7254bb42d-0 | Source code for langchain.tools.searx_search.tool
"""Tool for the SearxNG search API."""
from typing import Optional
from pydantic import Extra
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.tools.base import BaseTool, Field
from langchain.u... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/searx_search/tool.html |
0ba7254bb42d-1 | )
wrapper: SearxSearchWrapper
num_results: int = 4
kwargs: dict = Field(default_factory=dict)
class Config:
"""Pydantic config."""
extra = Extra.allow
def _run(
self,
query: str,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> str:
""... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/searx_search/tool.html |
87deebcfe06f-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 CallbackManagerForToolRun
from langchain.tools.base import BaseTool
from langchain.utilities.duckduckgo_search imp... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ddg_search/tool.html |
87deebcfe06f-1 | )
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)
res_strs = [", ".join([f"{k}: {v}" for k, v ... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/ddg_search/tool.html |
3d38bb12bc61-0 | Source code for langchain.tools.multion.create_session
from typing import TYPE_CHECKING, Optional, Type
from pydantic import BaseModel, Field
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.base import BaseTool
if TYPE_CHECKING:
# This is for linting and IDE typehints
impo... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/multion/create_session.html |
807816c19b62-0 | Source code for langchain.tools.multion.update_session
from typing import TYPE_CHECKING, Optional, Type
from pydantic import BaseModel, Field
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.base import BaseTool
if TYPE_CHECKING:
# This is for linting and IDE typehints
impo... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/multion/update_session.html |
807816c19b62-1 | ) -> dict:
try:
try:
response = multion.update_session(tabId, {"input": query, "url": url})
content = {"tabId": tabId, "Response": response["message"]}
self.tabId = tabId
return content
except Exception as e:
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/multion/update_session.html |
1e48bfe5d7c5-0 | Source code for langchain.tools.scenexplain.tool
"""Tool for the SceneXplain API."""
from typing import Optional
from pydantic import BaseModel, Field
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.base import BaseTool
from langchain.utilities.scenexplain import SceneXplainAPIWra... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/scenexplain/tool.html |
2ae1d795ad89-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 pydantic import Field, validator
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackMan... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html |
2ae1d795ad89-1 | """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 variables."""
for var... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html |
2ae1d795ad89-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 |
2ae1d795ad89-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 |
2ae1d795ad89-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 |
2ae1d795ad89-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 |
2ae1d795ad89-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 |
2ae1d795ad89-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 |
2e5c2a39148f-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 pydantic import BaseModel, Extra, Field, root_validator
from langchain.schema.language_model import BaseLanguageModel
from langchain.callbacks.manager import (
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/sql_database/tool.html |
2e5c2a39148f-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 = "sql_db_schema"
description = """
Input to this tool is a comma-separat... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/sql_database/tool.html |
2e5c2a39148f-2 | llm_chain: LLMChain = Field(init=False)
name = "sql_db_query_checker"
description = """
Use this tool to double check if your query is correct before executing it.
Always use this tool before executing a query with query_sql_db!
"""
@root_validator(pre=True)
def initialize_llm_chain(cls, val... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/sql_database/tool.html |
e823a0e55d9d-0 | Source code for langchain.tools.interaction.tool
"""Tools for interacting with the user."""
import warnings
from typing import Any
from langchain.tools.human.tool import HumanInputRun
[docs]def StdInInquireTool(*args: Any, **kwargs: Any) -> HumanInputRun:
"""Tool for asking the user for input."""
warnings.warn(... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/interaction/tool.html |
41472116445c-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 |
ddfa55cdf3ed-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://api.python.langchain.com/en/latest/_modules/langchain/tools/google_serper/tool.html |
ddfa55cdf3ed-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://api.python.langchain.com/en/latest/_modules/langchain/tools/google_serper/tool.html |
65f25a90a519-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 pydantic import BaseModel, Field
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/sleep/tool.html |
e147da7cec6e-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 CallbackManagerForToolRun
from langchain.tools.gmail.base import GmailBaseTool
[docs]class CreateD... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/create_draft.html |
e147da7cec6e-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://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/create_draft.html |
c0b262c85f5e-0 | Source code for langchain.tools.gmail.base
"""Base class for Gmail tools."""
from __future__ import annotations
from typing import TYPE_CHECKING
from pydantic import Field
from langchain.tools.base import BaseTool
from langchain.tools.gmail.utils import build_resource_service
if TYPE_CHECKING:
# This is for linting... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/base.html |
9d5457dfff1e-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, Union
from pydantic import BaseModel, Field
from langchain.callbacks.manager import CallbackManage... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/send_message.html |
9d5457dfff1e-1 | ) -> Dict[str, Any]:
"""Create a message for an email."""
mime_message = MIMEMultipart()
mime_message.attach(MIMEText(message, "html"))
mime_message["To"] = ", ".join(to if isinstance(to, list) else [to])
mime_message["Subject"] = subject
if cc is not None:
mi... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/send_message.html |
344cccfe3f22-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 CallbackManagerForToolRun
from langchain.tools.gmail.base import GmailBaseTool
from langchain.tools.gmail.utils import clean_... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/get_message.html |
344cccfe3f22-1 | "id": message_id,
"threadId": message_data["threadId"],
"snippet": message_data["snippet"],
"body": body,
"subject": subject,
"sender": sender,
} | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/get_message.html |
1717cc1c9d42-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 CallbackManagerForToolRun
from langchain.tools.gmail.base import GmailBaseTool
[docs]class GetThreadSchema(BaseModel):
"""Input for GetMessageTool.""... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/get_thread.html |
15000138ca1a-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 CallbackManagerForToolRun
from langchain.tools.gmail.base import GmailBaseTool
from langchain.too... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/search.html |
15000138ca1a-1 | """Tool that searches for messages or threads in Gmail."""
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: Typ... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/search.html |
15000138ca1a-2 | sender = email_msg["From"]
message_body = email_msg.get_payload()
body = clean_email_body(message_body)
results.append(
{
"id": message["id"],
"threadId": message_data["threadId"],
"snippet": message_data["sn... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/search.html |
0a1bdf20ace3-0 | Source code for langchain.tools.gmail.utils
"""Gmail tool utils."""
from __future__ import annotations
import logging
import os
from typing import TYPE_CHECKING, List, Optional, Tuple
if TYPE_CHECKING:
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from ... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/utils.html |
0a1bdf20ace3-1 | """Import googleapiclient.discovery.build function.
Returns:
build_resource: googleapiclient.discovery.build function.
"""
try:
from googleapiclient.discovery import build
except ImportError:
raise ImportError(
"You need to install googleapiclient to use this toolkit.... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/utils.html |
0a1bdf20ace3-2 | creds.refresh(Request())
else:
# https://developers.google.com/gmail/api/quickstart/python#authorize_credentials_for_a_desktop_application # noqa
flow = InstalledAppFlow.from_client_secrets_file(
client_secrets_file, scopes
)
creds = flow.run_local... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/utils.html |
4b7f940ee711-0 | Source code for langchain.tools.pubmed.tool
from typing import Optional
from pydantic import Field
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.base import BaseTool
from langchain.utilities.pubmed import PubMedAPIWrapper
[docs]class PubmedQueryRun(BaseTool):
"""Tool that se... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/pubmed/tool.html |
78e847e0782e-0 | Source code for langchain.tools.zapier.tool
"""## 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 Gmail, Salesforce... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html |
78e847e0782e-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html |
78e847e0782e-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://api.python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html |
78e847e0782e-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://api.python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html |
78e847e0782e-4 | )
ZapierNLARunAction.__doc__ = (
ZapierNLAWrapper.run.__doc__ + ZapierNLARunAction.__doc__ # type: ignore
)
# other useful actions
[docs]class ZapierNLAListActions(BaseTool):
"""
Args:
None
"""
name = "ZapierNLA_list_actions"
description = BASE_ZAPIER_TOOL_PROMPT + (
"This tool ... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html |
234534f5bd8d-0 | Source code for langchain.tools.arxiv.tool
"""Tool for the Arxiv API."""
from typing import Optional
from pydantic import Field
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.base import BaseTool
from langchain.utilities.arxiv import ArxivAPIWrapper
[docs]class ArxivQueryRun(Base... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/arxiv/tool.html |
fbdcc299525f-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/google_search/tool.html |
5e586f86b97b-0 | Source code for langchain.tools.dataforseo_api_search.tool
"""Tool for the DataForSeo SERP API."""
from typing import Optional
from pydantic.fields import Field
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.tools.base import BaseTool
from l... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/dataforseo_api_search/tool.html |
5e586f86b97b-1 | "or popular searches."
"The input should be a search query and the output is a JSON object "
"of the query results."
)
api_wrapper: DataForSeoAPIWrapper = Field(default_factory=DataForSeoAPIWrapper)
def _run(
self,
query: str,
run_manager: Optional[CallbackManagerForT... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/dataforseo_api_search/tool.html |
14b00517394a-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.callbacks.manager import CallbackManagerForToolRun
from langchain.chains import RetrievalQA, RetrievalQAWithSourcesChain... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/vectorstore/tool.html |
14b00517394a-1 | 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, callbacks=run_manager.get_child() if run_manager else Non... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/vectorstore/tool.html |
783d462a821a-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 CallbackManagerForToolRun
from langchain.tools.azure_cognitive_services.ut... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/speech2text.html |
783d462a821a-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 |
783d462a821a-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 |
75c751dace3c-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 CallbackManagerForToolRun
from langchain.tools.azure_cognitive_services.util... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html |
75c751dace3c-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 |
75c751dace3c-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 |
75c751dace3c-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 |
f4485cb35fa8-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 CallbackManagerForToolRun
from langchain.tools.base import BaseTool
fr... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/text2speech.html |
f4485cb35fa8-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 |
f4485cb35fa8-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 |
30a6843c569e-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 CallbackManagerForToolRun
from langchain.tools.azure_cognitive_services.utils impor... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/image_analysis.html |
30a6843c569e-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 |
30a6843c569e-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 |
30a6843c569e-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 |
cf28ef42a294-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 |
6ad2645c14ed-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 CallbackManagerForToolRun
from langchain.tools.base import BaseTool
from langchain.utilities import OpenWeatherMapAPIWrapper
[docs]cla... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/openweathermap/tool.html |
db7edddeb52b-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 pydan... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/github/tool.html |
f4e1ab1762d9-0 | Source code for langchain.tools.json.tool
# flake8: noqa
"""Tools for working with JSON specs."""
from __future__ import annotations
import json
import re
from pathlib import Path
from typing import Dict, List, Optional, Union
from pydantic import BaseModel
from langchain.callbacks.manager import (
AsyncCallbackMan... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/json/tool.html |
f4e1ab1762d9-1 | try:
items = _parse_input(text)
val = self.dict_
for i in items:
if i:
val = val[i]
if not isinstance(val, dict):
raise ValueError(
f"Value at path `{text}` is not a dict, get the value directly."
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/json/tool.html |
f4e1ab1762d9-2 | """
spec: JsonSpec
def _run(
self,
tool_input: str,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> str:
return self.spec.keys(tool_input)
async def _arun(
self,
tool_input: str,
run_manager: Optional[AsyncCallbackManagerForToolRun] =... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/json/tool.html |
f320f1a23702-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 |
631a079fdab0-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 |
2ed320fee9a2-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://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html |
2ed320fee9a2-1 | )
SCHEMA_TYPE = Union[str, Type, tuple, None, Enum]
[docs]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 P... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html |
2ed320fee9a2-2 | type_ = schema.type
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"{p... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html |
2ed320fee9a2-3 | else:
# Directly use the primitive type
pass
else:
raise NotImplementedError(f"Unsupported type: {schema_type}")
return schema_type
@staticmethod
def _validate_location(location: APIPropertyLocation, name: str) -> None:
if location not in SUPPO... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html |
2ed320fee9a2-4 | schema = cls._get_schema(parameter, spec)
schema_type = cls._get_schema_type(parameter, schema)
default_val = schema.default if schema is not None else None
return cls(
name=parameter.name,
location=location,
default=default_val,
description=parame... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html |
2ed320fee9a2-5 | required=prop_name in required_props,
spec=spec,
references_used=references_used,
)
)
return schema.type, properties
@classmethod
def _process_array_schema(
cls, schema: Schema, name: str, spec: OpenAPISpec, references_used: Lis... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html |
2ed320fee9a2-6 | schema, spec, references_used
)
elif schema_type == "array":
schema_type = cls._process_array_schema(schema, name, spec, references_used)
elif schema_type in PRIMITIVE_TYPES:
# Use the primitive type directly
pass
elif schema_type is None:
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html |
2ed320fee9a2-7 | f"Could not resolve schema for media type: {media_type_obj}"
)
api_request_body_properties = []
required_properties = schema.required or []
if schema.type == "object" and schema.properties:
for prop_name, prop_schema in schema.properties.items():
if isinst... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html |
2ed320fee9a2-8 | operation_id: str = Field(alias="operation_id")
"""The unique identifier of the operation."""
description: Optional[str] = Field(alias="description")
"""The description of the operation."""
base_url: str = Field(alias="base_url")
"""The base URL of the operation."""
path: str = Field(alias="path... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html |
2ed320fee9a2-9 | def from_openapi_url(
cls,
spec_url: str,
path: str,
method: str,
) -> "APIOperation":
"""Create an APIOperation from an OpenAPI URL."""
spec = OpenAPISpec.from_url(spec_url)
return cls.from_openapi_spec(spec, path, method)
[docs] @classmethod
def from_... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html |
2ed320fee9a2-10 | # parsing specs that are < v3
return "any"
elif isinstance(type_, str):
return {
"str": "string",
"integer": "number",
"float": "number",
"date-time": "string",
}.get(type_, type_)
elif isinstance(type_, ... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html |
2ed320fee9a2-11 | if self.request_body:
formatted_request_body_props = self._format_nested_properties(
self.request_body.properties
)
params.append(formatted_request_body_props)
for prop in self.properties:
prop_name = prop.name
prop_type = self.ts_type_... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html |
f42f227bb121-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://api.python.langchain.com/en/latest/_modules/langchain/tools/shell/tool.html |
f42f227bb121-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 |
6cb6fc088dce-0 | Source code for langchain.tools.amadeus.base
"""Base class for Amadeus tools."""
from __future__ import annotations
from typing import TYPE_CHECKING
from pydantic import Field
from langchain.tools.amadeus.utils import authenticate
from langchain.tools.base import BaseTool
if TYPE_CHECKING:
from amadeus import Clien... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/base.html |
080877edc1ee-0 | Source code for langchain.tools.amadeus.flight_search
import logging
from datetime import datetime as dt
from typing import Dict, Optional, Type
from pydantic import BaseModel, Field
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.amadeus.base import AmadeusBaseTool
logger = loggi... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/flight_search.html |
080877edc1ee-1 | " 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 for searching for a single flight between two airports."""
name: str = "... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/flight_search.html |
080877edc1ee-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 |
080877edc1ee-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 |
6a6d48ea842e-0 | Source code for langchain.tools.amadeus.closest_airport
from typing import Optional, Type
from pydantic import BaseModel, Field
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.chains import LLMChain
from langchain.chat_models import ChatOpenAI
from langchain.tools.amadeus.base import Am... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/amadeus/closest_airport.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.