id
stringlengths
14
16
text
stringlengths
4
1.28k
source
stringlengths
54
121
210b10c26422-4
) return json.dumps(chain({chain.question_key: query}, return_only_outputs=True)) async def _arun( self, query: str, run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> str: """Use the tool asynchronously.""" raise NotImplementedError("VectorStoreQA...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/vectorstore/tool.html
289a2a83c2bf-0
Source code for langchain.tools.pubmed.tool """Tool for the Pubmed API.""" from typing import Optional from pydantic import Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langchain.utilities.pupmed impor...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/pubmed/tool.html
289a2a83c2bf-1
) api_wrapper: PubMedAPIWrapper = Field(default_factory=PubMedAPIWrapper) def _run( self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the Arxiv tool.""" return self.api_wrapper.run(query) async def _arun( self, ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/pubmed/tool.html
c7d3716a6ba0-0
Source code for langchain.tools.google_search.tool """Tool for the Google search API.""" from typing import Optional from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langchain.utilities.google_search import Goog...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/google_search/tool.html
c7d3716a6ba0-1
) -> str: """Use the tool.""" return self.api_wrapper.run(query) async def _arun( self, query: str, run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> str: """Use the tool asynchronously.""" raise NotImplementedError("GoogleSearchRun does n...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/google_search/tool.html
c7d3716a6ba0-2
api_wrapper: GoogleSearchAPIWrapper def _run( self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the tool.""" return str(self.api_wrapper.results(query, self.num_results)) async def _arun( self, query: str, ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/google_search/tool.html
40978ca4af5d-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
40978ca4af5d-1
def _run( self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the tool.""" return self.wrapper.run(query, **self.kwargs) async def _arun( self, query: str, run_manager: Optional[AsyncCallbackManagerForToolRun...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/searx_search/tool.html
40978ca4af5d-2
"Input should be a search query. Output is a JSON array of the query results" ) wrapper: SearxSearchWrapper num_results: int = 4 kwargs: dict = Field(default_factory=dict) class Config: """Pydantic config.""" extra = Extra.allow def _run( self, query: str, ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/searx_search/tool.html
40978ca4af5d-3
return ( await self.wrapper.aresults(query, self.num_results, **self.kwargs) ).__str__()
https://api.python.langchain.com/en/latest/_modules/langchain/tools/searx_search/tool.html
bef1f9041caf-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 pydantic import BaseModel from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html
bef1f9041caf-1
"""Tool for making a GET request to an API endpoint.""" name = "requests_get" description = "A portal to the internet. Use this when you need to get specific content from a website. Input should be a url (i.e. https://www.google.com). The output will be the text response of the GET request." def _run( ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html
bef1f9041caf-2
[docs]class RequestsPostTool(BaseRequestsTool, BaseTool): """Tool for making a POST request to an API endpoint.""" name = "requests_post" description = """Use this when you want to POST to a website. Input should be a json string with two keys: "url" and "data". The value of "url" should be a string...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html
bef1f9041caf-3
data = _parse_input(text) return self.requests_wrapper.post(_clean_url(data["url"]), data["data"]) except Exception as e: return repr(e) async def _arun( self, text: str, run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> str: """Ru...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html
bef1f9041caf-4
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 careful to always use double quotes for strings in the json string The output will be the text respons...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html
bef1f9041caf-5
self, text: str, run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> str: """Run the tool asynchronously.""" try: data = _parse_input(text) return await self.requests_wrapper.apatch( _clean_url(data["url"]), data["data"] ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html
bef1f9041caf-6
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 of the PUT request. """ def _run( self, text: str, run_manager: Optional[CallbackManagerForToolRun] = None ) -> str: """Run the tool...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html
bef1f9041caf-7
data = _parse_input(text) return await self.requests_wrapper.aput( _clean_url(data["url"]), data["data"] ) except Exception as e: return repr(e) [docs]class RequestsDeleteTool(BaseRequestsTool, BaseTool): """Tool for making a DELETE request to an API endpo...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html
bef1f9041caf-8
self, url: str, run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> str: """Run the tool asynchronously.""" return await self.requests_wrapper.adelete(_clean_url(url))
https://api.python.langchain.com/en/latest/_modules/langchain/tools/requests/tool.html
fdb9e3a5cfce-0
Source code for langchain.tools.playwright.extract_text from __future__ import annotations from typing import Optional, Type from pydantic import BaseModel, root_validator from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.playwright.base ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/extract_text.html
fdb9e3a5cfce-1
except ImportError: raise ValueError( "The 'beautifulsoup4' package is required to use this tool." " Please install it with 'pip install beautifulsoup4'." ) return values def _run(self, run_manager: Optional[CallbackManagerForToolRun] = None) -> str: ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/extract_text.html
fdb9e3a5cfce-2
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
07dfeffb7d3b-0
Source code for langchain.tools.playwright.navigate_back from __future__ import annotations from typing import Optional, Type from pydantic import BaseModel from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.playwright.base import BaseBrow...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/navigate_back.html
07dfeffb7d3b-1
"""Use the tool.""" if self.sync_browser is None: raise ValueError(f"Synchronous browser not provided to {self.name}") page = get_current_page(self.sync_browser) response = page.go_back() if response: return ( f"Navigated back to the previous page ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/navigate_back.html
07dfeffb7d3b-2
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
a2e30f1366e6-0
Source code for langchain.tools.playwright.extract_hyperlinks from __future__ import annotations import json from typing import TYPE_CHECKING, Any, Optional, Type from pydantic import BaseModel, Field, root_validator from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToo...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/extract_hyperlinks.html
a2e30f1366e6-1
description: str = "Extract all hyperlinks on the current webpage" args_schema: Type[BaseModel] = ExtractHyperlinksToolInput @root_validator def check_bs_import(cls, values: dict) -> dict: """Check that the arguments are valid.""" try: from bs4 import BeautifulSoup # noqa: F401 ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/extract_hyperlinks.html
a2e30f1366e6-2
# 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: links = [anchor.get("href", "") for anchor in an...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/extract_hyperlinks.html
a2e30f1366e6-3
html_content = page.content() return self.scrape_page(page, html_content, absolute_urls) async def _arun( self, absolute_urls: bool = False, run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> str: """Use the tool asynchronously.""" if self.async_br...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/extract_hyperlinks.html
3e2fe96c6495-0
Source code for langchain.tools.playwright.click from __future__ import annotations from typing import Optional, Type from pydantic import BaseModel, Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.playwright.base import BaseBrows...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/click.html
3e2fe96c6495-1
"""Whether to consider only visible elements.""" playwright_strict: bool = False """Whether to employ Playwright's strict mode when clicking on elements.""" playwright_timeout: float = 1_000 """Timeout (in ms) for Playwright to wait for element to be ready.""" def _selector_effective(self, selector:...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/click.html
3e2fe96c6495-2
selector_effective = self._selector_effective(selector=selector) from playwright.sync_api import TimeoutError as PlaywrightTimeoutError try: page.click( selector_effective, strict=self.playwright_strict, timeout=self.playwright_timeout, ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/click.html
3e2fe96c6495-3
selector_effective = self._selector_effective(selector=selector) from playwright.async_api import TimeoutError as PlaywrightTimeoutError try: await page.click( selector_effective, strict=self.playwright_strict, timeout=self.playwright_timeout, ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/click.html
778ee6de228f-0
Source code for langchain.tools.playwright.navigate from __future__ import annotations from typing import Optional, Type from pydantic import BaseModel, Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.playwright.base import BaseBr...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/navigate.html
778ee6de228f-1
self, url: str, run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the tool.""" if self.sync_browser is None: raise ValueError(f"Synchronous browser not provided to {self.name}") page = get_current_page(self.sync_browser) response = ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/navigate.html
778ee6de228f-2
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
0d9f1c0ec6b8-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 pydantic import BaseModel, Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) fro...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/get_elements.html
0d9f1c0ec6b8-1
attributes: List[str] = Field( default_factory=lambda: ["innerText"], description="Set of attributes to retrieve for each element", ) async def _aget_elements( page: AsyncPage, selector: str, attributes: Sequence[str] ) -> List[dict]: """Get elements matching the given CSS selector.""" e...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/get_elements.html
0d9f1c0ec6b8-2
return results def _get_elements( 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: ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/get_elements.html
0d9f1c0ec6b8-3
) args_schema: Type[BaseModel] = GetElementsToolInput def _run( self, selector: str, attributes: Sequence[str] = ["innerText"], run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the tool.""" if self.sync_browser is None: rai...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/get_elements.html
0d9f1c0ec6b8-4
) -> 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
439ce4ed22c0-0
Source code for langchain.tools.playwright.current_page from __future__ import annotations from typing import Optional, Type from pydantic import BaseModel from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.playwright.base import BaseBrows...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/current_page.html
439ce4ed22c0-1
page = get_current_page(self.sync_browser) return str(page.url) 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 provid...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/playwright/current_page.html
f8fe23585a8b-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 ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool f...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/ddg_search/tool.html
f8fe23585a8b-1
default_factory=DuckDuckGoSearchAPIWrapper ) def _run( self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the tool.""" return self.api_wrapper.run(query) async def _arun( self, query: str, run_manage...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/ddg_search/tool.html
f8fe23585a8b-2
"Useful for when you need to answer questions about current events. " "Input should be a search query. Output is a JSON array of the query results" ) num_results: int = 4 api_wrapper: DuckDuckGoSearchAPIWrapper = Field( default_factory=DuckDuckGoSearchAPIWrapper ) def _run( s...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/ddg_search/tool.html
f8fe23585a8b-3
"""Use the tool asynchronously.""" raise NotImplementedError("DuckDuckGoSearchResults does not support async") def DuckDuckGoSearchTool(*args: Any, **kwargs: Any) -> DuckDuckGoSearchRun: """ Deprecated. Use DuckDuckGoSearchRun instead. Args: *args: **kwargs: Returns: Duck...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/ddg_search/tool.html
e27c4736326d-0
Source code for langchain.tools.brave_search.tool from __future__ import annotations from typing import Any, Optional from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langchain.utilities.brave_search import Brav...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/brave_search/tool.html
e27c4736326d-1
) -> BraveSearch: wrapper = BraveSearchWrapper(api_key=api_key, search_kwargs=search_kwargs or {}) return cls(search_wrapper=wrapper, **kwargs) def _run( self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the tool.""" ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/brave_search/tool.html
71392965bbfe-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 ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.tools.base import BaseTool from langchain.u...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/scenexplain/tool.html
71392965bbfe-1
"the output will be a text description that covers every detail of the image." ) api_wrapper: SceneXplainAPIWrapper = Field(default_factory=SceneXplainAPIWrapper) def _run( self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None ) -> str: """Use the tool.""" ret...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/scenexplain/tool.html
20db56ba472f-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
20db56ba472f-1
# for more info. class APIPropertyLocation(Enum): """The location of the property.""" QUERY = "query" PATH = "path" HEADER = "header" COOKIE = "cookie" # Not yet supported @classmethod def from_str(cls, location: str) -> "APIPropertyLocation": """Parse an APIPropertyLocation.""" ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-2
" for parameter {name}. " + f"Valid values are {[loc.value for loc in SUPPORTED_LOCATIONS]}" ) SCHEMA_TYPE = Union[str, Type, tuple, None, Enum] 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...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-3
"""The name of the property.""" required: bool = Field(alias="required") """Whether the property is required.""" type: SCHEMA_TYPE = Field(alias="type") """The type of the property. Either a primitive type, a component/parameter type, or an array or 'object' (dict) of the above.""" defa...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-4
@staticmethod def _cast_schema_list_type(schema: Schema) -> Optional[Union[str, Tuple[str, ...]]]: type_ = schema.type if not isinstance(type_, list): return type_ else: return tuple(type_) @staticmethod def _get_schema_type_for_enum(parameter: Parameter, sche...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-5
elif isinstance(items, Reference): ref_name = items.ref.split("/")[-1] schema_type = ref_name # TODO: Add ref definitions to make his valid else: raise ValueError(f"Unsupported array items: {items}") if isinstance(schema_type, str): # TODO: recurse ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-6
raise NotImplementedError("Objects not yet supported") elif schema_type in PRIMITIVE_TYPES: if schema.enum: schema_type = APIProperty._get_schema_type_for_enum(parameter, schema) else: # Directly use the primitive type pass else: ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-7
) @staticmethod def _get_schema(parameter: Parameter, spec: OpenAPISpec) -> Optional[Schema]: schema = parameter.param_schema if isinstance(schema, Reference): schema = spec.get_referenced_schema(schema) elif schema is None: return None elif not isinstance...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-8
cls._validate_location( location, parameter.name, ) cls._validate_content(parameter.content) 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 ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-9
references_used: List[str] = Field(alias="references_used") """The references used by the property.""" @classmethod def _process_object_schema( cls, schema: Schema, spec: OpenAPISpec, references_used: List[str] ) -> Tuple[Union[str, List[str], None], List["APIRequestBodyProperty"]]: prop...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-10
else: continue properties.append( cls.from_schema( schema=prop_schema, name=prop_name, required=prop_name in required_props, spec=spec, references_used=references_used, ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-11
else: pass if isinstance(items, Schema): array_type = cls.from_schema( schema=items, name=f"{name}Item", required=True, # TODO: Add required spec=spec, references_used=referen...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-12
if schema_type == "object" and schema.properties: schema_type, properties = cls._process_object_schema( schema, spec, references_used ) elif schema_type == "array": schema_type = cls._process_array_schema(schema, name, spec, references_used) elif schem...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-13
) class APIRequestBody(BaseModel): """A model for a request body.""" description: Optional[str] = Field(alias="description") """The description of the request body.""" properties: List[APIRequestBodyProperty] = Field(alias="properties") # E.g., application/json - we only support JSON at the moment. ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-14
schema = spec.get_referenced_schema(schema) if schema is None: raise ValueError( f"Could not resolve schema for media type: {media_type_obj}" ) api_request_body_properties = [] required_properties = schema.required or [] if schema.type == "object" ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-15
type=schema.type, default=schema.default, description=schema.description, properties=[], references_used=references_used, ) ) return api_request_body_properties @classmethod def from_request_body(...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-16
) [docs]class APIOperation(BaseModel): """A model for a single API operation.""" 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(ali...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-17
# """The properties of the operation.""" # 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]...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-18
INVALID_LOCATION_TEMPL.format( location=param.param_in, name=param.name ) + " Ignoring optional parameter" ) pass return properties [docs] @classmethod def from_openapi_url( cls, spec_url: str,...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-19
parameters = spec.get_parameters_for_operation(operation) 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 = ( ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-20
) [docs] @staticmethod def ts_type_from_python(type_: SCHEMA_TYPE) -> str: if type_ is None: # TODO: Handle Nones better. These often result when # parsing specs that are < v3 return "any" elif isinstance(type_, str): return { "str":...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-21
def _format_nested_properties( self, properties: List[APIRequestBodyProperty], indent: int = 2 ) -> str: """Format nested properties.""" formatted_props = [] for prop in properties: prop_name = prop.name prop_type = self.ts_type_from_python(prop.type) ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-22
[docs] def to_typescript(self) -> str: """Get typescript string representation of the operation.""" operation_name = self.operation_id params = [] if self.request_body: formatted_request_body_props = self._format_nested_properties( self.request_body.propert...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
20db56ba472f-23
typescript_definition = f""" {description_str} type {operation_name} = (_: {{ {formatted_params} }}) => any; """ return typescript_definition.strip() @property def query_params(self) -> List[str]: return [ property.name for property in self.properties if prope...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/openapi/utils/api_models.html
2bcdf9404bc0-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
2bcdf9404bc0-1
self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the tool.""" return str(self.api_wrapper.run(query)) async def _arun( self, query: str, run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> str: ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/google_serper/tool.html
2bcdf9404bc0-2
"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
db08b9eb4c1a-0
Source code for langchain.tools.jira.tool """ This tool allows agents to interact with the atlassian-python-api library and operate on a Jira instance. For more information on the atlassian-python-api library, see https://atlassian-python-api.readthedocs.io/jira.html To use this tool, you must first set as environment ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/jira/tool.html
db08b9eb4c1a-1
agent = initialize_agent( toolkit.get_tools(), llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True ) ``` """ from typing import Optional from pydantic import Field from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.too...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/jira/tool.html
db08b9eb4c1a-2
return self.api_wrapper.run(self.mode, instructions) async def _arun( self, _: str, run_manager: Optional[AsyncCallbackManagerForToolRun] = None, ) -> str: """Use the Atlassian Jira API to run an operation.""" raise NotImplementedError("JiraAction does not support async")
https://api.python.langchain.com/en/latest/_modules/langchain/tools/jira/tool.html
b191e8bccacd-0
Source code for langchain.tools.steamship_image_generation.tool """This tool allows agents to generate images using Steamship. Steamship offers access to different third party image generation APIs using a single API key. Today the following models are supported: - Dall-E - Stable Diffusion To use this tool, you must f...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/steamship_image_generation/tool.html
b191e8bccacd-1
class ModelName(str, Enum): """Supported Image Models for generation.""" DALL_E = "dall-e" STABLE_DIFFUSION = "stable-diffusion" SUPPORTED_IMAGE_SIZES = { ModelName.DALL_E: ("256x256", "512x512", "1024x1024"), ModelName.STABLE_DIFFUSION: ("512x512", "768x768"), } [docs]class SteamshipImageGeneration...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/steamship_image_generation/tool.html
b191e8bccacd-2
description = ( "Useful for when you need to generate an image." "Input: A detailed text-2-image prompt describing an image" "Output: the UUID of a generated image" ) @root_validator(pre=True) def validate_size(cls, values: Dict) -> Dict: if "size" in values: size...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/steamship_image_generation/tool.html
b191e8bccacd-3
values, "steamship_api_key", "STEAMSHIP_API_KEY" ) try: from steamship import Steamship except ImportError: raise ImportError( "steamship is not installed. " "Please install it with `pip install steamship`" ) steamship =...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/steamship_image_generation/tool.html
b191e8bccacd-4
plugin_handle=self.model_name.value, config={"n": 1, "size": self.size} ) task = image_generator.generate(text=query, append_output_to_file=True) task.wait() blocks = task.output.blocks if len(blocks) > 0: if self.return_urls: return make_image_public(...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/steamship_image_generation/tool.html
93b10fe08a85-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 ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, )...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/text2speech.html
93b10fe08a85-1
azure_cogs_region: str = "" #: :meta private: speech_language: str = "en-US" #: :meta private: speech_config: Any #: :meta private: name = "azure_cognitive_services_text2speech" description = ( "A wrapper around Azure Cognitive Services Text2Speech. " "Useful for when you need to conv...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/text2speech.html
93b10fe08a85-2
) 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
93b10fe08a85-3
) result = speech_synthesizer.speak_text(text) if result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted: stream = speechsdk.AudioDataStream(result) with tempfile.NamedTemporaryFile( mode="wb", suffix=".wav", delete=False ) as f: ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/text2speech.html
93b10fe08a85-4
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
b495fd22399d-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 ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html
b495fd22399d-1
https://learn.microsoft.com/en-us/azure/applied-ai-services/form-recognizer/quickstarts/get-started-sdks-rest-api?view=form-recog-3.0.0&pivots=programming-language-python """ azure_cogs_key: str = "" #: :meta private: azure_cogs_endpoint: str = "" #: :meta private: doc_analysis_client: Any #: :meta p...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html
b495fd22399d-2
"""Validate that api key and endpoint exists in environment.""" azure_cogs_key = get_from_dict_or_env( values, "azure_cogs_key", "AZURE_COGS_KEY" ) azure_cogs_endpoint = get_from_dict_or_env( values, "azure_cogs_endpoint", "AZURE_COGS_ENDPOINT" ) try: ...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html
b495fd22399d-3
) return values def _parse_tables(self, tables: List[Any]) -> List[Any]: result = [] for table in tables: rc, cc = table.row_count, table.column_count _table = [["" for _ in range(cc)] for _ in range(rc)] for cell in table.cells: _table[cel...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html
b495fd22399d-4
document_src_type = detect_file_src_type(document_path) if document_src_type == "local": with open(document_path, "rb") as document: poller = self.doc_analysis_client.begin_analyze_document( "prebuilt-document", document ) elif document_src...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html
b495fd22399d-5
res_dict["key_value_pairs"] = self._parse_kv_pairs(result.key_value_pairs) return res_dict def _format_document_analysis_result(self, document_analysis_result: Dict) -> str: formatted_result = [] if "content" in document_analysis_result: formatted_result.append( f...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html
b495fd22399d-6
) return "\n".join(formatted_result) def _run( self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None, ) -> str: """Use the tool.""" try: document_analysis_result = self._document_analysis(query) if not document_analysis_...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/form_recognizer.html
3872b4afaaf5-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 ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langcha...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/image_analysis.html
3872b4afaaf5-1
azure_cogs_endpoint: str = "" #: :meta private: vision_service: Any #: :meta private: analysis_options: Any #: :meta private: name = "azure_cognitive_services_image_analysis" description = ( "A wrapper around Azure Cognitive Services Image Analysis. " "Useful for when you need to anal...
https://api.python.langchain.com/en/latest/_modules/langchain/tools/azure_cognitive_services/image_analysis.html