id
stringlengths
14
16
text
stringlengths
31
2.41k
source
stringlengths
53
121
fa9f8052d3ca-0
Source code for langchain.utilities.max_compute from __future__ import annotations from typing import TYPE_CHECKING, Iterator, List, Optional from langchain.utils import get_from_env if TYPE_CHECKING: from odps import ODPS [docs]class MaxComputeAPIWrapper: """Interface for querying Alibaba Cloud MaxCompute tabl...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/max_compute.html
fa9f8052d3ca-1
"https://pyodps.readthedocs.io/." ) from ex access_id = access_id or get_from_env("access_id", "MAX_COMPUTE_ACCESS_ID") secret_access_key = secret_access_key or get_from_env( "secret_access_key", "MAX_COMPUTE_SECRET_ACCESS_KEY" ) client = ODPS( access_...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/max_compute.html
ad04f6b6b041-0
Source code for langchain.utilities.google_search """Util that calls Google Search.""" from typing import Any, Dict, List, Optional from pydantic import BaseModel, Extra, root_validator from langchain.utils import get_from_dict_or_env [docs]class GoogleSearchAPIWrapper(BaseModel): """Wrapper for Google Search API. ...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/google_search.html
ad04f6b6b041-1
- Under Search engine ID you’ll find the search-engine-ID. 4. Enable the Custom Search API - Navigate to the APIs & Services→Dashboard panel in Cloud Console. - Click Enable APIs and Services. - Search for Custom Search API and click on it. - Click Enable. URL for it: https://console.cloud.googl...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/google_search.html
ad04f6b6b041-2
except ImportError: raise ImportError( "google-api-python-client is not installed. " "Please install it with `pip install google-api-python-client`" ) service = build("customsearch", "v1", developerKey=google_api_key) values["search_engine"] = serv...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/google_search.html
ad04f6b6b041-3
metadata_result["snippet"] = result["snippet"] metadata_results.append(metadata_result) return metadata_results
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/google_search.html
b8563074f47d-0
Source code for langchain.utilities.arxiv """Util that calls Arxiv.""" import logging import os from typing import Any, Dict, List, Optional from pydantic import BaseModel, Extra, root_validator from langchain.schema import Document logger = logging.getLogger(__name__) [docs]class ArxivAPIWrapper(BaseModel): """Wra...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/arxiv.html
b8563074f47d-1
doc_content_chars_max: Optional[int] = 4000 class Config: """Configuration for this pydantic object.""" extra = Extra.forbid @root_validator() def validate_environment(cls, values: Dict) -> Dict: """Validate that the python package exists in environment.""" try: i...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/arxiv.html
b8563074f47d-2
f"Summary: {result.summary}" for result in results ] if docs: return "\n\n".join(docs)[: self.doc_content_chars_max] else: return "No good Arxiv Result was found" [docs] def load(self, query: str) -> List[Document]: """ Run Arxiv search and ...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/arxiv.html
b8563074f47d-3
"journal_ref": result.journal_ref, "doi": result.doi, "primary_category": result.primary_category, "categories": result.categories, "links": [link.href for link in result.links], } else: extra_met...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/arxiv.html
0b28c8a2c05c-0
Source code for langchain.utilities.wolfram_alpha """Util that calls WolframAlpha.""" from typing import Any, Dict, Optional from pydantic import BaseModel, Extra, root_validator from langchain.utils import get_from_dict_or_env [docs]class WolframAlphaAPIWrapper(BaseModel): """Wrapper for Wolfram Alpha. Docs fo...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/wolfram_alpha.html
0b28c8a2c05c-1
res = self.wolfram_client.query(query) try: assumption = next(res.pods).text answer = next(res.results).text except StopIteration: return "Wolfram Alpha wasn't able to answer it" if answer is None or answer == "": # We don't want to return the assu...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/wolfram_alpha.html
2fd1c2d087a0-0
Source code for langchain.utilities.graphql import json from typing import Any, Callable, Dict, Optional from pydantic import BaseModel, Extra, root_validator [docs]class GraphQLAPIWrapper(BaseModel): """Wrapper around GraphQL API. To use, you should have the ``gql`` python package installed. This wrapper w...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/graphql.html
2fd1c2d087a0-1
return json.dumps(result, indent=2) def _execute_query(self, query: str) -> Dict[str, Any]: """Execute a GraphQL query and return the results.""" document_node = self.gql_function(query) result = self.gql_client.execute(document_node) return result
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/graphql.html
85830dbfd5a6-0
Source code for langchain.utilities.openapi """Utility functions for parsing an OpenAPI spec.""" import copy import json import logging import re from enum import Enum from pathlib import Path from typing import Dict, List, Optional, Union import requests import yaml from openapi_schema_pydantic import ( Components...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/openapi.html
85830dbfd5a6-1
@property def _components_strict(self) -> Components: """Get components or err.""" if self.components is None: raise ValueError("No components found in spec. ") return self.components @property def _parameters_strict(self) -> Dict[str, Union[Parameter, Reference]]: ...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/openapi.html
85830dbfd5a6-2
parameter = self._get_referenced_parameter(ref) while isinstance(parameter, Reference): parameter = self._get_referenced_parameter(parameter) return parameter [docs] def get_referenced_schema(self, ref: Reference) -> Schema: """Get a schema (or nested reference) or err.""" ...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/openapi.html
85830dbfd5a6-3
while isinstance(request_body, Reference): request_body = self._get_referenced_request_body(request_body) return request_body @staticmethod def _alert_unsupported_spec(obj: dict) -> None: """Alert if the spec is not supported.""" warning_message = ( " This may res...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/openapi.html
85830dbfd5a6-4
for key in keys[:-1]: item = item[key] item.pop(keys[-1], None) return cls.parse_obj(new_obj) [docs] @classmethod def from_spec_dict(cls, spec_dict: dict) -> "OpenAPISpec": """Get an OpenAPI spec from a dict.""" return cls.parse_obj(spec_dict) [docs...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/openapi.html
85830dbfd5a6-5
path_item = self._get_path_strict(path) results = [] for method in HTTPVerb: operation = getattr(path_item, method.value, None) if isinstance(operation, Operation): results.append(method.value) return results [docs] def get_parameters_for_path(self, pat...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/openapi.html
85830dbfd5a6-6
return request_body [docs] @staticmethod def get_cleaned_operation_id(operation: Operation, path: str, method: str) -> str: """Get a cleaned operation id from an operation id.""" operation_id = operation.operationId if operation_id is None: # Replace all punctuation of any kin...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/openapi.html
d998fc6b7334-0
Source code for langchain.utilities.apify from typing import Any, Callable, Dict, Optional from pydantic import BaseModel, root_validator from langchain.document_loaders import ApifyDatasetLoader from langchain.document_loaders.base import Document from langchain.utils import get_from_dict_or_env [docs]class ApifyWrapp...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/apify.html
d998fc6b7334-1
*, build: Optional[str] = None, memory_mbytes: Optional[int] = None, timeout_secs: Optional[int] = None, ) -> ApifyDatasetLoader: """Run an Actor on the Apify platform and wait for results to be ready. Args: actor_id (str): The ID or name of the Actor on the Apify...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/apify.html
d998fc6b7334-2
memory_mbytes: Optional[int] = None, timeout_secs: Optional[int] = None, ) -> ApifyDatasetLoader: """Run an Actor on the Apify platform and wait for results to be ready. Args: actor_id (str): The ID or name of the Actor on the Apify platform. run_input (Dict): The inp...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/apify.html
d998fc6b7334-3
timeout_secs: Optional[int] = None, ) -> ApifyDatasetLoader: """Run a saved Actor task on Apify and wait for results to be ready. Args: task_id (str): The ID or name of the task on the Apify platform. task_input (Dict): The input object of the task that you're trying to run. ...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/apify.html
d998fc6b7334-4
timeout_secs: Optional[int] = None, ) -> ApifyDatasetLoader: """Run a saved Actor task on Apify and wait for results to be ready. Args: task_id (str): The ID or name of the task on the Apify platform. task_input (Dict): The input object of the task that you're trying to run. ...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/apify.html
1d11990d8aaf-0
Source code for langchain.utilities.jira """Util that calls Jira.""" from typing import Any, Dict, List, Optional from pydantic import BaseModel, Extra, root_validator from langchain.tools.jira.prompt import ( JIRA_CATCH_ALL_PROMPT, JIRA_CONFLUENCE_PAGE_CREATE_PROMPT, JIRA_GET_ALL_PROJECTS_PROMPT, JIRA_...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/jira.html
1d11990d8aaf-1
"mode": "create_page", "name": "Create confluence page", "description": JIRA_CONFLUENCE_PAGE_CREATE_PROMPT, }, ] class Config: """Configuration for this pydantic object.""" extra = Extra.forbid [docs] def list(self) -> List[Dict]: return self.operations...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/jira.html
1d11990d8aaf-2
values["jira"] = jira values["confluence"] = confluence return values [docs] def parse_issues(self, issues: Dict) -> List[dict]: parsed = [] for issue in issues["issues"]: key = issue["key"] summary = issue["fields"]["summary"] created = issue["fiel...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/jira.html
1d11990d8aaf-3
parsed = [] for project in projects: id = project["id"] key = project["key"] name = project["name"] type = project["projectTypeKey"] style = project["style"] parsed.append( {"id": id, "key": key, "name": name, "type": type, ...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/jira.html
1d11990d8aaf-4
params = json.loads(query) return self.confluence.create_page(**dict(params)) [docs] def other(self, query: str) -> str: context = {"self": self} exec(f"result = {query}", context) result = context["result"] return str(result) [docs] def run(self, mode: str, query: str) -> ...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/jira.html
bac05a50b69c-0
Source code for langchain.utilities.awslambda """Util that calls Lambda.""" import json from typing import Any, Dict, Optional from pydantic import BaseModel, Extra, root_validator [docs]class LambdaWrapper(BaseModel): """Wrapper for AWS Lambda SDK. Docs for using: 1. pip install boto3 2. Create a lambd...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/awslambda.html
bac05a50b69c-1
answer = json.loads(payload_string)["body"] except StopIteration: return "Failed to parse response from Lambda" if answer is None or answer == "": # We don't want to return the assumption alone if answer is empty return "Request failed." else: retu...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/awslambda.html
ce0a6450eb6f-0
Source code for langchain.utilities.bing_search """Util that calls Bing Search. In order to set this up, follow instructions at: https://levelup.gitconnected.com/api-tutorial-how-to-use-bing-web-search-api-in-python-4165d5592a7e """ from typing import Dict, List import requests from pydantic import BaseModel, Extra, ro...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/bing_search.html
ce0a6450eb6f-1
bing_subscription_key = get_from_dict_or_env( values, "bing_subscription_key", "BING_SUBSCRIPTION_KEY" ) values["bing_subscription_key"] = bing_subscription_key bing_search_url = get_from_dict_or_env( values, "bing_search_url", "BING_SEARCH_URL", ...
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/bing_search.html
ce0a6450eb6f-2
"snippet": result["snippet"], "title": result["name"], "link": result["url"], } metadata_results.append(metadata_result) return metadata_results
https://api.python.langchain.com/en/stable/_modules/langchain/utilities/bing_search.html