id stringlengths 14 15 | text stringlengths 44 2.47k | source stringlengths 61 181 |
|---|---|---|
6da3bd32939d-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" | https://api.python.langchain.com/en/latest/_modules/langchain/tools/eleven_labs/models.html |
585b614a0dd5-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/eleven_labs/text2speech.html |
585b614a0dd5-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/eleven_labs/text2speech.html |
cb6469a23cad-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 |
cb6469a23cad-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 |
cb6469a23cad-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 |
cb6469a23cad-3 | 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["params_schema"]
if "instructions" in params_schema:
del params_schema["i... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html |
cb6469a23cad-4 | )
ZapierNLARunAction.__doc__ = (
ZapierNLAWrapper.run.__doc__ + ZapierNLARunAction.__doc__ # type: ignore
)
# other useful actions
[docs]class ZapierNLAListActions(BaseTool):
"""
Args:
None
"""
name: str = "ZapierNLA_list_actions"
description: str = BASE_ZAPIER_TOOL_PROMPT + (
"... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/zapier/tool.html |
802a1b7e9a2c-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 |
802a1b7e9a2c-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 |
802a1b7e9a2c-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 |
bae7f12933de-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 langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/send_message.html |
bae7f12933de-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 |
a41ec0e2ac47-0 | Source code for langchain.tools.gmail.get_message
import base64
import email
from typing import Dict, Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.gmail.base import GmailBaseTool
from langchain.tools.gmail.utils ... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/get_message.html |
a41ec0e2ac47-1 | cdispo = str(part.get("Content-Disposition"))
if ctype == "text/plain" and "attachment" not in cdispo:
message_body = part.get_payload(decode=True).decode("utf-8")
break
else:
message_body = email_msg.get_payload(decode=True).decode("utf-8")
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/get_message.html |
dcdb9ac7e9f7-0 | Source code for langchain.tools.gmail.create_draft
import base64
from email.message import EmailMessage
from typing import List, Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.gmail.base import GmailBaseTool
[docs]... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/create_draft.html |
dcdb9ac7e9f7-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 |
91c9e347d034-0 | Source code for langchain.tools.gmail.base
"""Base class for Gmail 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.gmail.utils import build_resource_service
if TYPE_CHECKING:
# This i... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/base.html |
162307c58c51-0 | Source code for langchain.tools.gmail.get_thread
from typing import Dict, Optional, Type
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.gmail.base import GmailBaseTool
[docs]class GetThreadSchema(BaseModel):
"""Input for GetM... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/get_thread.html |
d36ebdf9b8d3-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 langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.gmail.base import GmailBaseTool
from ... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/search.html |
d36ebdf9b8d3-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 |
d36ebdf9b8d3-2 | message_body = ""
if email_msg.is_multipart():
for part in email_msg.walk():
ctype = part.get_content_type()
cdispo = str(part.get("Content-Disposition"))
if ctype == "text/plain" and "attachment" not in cdispo:
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/search.html |
b16519a0326f-0 | Source code for langchain.tools.playwright.extract_hyperlinks
from __future__ import annotations
import json
from typing import TYPE_CHECKING, Any, Optional, Type
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import BaseModel, F... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/extract_hyperlinks.html |
b16519a0326f-1 | soup = BeautifulSoup(html_content, "lxml")
# Find all the anchor elements and extract their href attributes
anchors = soup.find_all("a")
if absolute_urls:
base_url = page.url
links = [urljoin(base_url, anchor.get("href", "")) for anchor in anchors]
else:
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/extract_hyperlinks.html |
b5028f066bea-0 | Source code for langchain.tools.playwright.navigate_back
from __future__ import annotations
from typing import Optional, Type
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import BaseModel
from langchain.tools.playwright.base im... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/navigate_back.html |
b5028f066bea-1 | response = await page.go_back()
if response:
return (
f"Navigated back to the previous page with URL '{response.url}'."
f" Status code {response.status}"
)
else:
return "Unable to navigate back; no previous page in the history" | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/navigate_back.html |
366764b096d2-0 | Source code for langchain.tools.playwright.extract_text
from __future__ import annotations
from typing import Optional, Type
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import BaseModel, root_validator
from langchain.tools.pla... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/extract_text.html |
366764b096d2-1 | async def _arun(
self, run_manager: Optional[AsyncCallbackManagerForToolRun] = None
) -> str:
"""Use the tool."""
if self.async_browser is None:
raise ValueError(f"Asynchronous browser not provided to {self.name}")
# Use Beautiful Soup since it's faster than looping throu... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/extract_text.html |
28871d454f56-0 | Source code for langchain.tools.playwright.utils
"""Utilities for the Playwright browser tools."""
from __future__ import annotations
import asyncio
from typing import TYPE_CHECKING, Any, Coroutine, TypeVar
if TYPE_CHECKING:
from playwright.async_api import Browser as AsyncBrowser
from playwright.async_api impo... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/utils.html |
28871d454f56-1 | return context.pages[-1]
[docs]def create_async_playwright_browser(headless: bool = True) -> AsyncBrowser:
"""
Create an async playwright browser.
Args:
headless: Whether to run the browser in headless mode. Defaults to True.
Returns:
AsyncBrowser: The playwright browser.
"""
fro... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/utils.html |
4194ce50c4bb-0 | Source code for langchain.tools.playwright.get_elements
from __future__ import annotations
import json
from typing import TYPE_CHECKING, List, Optional, Sequence, Type
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import BaseMod... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/get_elements.html |
4194ce50c4bb-1 | page: SyncPage, selector: str, attributes: Sequence[str]
) -> List[dict]:
"""Get elements matching the given CSS selector."""
elements = page.query_selector_all(selector)
results = []
for element in elements:
result = {}
for attribute in attributes:
if attribute == "innerText... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/get_elements.html |
4194ce50c4bb-2 | ) -> str:
"""Use the tool."""
if self.async_browser is None:
raise ValueError(f"Asynchronous browser not provided to {self.name}")
page = await aget_current_page(self.async_browser)
# Navigate to the desired webpage before using this tool
results = await _aget_element... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/get_elements.html |
bb8d53a7a853-0 | Source code for langchain.tools.playwright.base
from __future__ import annotations
from typing import TYPE_CHECKING, Optional, Tuple, Type
from langchain.pydantic_v1 import root_validator
from langchain.tools.base import BaseTool
if TYPE_CHECKING:
from playwright.async_api import Browser as AsyncBrowser
from pl... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/base.html |
bb8d53a7a853-1 | raise ValueError("Either async_browser or sync_browser must be specified.")
return values
[docs] @classmethod
def from_browser(
cls,
sync_browser: Optional[SyncBrowser] = None,
async_browser: Optional[AsyncBrowser] = None,
) -> BaseBrowserTool:
"""Instantiate the tool.... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/base.html |
f64579f78a77-0 | Source code for langchain.tools.playwright.current_page
from __future__ import annotations
from typing import Optional, Type
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import BaseModel
from langchain.tools.playwright.base imp... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/current_page.html |
a6dc52799f09-0 | Source code for langchain.tools.playwright.navigate
from __future__ import annotations
from typing import Optional, Type
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.playwright.base ... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/navigate.html |
a6dc52799f09-1 | page = await aget_current_page(self.async_browser)
response = await page.goto(url)
status = response.status if response else "unknown"
return f"Navigating to {url} returned status code {status}" | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/navigate.html |
5375d52822af-0 | Source code for langchain.tools.playwright.click
from __future__ import annotations
from typing import Optional, Type
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools.playwright.base imp... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/click.html |
5375d52822af-1 | page = get_current_page(self.sync_browser)
# Navigate to the desired webpage before using this tool
selector_effective = self._selector_effective(selector=selector)
from playwright.sync_api import TimeoutError as PlaywrightTimeoutError
try:
page.click(
selecto... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/click.html |
c4f31b7abae1-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 langchain.pydantic_v1 import BaseModel
from langchain.callbacks.manager import (
Asy... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/json/tool.html |
c4f31b7abae1-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 di... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/json/tool.html |
c4f31b7abae1-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 |
8f7cf4d31dd2-0 | Source code for langchain.tools.google_serper.tool
"""Tool for the Serper.dev Google Search API."""
from typing import Optional
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import Field
from langchain.tools.base import BaseTool... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/google_serper/tool.html |
8f7cf4d31dd2-1 | "Input should be a search query. Output is a JSON object of the query results"
)
api_wrapper: GoogleSerperAPIWrapper = Field(default_factory=GoogleSerperAPIWrapper)
def _run(
self,
query: str,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> str:
"""Use the t... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/google_serper/tool.html |
07ac229952f4-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):
""... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/pubmed/tool.html |
bd53727bca4a-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 import OpenWeatherMapAPIWrap... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/openweathermap/tool.html |
1e63c185e60d-0 | Source code for langchain.tools.searchapi.tool
"""Tool for the SearchApi.io search API."""
from typing import Optional
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.pydantic_v1 import Field
from langchain.tools.base import BaseTool
from lan... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/searchapi/tool.html |
1e63c185e60d-1 | "with the query results."
)
api_wrapper: SearchApiAPIWrapper = Field(default_factory=SearchApiAPIWrapper)
def _run(
self,
query: str,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> str:
"""Use the tool."""
return str(self.api_wrapper.results(query))... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/searchapi/tool.html |
1aa553c9ace3-0 | Source code for langchain.tools.google_places.tool
"""Tool for the Google search 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.google_places... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/google_places/tool.html |
9bb7f9f6bd50-0 | Source code for langchain.tools.edenai.text_moderation
from __future__ import annotations
import logging
from typing import Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.edenai.edenai_base_tool import EdenaiTool
logger = logging.getLogger(__name__)
[docs]class EdenAiTex... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/text_moderation.html |
9bb7f9f6bd50-1 | )
language: str
feature: str = "text"
subfeature: str = "moderation"
def _parse_response(self, response: list) -> str:
formatted_result = []
for result in response:
if "nsfw_likelihood" in result.keys():
formatted_result.append(
"nsfw_likel... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/text_moderation.html |
b6d53db5f7cf-0 | Source code for langchain.tools.edenai.image_explicitcontent
from __future__ import annotations
import logging
from typing import Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.edenai.edenai_base_tool import EdenaiTool
logger = logging.getLogger(__name__)
[docs]class Ede... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/image_explicitcontent.html |
b6d53db5f7cf-1 | result_str += f"{idx}: {label} likelihood {likelihood},\n"
return result_str[:-2]
def _parse_response(self, json_data: list) -> str:
if len(json_data) == 1:
result = self._parse_json(json_data[0])
else:
for entry in json_data:
if entry.get("provider") ... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/image_explicitcontent.html |
d1a57614fe72-0 | Source code for langchain.tools.edenai.ocr_invoiceparser
from __future__ import annotations
import logging
from typing import Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.edenai.edenai_base_tool import EdenaiTool
logger = logging.getLogger(__name__)
[docs]class EdenAiP... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/ocr_invoiceparser.html |
d1a57614fe72-1 | )
else:
for entry in response:
if entry.get("provider") == "eden-ai":
self._parse_json_multilevel(
entry["extracted_data"][0], formatted_list
)
return "\n".join(formatted_list)
def _run(
self,
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/ocr_invoiceparser.html |
fd320bdc1f0a-0 | Source code for langchain.tools.edenai.edenai_base_tool
from __future__ import annotations
import logging
from abc import abstractmethod
from typing import Any, Dict, List, Optional
import requests
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import root_validator
from la... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/edenai_base_tool.html |
fd320bdc1f0a-1 | query_params (dict): The parameters to include in the API call.
Returns:
requests.Response: The response from the EdenAI API call.
"""
# faire l'API call
headers = {
"Authorization": f"Bearer {self.edenai_api_key}",
"User-Agent": self.get_user_agent(),... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/edenai_base_tool.html |
fd320bdc1f0a-2 | # not the provider response directly
provider_response = response.json()[0]
if provider_response.get("status") == "fail":
err_msg = provider_response["error"]["message"]
raise ValueError(err_msg)
@abstractmethod
def _run(
self, query: str, run_mana... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/edenai_base_tool.html |
fd320bdc1f0a-3 | self._parse_json_multilevel(subsections, formatted_list, level + 1)
def _list_handling(
self, subsection_list: list, formatted_list: list, level: int
) -> None:
for list_item in subsection_list:
if isinstance(list_item, dict):
self._parse_json_multilevel(list_item, fo... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/edenai_base_tool.html |
55ee274c2ec6-0 | Source code for langchain.tools.edenai.image_objectdetection
from __future__ import annotations
import logging
from typing import Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.edenai.edenai_base_tool import EdenaiTool
logger = logging.getLogger(__name__)
[docs]class Ede... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/image_objectdetection.html |
55ee274c2ec6-1 | [x_min, x_max, y_min, y_max]
): # some providers don't return positions
label_str += f""",at the position x_min: {x_min}, x_max: {x_max},
y_min: {y_min}, y_max: {y_max}"""
label_info.append(label_str)
result.append("\n".join(label_info))
return "... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/image_objectdetection.html |
426f887c34e9-0 | Source code for langchain.tools.edenai.audio_text_to_speech
from __future__ import annotations
import logging
from typing import Dict, List, Literal, Optional
import requests
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import Field, root_validator, validator
from langcha... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/audio_text_to_speech.html |
426f887c34e9-1 | voice: Literal["MALE", "FEMALE"]
"""voice option : 'MALE' or 'FEMALE' """
feature: str = "audio"
subfeature: str = "text_to_speech"
@validator("providers")
def check_only_one_provider_selected(cls, v: List[str]) -> List[str]:
"""
This tool has no feature to combine providers results.... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/audio_text_to_speech.html |
426f887c34e9-2 | return "audio.wav"
def _run(
self,
query: str,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> str:
"""Use the tool."""
all_params = {
"text": query,
"language": self.language,
"option": self.voice,
"return_typ... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/audio_text_to_speech.html |
81536b63445c-0 | Source code for langchain.tools.edenai.audio_speech_to_text
from __future__ import annotations
import json
import logging
import time
from typing import List, Optional
import requests
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.pydantic_v1 import validator
from langchain.tools.edena... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/audio_speech_to_text.html |
81536b63445c-1 | """
This tool has no feature to combine providers results.
Therefore we only allow one provider
"""
if len(v) > 1:
raise ValueError(
"Please select only one provider. "
"The feature to combine providers results is not available "
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/audio_speech_to_text.html |
81536b63445c-2 | job_id = self._call_eden_ai(query_params)
url = self.base_url + job_id
audio_analysis_result = self._wait_processing(url)
result = audio_analysis_result.text
formatted_text = json.loads(result)
return formatted_text["results"][self.providers[0]]["text"] | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/audio_speech_to_text.html |
1f1a11609df4-0 | Source code for langchain.tools.edenai.ocr_identityparser
from __future__ import annotations
import logging
from typing import Optional
from langchain.callbacks.manager import CallbackManagerForToolRun
from langchain.tools.edenai.edenai_base_tool import EdenaiTool
logger = logging.getLogger(__name__)
[docs]class EdenAi... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/ocr_identityparser.html |
1f1a11609df4-1 | )
return "\n".join(formatted_list)
def _run(
self,
query: str,
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> str:
"""Use the tool."""
query_params = {
"file_url": query,
"language": self.language,
"attributes_as_... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/edenai/ocr_identityparser.html |
ff82c26e89f2-0 | Source code for langchain.tools.spark_sql.tool
# flake8: noqa
"""Tools for interacting with Spark SQL."""
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.manager import... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/spark_sql/tool.html |
ff82c26e89f2-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: str = "schema_sql_db"
description: str = """
Input to this tool is a comma-separa... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/spark_sql/tool.html |
ff82c26e89f2-2 | template: str = QUERY_CHECKER
llm: BaseLanguageModel
llm_chain: LLMChain = Field(init=False)
name: str = "query_checker_sql_db"
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 query_sql_db!
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/spark_sql/tool.html |
43d5c825f5d3-0 | Source code for langchain.tools.arxiv.tool
"""Tool for the Arxiv 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.arxiv import ArxivAPIWrapper
[docs]class Arxiv... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/arxiv/tool.html |
8f93354bfe97-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/office365/utils.html |
8f93354bfe97-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/office365/utils.html |
5076960fbdf9-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/office365/send_message.html |
5076960fbdf9-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/office365/send_message.html |
312d6154a482-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/office365/create_draft_message.html |
312d6154a482-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/office365/create_draft_message.html |
bac970bb991a-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/office365/messages_search.html |
bac970bb991a-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=(
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/office365/messages_search.html |
bac970bb991a-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/office365/messages_search.html |
235aa632ff78-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/office365/send_event.html |
235aa632ff78-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):
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/office365/send_event.html |
e992f9c3470f-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 ... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/office365/base.html |
840b0421f806-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/office365/events_search.html |
840b0421f806-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/office365/events_search.html |
840b0421f806-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... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/office365/events_search.html |
840b0421f806-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")
... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/office365/events_search.html |
9f63d89d8ce1-0 | Source code for langchain.tools.metaphor_search.tool
"""Tool for the Metaphor search API."""
from typing import Dict, List, Optional, Union
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
from langchain.tools.base import BaseTool
from langchain.utilities.me... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/metaphor_search/tool.html |
9f63d89d8ce1-1 | start_published_date,
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:... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/metaphor_search/tool.html |
3d6c2eee65ea-0 | Source code for langchain.tools.requests.tool
# flake8: noqa
"""Tools for making requests to an API endpoint."""
import json
from typing import Any, Dict, Optional
from langchain.pydantic_v1 import BaseModel
from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
)
f... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html |
3d6c2eee65ea-1 | return await self.requests_wrapper.aget(_clean_url(url))
[docs]class RequestsPostTool(BaseRequestsTool, BaseTool):
"""Tool for making a POST request to an API endpoint."""
name: str = "requests_post"
description: str = """Use this when you want to POST to a website.
Input should be a json string with tw... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html |
3d6c2eee65ea-2 | name: str = "requests_patch"
description: str = """Use this when you want to PATCH to a website.
Input should be a json string with two keys: "url" and "data".
The value of "url" should be a string, and the value of "data" should be a dictionary of
key-value pairs you want to PATCH to the url.
Be c... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html |
3d6c2eee65ea-3 | Input should be a json string with two keys: "url" and "data".
The value of "url" should be a string, and the value of "data" should be a dictionary of
key-value pairs you want to PUT to the url.
Be careful to always use double quotes for strings in the json string.
The output will be the text response... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html |
3d6c2eee65ea-4 | ) -> str:
"""Run the tool."""
return self.requests_wrapper.delete(_clean_url(url))
async def _arun(
self,
url: str,
run_manager: Optional[AsyncCallbackManagerForToolRun] = None,
) -> str:
"""Run the tool asynchronously."""
return await self.requests_wrappe... | https://api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html |
e9c1540e11c4-0 | Source code for langchain.utilities.golden_query
"""Util that calls Golden."""
import json
from typing import Dict, Optional
import requests
from langchain.pydantic_v1 import BaseModel, Extra, root_validator
from langchain.utils import get_from_dict_or_env
GOLDEN_BASE_URL = "https://golden.com"
GOLDEN_TIMEOUT = 5000
[d... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/golden_query.html |
e9c1540e11c4-1 | content = json.loads(response.content)
query_id = content["id"]
response = requests.get(
(
f"{GOLDEN_BASE_URL}/api/v2/public/queries/{query_id}/results/"
"?pageSize=10"
),
headers=headers,
timeout=GOLDEN_TIMEOUT,
)
... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/golden_query.html |
20a3d774d986-0 | Source code for langchain.utilities.opaqueprompts
from typing import Dict, Union
[docs]def sanitize(
input: Union[str, Dict[str, str]]
) -> Dict[str, Union[str, Dict[str, str]]]:
"""
Sanitize input string or dict of strings by replacing sensitive data with
placeholders.
It returns the sanitized inpu... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/opaqueprompts.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.