id
stringlengths
14
16
text
stringlengths
13
2.7k
source
stringlengths
57
178
60eb0b161d5e-12
elt = t.dims[0] self.dispatch(elt) self.write(",") else: interleave(lambda: self.write(", "), self.dispatch, t.dims) # argument def _arg(self, t): self.write(t.arg) if t.annotation: self.write(": ") self.dispatch(t.annotation) ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/e2b_data_analysis/unparse.html
60eb0b161d5e-13
if d: self.write("=") self.dispatch(d) # kwargs if t.kwarg: if first: first = False else: self.write(", ") self.write("**" + t.kwarg.arg) if t.kwarg.annotation: self.wr...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/e2b_data_analysis/unparse.html
0a6a64e18a99-0
Source code for langchain.tools.openapi.utils.api_models """Pydantic models for parsing an OpenAPI spec.""" from __future__ import annotations import logging from enum import Enum from typing import ( TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Tuple, Type, Union, ) from lang...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
0a6a64e18a99-1
'Unsupported APIPropertyLocation "{location}"' " for parameter {name}. " + f"Valid values are {[loc.value for loc in SUPPORTED_LOCATIONS]}" ) SCHEMA_TYPE = Union[str, Type, tuple, None, Enum] [docs]class APIPropertyBase(BaseModel): """Base model for an API property.""" # The name of the parameter is req...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
0a6a64e18a99-2
Schema, ) [docs]class APIProperty(APIPropertyBase): """A model for a property in the query, path, header, or cookie params.""" location: APIPropertyLocation = Field(alias="location") """The path/how it's being passed to the endpoint.""" @staticmethod def _cast_schema_list_type( schema: S...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
0a6a64e18a99-3
if schema is None: return None schema_type: SCHEMA_TYPE = APIProperty._cast_schema_list_type(schema) if schema_type == "array": schema_type = APIProperty._get_schema_type_for_array(schema) elif schema_type == "object": # TODO: Resolve array and object types to...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
0a6a64e18a99-4
return schema [docs] @staticmethod def is_supported_location(location: str) -> bool: """Return whether the provided location is supported.""" try: return APIPropertyLocation.from_str(location) in SUPPORTED_LOCATIONS except ValueError: return False [docs] @classm...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
0a6a64e18a99-5
from openapi_pydantic import ( Reference, ) properties = [] required_props = schema.required or [] if schema.properties is None: raise ValueError( f"No properties found when processing object schema: {schema}" ) for prop_name, p...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
0a6a64e18a99-6
required=True, # TODO: Add required spec=spec, references_used=references_used, ) return f"Array<{array_type.type}>" return "array" [docs] @classmethod def from_schema( cls, schema: Schema, name: str, ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
0a6a64e18a99-7
"""The description of the request body.""" properties: List[APIRequestBodyProperty] = Field(alias="properties") # E.g., application/json - we only support JSON at the moment. media_type: str = Field(alias="media_type") """The media type of the request body.""" @classmethod def _process_supported...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
0a6a64e18a99-8
properties=[], references_used=references_used, ) ) return api_request_body_properties [docs] @classmethod def from_request_body( cls, request_body: RequestBody, spec: OpenAPISpec ) -> "APIRequestBody": """Instantiate from an OpenAPI Req...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
0a6a64e18a99-9
# components: Dict[str, BaseModel] = Field(alias="components") request_body: Optional[APIRequestBody] = Field(alias="request_body") """The request body of the operation.""" @staticmethod def _get_properties_from_parameters( parameters: List[Parameter], spec: OpenAPISpec ) -> List[APIProperty...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
0a6a64e18a99-10
properties = cls._get_properties_from_parameters(parameters, spec) operation_id = OpenAPISpec.get_cleaned_operation_id(operation, path, method) request_body = spec.get_request_body_for_operation(operation) api_request_body = ( APIRequestBody.from_request_body(request_body, spec) ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
0a6a64e18a99-11
) -> str: """Format nested properties.""" formatted_props = [] for prop in properties: prop_name = prop.name prop_type = self.ts_type_from_python(prop.type) prop_required = "" if prop.required else "?" prop_desc = f"/* {prop.description} */" if pro...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
0a6a64e18a99-12
{formatted_params} }}) => any; """ return typescript_definition.strip() @property def query_params(self) -> List[str]: return [ property.name for property in self.properties if property.location == APIPropertyLocation.QUERY ] @property def path...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
bba385ce080c-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html
bba385ce080c-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html
bba385ce080c-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html
bba385ce080c-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html
bba385ce080c-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." # ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html
bba385ce080c-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 ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html
bba385ce080c-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html
bba385ce080c-7
) -> str: """Get the names of the tables.""" return ", ".join(self.powerbi.get_table_names())
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/powerbi/tool.html
ced2d075af1d-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, Field, root_validator from langchain.schema.language_model import BaseLanguageModel from langchain.callbacks.manager import ( ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/spark_sql/tool.html
ced2d075af1d-1
name: str = "schema_sql_db" description: str = """ Input to this tool is a comma-separated list of tables, output is the schema and sample rows for those tables. Be sure that the tables actually exist by calling list_tables_sql_db first! Example Input: "table1, table2, table3" """ def _run( ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/spark_sql/tool.html
ced2d075af1d-2
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! """ @root_validator(pre=True) def initialize_llm_chain(cls, values: Dict[str, Any]) -> Dict[str, ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/spark_sql/tool.html
5051509e99d9-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/metaphor_search/tool.html
5051509e99d9-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:...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/metaphor_search/tool.html
98958a40c4c9-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(...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/interaction/tool.html
771c9596001f-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 ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/jira/tool.html
771c9596001f-1
) -> str: """Use the Atlassian Jira API to run an operation.""" return self.api_wrapper.run(self.mode, instructions)
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/jira/tool.html
ebe0138f922e-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/google_places/tool.html
fbd1a4195c09-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/extract_hyperlinks.html
fbd1a4195c09-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: ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/extract_hyperlinks.html
67dab042ea93-0
Source code for langchain.tools.playwright.navigate from __future__ import annotations from typing import Optional, Type from urllib.parse import urlparse from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.pydantic_v1 import BaseModel, Field, va...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/navigate.html
67dab042ea93-1
See https://python.langchain.com/docs/security for more information. """ name: str = "navigate_browser" description: str = "Navigate a browser to the specified URL" args_schema: Type[BaseModel] = NavigateToolInput def _run( self, url: str, run_manager: Optional[CallbackManage...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/navigate.html
63d9df40bdf5-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/base.html
63d9df40bdf5-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....
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/base.html
bb34a5f532d9-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/utils.html
bb34a5f532d9-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/utils.html
0f203a029aa4-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/navigate_back.html
0f203a029aa4-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"
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/navigate_back.html
f80284b49b65-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/current_page.html
149bb4b27c11-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/get_elements.html
149bb4b27c11-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/get_elements.html
149bb4b27c11-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/get_elements.html
d28b64d9bbab-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/extract_text.html
d28b64d9bbab-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/extract_text.html
d2c6ad871f64-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/click.html
d2c6ad871f64-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/click.html
833a4fb1f59e-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/youtube/search.html
833a4fb1f59e-1
person = values[0] if len(values) > 1: num_results = int(values[1]) else: num_results = 2 return self._search(person, num_results)
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/youtube/search.html
eb8fcd4bbf9f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/json/tool.html
eb8fcd4bbf9f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/json/tool.html
eb8fcd4bbf9f-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] =...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/json/tool.html
7418aa39c2e7-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 ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/search.html
7418aa39c2e7-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/search.html
7418aa39c2e7-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: ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/search.html
88f821756354-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]...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/create_draft.html
88f821756354-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/create_draft.html
50cdaa916a7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/base.html
727022b604a6-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/get_thread.html
be326217a770-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 ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/utils.html
be326217a770-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....
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/utils.html
be326217a770-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/utils.html
1622a59c0897-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 ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/get_message.html
1622a59c0897-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") ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/get_message.html
3e118a8bdf85-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/send_message.html
3e118a8bdf85-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/gmail/send_message.html
458e6b87d4c5-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html
458e6b87d4c5-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html
458e6b87d4c5-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html
458e6b87d4c5-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html
458e6b87d4c5-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html
e37813be2630-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): """...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/transfer.html
7062382029a6-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/rule.html
7062382029a6-1
## SET Example - type: SET - 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: Operation...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/rule.html
6a6430ba0869-0
Source code for langchain.tools.ainetwork.base 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 import Field from langchain.tools.ainetwork...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/base.html
6a6430ba0869-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/base.html
a4fbd39214c4-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/utils.html
a4fbd39214c4-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/utils.html
5354ec80e6c0-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/owner.html
5354ec80e6c0-1
## Address Rules - 0x[0-9a-fA-F]{40}: 40-digit hexadecimal address - *: 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 fa...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/owner.html
5354ec80e6c0-2
transactionInput=ValueOnlyTransactionInput( value={ ".owner": { "owners": { address: { "write_owner": write_owner or False, ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/owner.html
d7f51b07cff7-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/value.html
d7f51b07cff7-1
- `/sharding`: Sharding - `/token/name`: Token name - `/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 _a...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/value.html
6843b35cb89d-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 ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/app.html
6843b35cb89d-1
## SET_ADMIN Example 1 - type: SET_ADMIN - appName: ain_project ### Result: 1. Path /apps/ain_project created. 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. <addres...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/app.html
6843b35cb89d-2
return json.dumps(res, ensure_ascii=False) except Exception as e: return f"{builtins.type(e).__name__}: {str(e)}"
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/ainetwork/app.html
68c677afece8-0
Source code for langchain.tools.bearly.tool import base64 import itertools import json import re from pathlib import Path from typing import Dict, List, Type import requests from langchain.pydantic_v1 import BaseModel, Field from langchain.tools import Tool [docs]def strip_markdown_code(md_string: str) -> str: """S...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/bearly/tool.html
68c677afece8-1
You must send the whole script every time and print your outputs. \ Script should be pure python code that can be evaluated. \ It should be in python format NOT markdown. \ The code should NOT be wrapped in backticks. \ All python packages including requests, matplotlib, scipy, numpy, pandas, \ etc are available. \ If ...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/bearly/tool.html
68c677afece8-2
f"- path: `{target_path}` \n first four lines: {peek_content}" f" \n description: `{file_info.description}`" ) return "\n".join(lines) @property def description(self) -> str: return (base_description + "\n\n" + self.file_description).strip() [docs] def make_input_f...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/bearly/tool.html
68c677afece8-3
"""Use the tool asynchronously.""" raise NotImplementedError("custom_search does not support async") [docs] def add_file(self, source_path: str, target_path: str, description: str) -> None: if target_path in self.files: raise ValueError("target_path already exists") if not Path(so...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/bearly/tool.html
bba6e8acfab4-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/text2speech.html
bba6e8acfab4-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/text2speech.html
bba6e8acfab4-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/text2speech.html
c179588460a8-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/image_analysis.html
c179588460a8-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 = (...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/image_analysis.html
c179588460a8-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/image_analysis.html
c179588460a8-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}")
lang/api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/image_analysis.html