id stringlengths 14 16 | text stringlengths 31 2.41k | source stringlengths 53 121 |
|---|---|---|
cee2f501b181-0 | Source code for langchain.utilities.bash
"""Wrapper around subprocess to run commands."""
from __future__ import annotations
import platform
import re
import subprocess
from typing import TYPE_CHECKING, List, Union
from uuid import uuid4
if TYPE_CHECKING:
import pexpect
def _lazy_import_pexpect() -> pexpect:
""... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/bash.html |
cee2f501b181-1 | # Set the custom prompt
process.sendline("PS1=" + prompt)
process.expect_exact(prompt, timeout=10)
return process
[docs] def run(self, commands: Union[str, List[str]]) -> str:
"""Run commands and return final output."""
if isinstance(commands, str):
commands = [com... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/bash.html |
cee2f501b181-2 | self.process.expect(self.prompt, timeout=10)
self.process.sendline("")
try:
self.process.expect([self.prompt, pexpect.EOF], timeout=10)
except pexpect.TIMEOUT:
return f"Timeout error while executing command {command}"
if self.process.after == pexpect.EOF:
... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/bash.html |
fc7d36900803-0 | Source code for langchain.utilities.brave_search
import json
import requests
from pydantic import BaseModel, Field
[docs]class BraveSearchWrapper(BaseModel):
api_key: str
search_kwargs: dict = Field(default_factory=dict)
[docs] def run(self, query: str) -> str:
headers = {
"X-Subscription... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/brave_search.html |
a46e4d1fecb1-0 | Source code for langchain.utilities.wikipedia
"""Util that calls Wikipedia."""
import logging
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Extra, root_validator
from langchain.schema import Document
logger = logging.getLogger(__name__)
WIKIPEDIA_MAX_QUERY_LENGTH = 300
[docs]class Wikiped... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/wikipedia.html |
a46e4d1fecb1-1 | summaries = []
for page_title in page_titles[: self.top_k_results]:
if wiki_page := self._fetch_page(page_title):
if summary := self._formatted_page_summary(page_title, wiki_page):
summaries.append(summary)
if not summaries:
return "No good Wik... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/wikipedia.html |
a46e4d1fecb1-2 | except (
self.wiki_client.exceptions.PageError,
self.wiki_client.exceptions.DisambiguationError,
):
return None
[docs] def load(self, query: str) -> List[Document]:
"""
Run Wikipedia search and get the article text plus the meta information.
See
... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/wikipedia.html |
fa84a49ec24e-0 | Source code for langchain.utilities.zapier
"""Util that can interact with Zapier NLA.
Full docs here: https://nla.zapier.com/start/
Note: this wrapper currently only implemented the `api_key` auth method for testing
and server-side production use cases (using the developer's connected accounts on
Zapier.com)
For use-ca... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/zapier.html |
fa84a49ec24e-1 | your own provider and generate credentials.
"""
zapier_nla_api_key: str
zapier_nla_oauth_access_token: str
zapier_nla_api_base: str = "https://nla.zapier.com/api/v1/"
class Config:
"""Configuration for this pydantic object."""
extra = Extra.forbid
def _format_headers(self) -> Dic... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/zapier.html |
fa84a49ec24e-2 | {
"instructions": instructions,
}
)
if preview_only:
data.update({"preview_only": True})
return data
def _create_action_url(self, action_id: str) -> str:
"""Create a url for an action."""
return self.zapier_nla_api_base + f"exposed/{act... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/zapier.html |
fa84a49ec24e-3 | return values
[docs] async def alist(self) -> List[Dict]:
"""Returns a list of all exposed (enabled) actions associated with
current user (associated with the set api_key). Change your exposed
actions here: https://nla.zapier.com/demo/start/
The return list can be empty if no actions ... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/zapier.html |
fa84a49ec24e-4 | """
session = self._get_session()
try:
response = session.get(self.zapier_nla_api_base + "exposed/")
response.raise_for_status()
except requests.HTTPError as http_err:
if response.status_code == 401:
if self.zapier_nla_oauth_access_token:
... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/zapier.html |
fa84a49ec24e-5 | ) -> Dict:
"""Executes an action that is identified by action_id, must be exposed
(enabled) by the current user (associated with the set api_key). Change
your exposed actions here: https://nla.zapier.com/demo/start/
The return JSON is guaranteed to be less than ~500 words (350
to... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/zapier.html |
fa84a49ec24e-6 | response = await self._arequest(
"POST",
self._create_action_url(action_id),
json=self._create_action_payload(instructions, params, preview_only=True),
)
return response["result"]
[docs] def run_as_str(self, *args, **kwargs) -> str: # type: ignore[no-untyped-def]
... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/zapier.html |
fa84a49ec24e-7 | """Same as list, but returns a stringified version of the JSON for
insertting back into an LLM."""
actions = self.list()
return json.dumps(actions)
[docs] async def alist_as_str(self) -> str: # type: ignore[no-untyped-def]
"""Same as list, but returns a stringified version of the JSO... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/zapier.html |
7852bd69f34f-0 | Source code for langchain.utilities.powerbi
"""Wrapper around a Power BI endpoint."""
from __future__ import annotations
import asyncio
import logging
import os
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Union
import aiohttp
import requests
from aiohttp import ServerTimeoutError
from pydanti... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/powerbi.html |
7852bd69f34f-1 | """Fix the table names."""
return [fix_table_name(table) for table in table_names]
@root_validator(pre=True, allow_reuse=True)
def token_or_credential_present(cls, values: Dict[str, Any]) -> Dict[str, Any]:
"""Validate that at least one of token and credentials is present."""
if "token" ... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/powerbi.html |
7852bd69f34f-2 | "Could not get a token from the supplied credentials."
) from exc
raise ClientAuthenticationError("No credential or token supplied.")
[docs] def get_table_names(self) -> Iterable[str]:
"""Get names of tables available."""
return self.table_names
[docs] def get_schemas(self)... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/powerbi.html |
7852bd69f34f-3 | if isinstance(table_names, str) and table_names != "":
if table_names not in self.table_names:
_LOGGER.warning("Table %s not found in dataset.", table_names)
return None
return [fix_table_name(table_names)]
return self.table_names
def _... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/powerbi.html |
7852bd69f34f-4 | tables_todo = self._get_tables_todo(tables_requested)
await asyncio.gather(*[self._aget_schema(table) for table in tables_todo])
return self._get_schema_for_tables(tables_requested)
def _get_schema(self, table: str) -> None:
"""Get the schema for a table."""
try:
result =... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/powerbi.html |
7852bd69f34f-5 | self.schemas[table] = "unknown"
def _create_json_content(self, command: str) -> dict[str, Any]:
"""Create the json content for the request."""
return {
"queries": [{"query": rf"{command}"}],
"impersonatedUserName": self.impersonated_user_name,
"serializerSettings"... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/powerbi.html |
7852bd69f34f-6 | json_contents: List[Dict[str, Union[str, int, float]]],
table_name: Optional[str] = None,
) -> str:
"""Converts a JSON object to a markdown table."""
output_md = ""
headers = json_contents[0].keys()
for header in headers:
header.replace("[", ".").replace("]", "")
if table_name:
... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/powerbi.html |
1d8265495db5-0 | Source code for langchain.utilities.bibtex
"""Util that calls bibtexparser."""
import logging
from typing import Any, Dict, List, Mapping
from pydantic import BaseModel, Extra, root_validator
logger = logging.getLogger(__name__)
OPTIONAL_FIELDS = [
"annotate",
"booktitle",
"editor",
"howpublished",
... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/bibtex.html |
1d8265495db5-1 | import bibtexparser
with open(path) as file:
entries = bibtexparser.load(file).entries
return entries
[docs] def get_metadata(
self, entry: Mapping[str, Any], load_extra: bool = False
) -> Dict[str, Any]:
"""Get metadata for the given entry."""
publication = en... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/bibtex.html |
a994b8cfffcc-0 | Source code for langchain.utilities.python
import sys
from io import StringIO
from typing import Dict, Optional
from pydantic import BaseModel, Field
[docs]class PythonREPL(BaseModel):
"""Simulates a standalone Python REPL."""
globals: Optional[Dict] = Field(default_factory=dict, alias="_globals")
locals: O... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/python.html |
c0b54b49294e-0 | Source code for langchain.utilities.openweathermap
"""Util that calls OpenWeatherMap using PyOWM."""
from typing import Any, Dict, Optional
from pydantic import Extra, root_validator
from langchain.tools.base import BaseModel
from langchain.utils import get_from_dict_or_env
[docs]class OpenWeatherMapAPIWrapper(BaseMode... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/openweathermap.html |
c0b54b49294e-1 | heat_index = w.heat_index
clouds = w.clouds
return (
f"In {location}, the current weather is as follows:\n"
f"Detailed status: {detailed_status}\n"
f"Wind speed: {wind['speed']} m/s, direction: {wind['deg']}°\n"
f"Humidity: {humidity}%\n"
f"Tem... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/openweathermap.html |
a9555fcff753-0 | Source code for langchain.utilities.google_serper
"""Util that calls Google Search using the Serper.dev API."""
from typing import Any, Dict, List, Optional
import aiohttp
import requests
from pydantic.class_validators import root_validator
from pydantic.main import BaseModel
from typing_extensions import Literal
from ... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/google_serper.html |
a9555fcff753-1 | arbitrary_types_allowed = True
@root_validator()
def validate_environment(cls, values: Dict) -> Dict:
"""Validate that api key exists in environment."""
serper_api_key = get_from_dict_or_env(
values, "serper_api_key", "SERPER_API_KEY"
)
values["serper_api_key"] = serp... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/google_serper.html |
a9555fcff753-2 | """Run query through GoogleSearch and parse result async."""
results = await self._async_google_serper_search_results(
query,
gl=self.gl,
hl=self.hl,
num=self.k,
search_type=self.type,
tbs=self.tbs,
**kwargs,
)
r... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/google_serper.html |
a9555fcff753-3 | return ["No good Google Search Result was found"]
return snippets
def _parse_results(self, results: dict) -> str:
return " ".join(self._parse_snippets(results))
def _google_serper_api_results(
self, search_term: str, search_type: str = "search", **kwargs: Any
) -> dict:
heade... | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/google_serper.html |
a9555fcff753-4 | else:
async with self.aiosession.post(
url, params=params, headers=headers, raise_for_status=True
) as response:
search_results = await response.json()
return search_results | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/google_serper.html |
a3a7544cbaf9-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/latest/_modules/langchain/utilities/max_compute.html |
a3a7544cbaf9-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/latest/_modules/langchain/utilities/max_compute.html |
c99101d93200-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/latest/_modules/langchain/utilities/google_search.html |
c99101d93200-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/latest/_modules/langchain/utilities/google_search.html |
c99101d93200-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/latest/_modules/langchain/utilities/google_search.html |
c99101d93200-3 | metadata_result["snippet"] = result["snippet"]
metadata_results.append(metadata_result)
return metadata_results | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/google_search.html |
aad4504d1062-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/latest/_modules/langchain/utilities/arxiv.html |
aad4504d1062-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/latest/_modules/langchain/utilities/arxiv.html |
aad4504d1062-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/latest/_modules/langchain/utilities/arxiv.html |
aad4504d1062-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/latest/_modules/langchain/utilities/arxiv.html |
94eb0546b494-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/latest/_modules/langchain/utilities/wolfram_alpha.html |
94eb0546b494-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/latest/_modules/langchain/utilities/wolfram_alpha.html |
acfe0d4cb1a7-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/latest/_modules/langchain/utilities/graphql.html |
acfe0d4cb1a7-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/latest/_modules/langchain/utilities/graphql.html |
ec13144fcf3c-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/latest/_modules/langchain/utilities/openapi.html |
ec13144fcf3c-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/latest/_modules/langchain/utilities/openapi.html |
ec13144fcf3c-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/latest/_modules/langchain/utilities/openapi.html |
ec13144fcf3c-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/latest/_modules/langchain/utilities/openapi.html |
ec13144fcf3c-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/latest/_modules/langchain/utilities/openapi.html |
ec13144fcf3c-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/latest/_modules/langchain/utilities/openapi.html |
ec13144fcf3c-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/latest/_modules/langchain/utilities/openapi.html |
84d5f9b19804-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/latest/_modules/langchain/utilities/apify.html |
84d5f9b19804-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/latest/_modules/langchain/utilities/apify.html |
84d5f9b19804-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/latest/_modules/langchain/utilities/apify.html |
84d5f9b19804-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/latest/_modules/langchain/utilities/apify.html |
84d5f9b19804-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/latest/_modules/langchain/utilities/apify.html |
10275b7d5f2a-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/latest/_modules/langchain/utilities/jira.html |
10275b7d5f2a-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/latest/_modules/langchain/utilities/jira.html |
10275b7d5f2a-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/latest/_modules/langchain/utilities/jira.html |
10275b7d5f2a-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/latest/_modules/langchain/utilities/jira.html |
10275b7d5f2a-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/latest/_modules/langchain/utilities/jira.html |
b68f7bd371b5-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/latest/_modules/langchain/utilities/awslambda.html |
b68f7bd371b5-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/latest/_modules/langchain/utilities/awslambda.html |
c747911cb81d-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/latest/_modules/langchain/utilities/bing_search.html |
c747911cb81d-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/latest/_modules/langchain/utilities/bing_search.html |
c747911cb81d-2 | "snippet": result["snippet"],
"title": result["name"],
"link": result["url"],
}
metadata_results.append(metadata_result)
return metadata_results | https://api.python.langchain.com/en/latest/_modules/langchain/utilities/bing_search.html |
d3daa5164eb7-0 | Model I/O
LangChain provides interfaces and integrations for working with language models.
Prompts
Models
Output Parsers | https://api.python.langchain.com/en/stable/model_io.html |
b0729971b7ce-0 | Data connection
LangChain has a number of modules that help you load, structure, store, and retrieve documents.
Document Loaders
Document Transformers
Embeddings
Vector Stores
Retrievers | https://api.python.langchain.com/en/stable/data_connection.html |
8fcc09bdad6d-0 | Models
LangChain provides interfaces and integrations for a number of different types of models.
LLMs
Chat Models | https://api.python.langchain.com/en/stable/models.html |
941f37850735-0 | API Reference
Full documentation on all methods, classes, and APIs in the LangChain Python package.
Abstractions
Base classes
Core
Model I/O
Data connection
Chains
Agents
Memory
Callbacks
Additional
Utilities
Experimental | https://api.python.langchain.com/en/stable/index.html |
2cfb94a2e9a8-0 | Prompts
The reference guides here all relate to objects for working with Prompts.
Prompt Templates
Example Selector | https://api.python.langchain.com/en/stable/prompts.html |
86df0f796b6d-0 | Please activate JavaScript to enable the search functionality. | https://api.python.langchain.com/en/stable/search.html |
a1409c1b5e0f-0 | Index
_
| A
| B
| C
| D
| E
| F
| G
| H
| I
| J
| K
| L
| M
| N
| O
| P
| Q
| R
| S
| T
| U
| V
| W
| Y
| Z
_
__call__() (langchain.llms.AI21 method)
(langchain.llms.AlephAlpha method)
(langchain.llms.AmazonAPIGateway method)
(langchain.llms.Anthropic method)
(langchain.llms.Anyscale method)
(l... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-1 | (langchain.llms.LlamaCpp method)
(langchain.llms.ManifestWrapper method)
(langchain.llms.Modal method)
(langchain.llms.MosaicML method)
(langchain.llms.NLPCloud method)
(langchain.llms.OctoAIEndpoint method)
(langchain.llms.OpenAI method)
(langchain.llms.OpenAIChat method)
(langchain.llms.OpenLLM method)
(langchain.llm... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-2 | (langchain.chains.ConstitutionalChain method)
(langchain.chains.ConversationalRetrievalChain method)
(langchain.chains.ConversationChain method)
(langchain.chains.FlareChain method)
(langchain.chains.GraphCypherQAChain method)
(langchain.chains.GraphQAChain method)
(langchain.chains.HypotheticalDocumentEmbedder method)... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-3 | (langchain.chains.SimpleSequentialChain method)
(langchain.chains.SQLDatabaseChain method)
(langchain.chains.SQLDatabaseSequentialChain method)
(langchain.chains.StuffDocumentsChain method)
(langchain.chains.TransformChain method)
(langchain.chains.VectorDBQA method)
(langchain.chains.VectorDBQAWithSourcesChain method)... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-4 | (langchain.vectorstores.Hologres method)
add_example() (langchain.prompts.example_selector.LengthBasedExampleSelector method)
(langchain.prompts.example_selector.NGramOverlapExampleSelector method)
(langchain.prompts.example_selector.SemanticSimilarityExampleSelector method)
(langchain.prompts.LengthBasedExampleSelecto... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-5 | (langchain.vectorstores.AwaDB method)
(langchain.vectorstores.AzureSearch method)
(langchain.vectorstores.Cassandra method)
(langchain.vectorstores.Chroma method)
(langchain.vectorstores.Clarifai method)
(langchain.vectorstores.Clickhouse method)
(langchain.vectorstores.DeepLake method)
(langchain.vectorstores.ElasticV... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-6 | aembed_query() (langchain.embeddings.OpenAIEmbeddings method)
afrom_documents() (langchain.vectorstores.VectorStore class method)
afrom_texts() (langchain.vectorstores.VectorStore class method)
age (langchain.experimental.GenerativeAgent attribute)
agenerate() (langchain.chains.ConversationChain method)
(langchain.chai... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-7 | (langchain.llms.LlamaCpp method)
(langchain.llms.ManifestWrapper method)
(langchain.llms.Modal method)
(langchain.llms.MosaicML method)
(langchain.llms.NLPCloud method)
(langchain.llms.OctoAIEndpoint method)
(langchain.llms.OpenAI method)
(langchain.llms.OpenAIChat method)
(langchain.llms.OpenLLM method)
(langchain.llm... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-8 | (langchain.llms.CerebriumAI method)
(langchain.llms.Clarifai method)
(langchain.llms.Cohere method)
(langchain.llms.CTransformers method)
(langchain.llms.Databricks method)
(langchain.llms.DeepInfra method)
(langchain.llms.FakeListLLM method)
(langchain.llms.ForefrontAI method)
(langchain.llms.GooglePalm method)
(langc... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-9 | (langchain.llms.StochasticAI method)
(langchain.llms.TextGen method)
(langchain.llms.VertexAI method)
(langchain.llms.Writer method)
agent (langchain.agents.AgentExecutor attribute)
AgentAction (class in langchain.schema)
AgentFinish (class in langchain.schema)
AgentType (class in langchain.agents)
aget() (langchain.ut... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-10 | (langchain.retrievers.TFIDFRetriever method)
(langchain.retrievers.TimeWeightedVectorStoreRetriever method)
(langchain.retrievers.VespaRetriever method)
(langchain.retrievers.WeaviateHybridSearchRetriever method)
(langchain.retrievers.WikipediaRetriever method)
(langchain.retrievers.ZepRetriever method)
(langchain.retr... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-11 | (langchain.llms.AlephAlpha attribute)
AlibabaCloudOpenSearch (class in langchain.vectorstores)
AlibabaCloudOpenSearchSettings (class in langchain.vectorstores)
alist() (langchain.utilities.ZapierNLAWrapper method)
alist_as_str() (langchain.utilities.ZapierNLAWrapper method)
allow_download (langchain.llms.GPT4All attrib... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-12 | api_docs (langchain.chains.APIChain attribute)
api_key (langchain.memory.MotorheadMemory attribute)
(langchain.retrievers.AzureCognitiveSearchRetriever attribute)
(langchain.retrievers.DataberryRetriever attribute)
(langchain.utilities.BraveSearchWrapper attribute)
api_operation (langchain.chains.OpenAPIEndpointChain a... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-13 | (langchain.tools.WolframAlphaQueryRun attribute)
(langchain.tools.ZapierNLAListActions attribute)
(langchain.tools.ZapierNLARunAction attribute)
apify_client (langchain.document_loaders.ApifyDatasetLoader attribute)
(langchain.utilities.ApifyWrapper attribute)
apify_client_async (langchain.utilities.ApifyWrapper attrib... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-14 | (langchain.chains.LLMRouterChain method)
(langchain.chains.LLMSummarizationCheckerChain method)
(langchain.chains.MapReduceChain method)
(langchain.chains.MapReduceDocumentsChain method)
(langchain.chains.MapRerankDocumentsChain method)
(langchain.chains.MultiPromptChain method)
(langchain.chains.MultiRetrievalQAChain ... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-15 | (langchain.llms.Anthropic method)
(langchain.llms.Anyscale method)
(langchain.llms.Aviary method)
(langchain.llms.AzureMLOnlineEndpoint method)
(langchain.llms.AzureOpenAI method)
(langchain.llms.Banana method)
(langchain.llms.Baseten method)
(langchain.llms.Beam method)
(langchain.llms.Bedrock method)
(langchain.llms.... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-16 | (langchain.llms.PredictionGuard method)
(langchain.llms.PromptLayerOpenAI method)
(langchain.llms.PromptLayerOpenAIChat method)
(langchain.llms.Replicate method)
(langchain.llms.RWKV method)
(langchain.llms.SagemakerEndpoint method)
(langchain.llms.SelfHostedHuggingFaceLLM method)
(langchain.llms.SelfHostedPipeline met... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-17 | (langchain.llms.GooglePalm method)
(langchain.llms.GooseAI method)
(langchain.llms.GPT4All method)
(langchain.llms.HuggingFaceEndpoint method)
(langchain.llms.HuggingFaceHub method)
(langchain.llms.HuggingFacePipeline method)
(langchain.llms.HuggingFaceTextGenInference method)
(langchain.llms.HumanInputLLM method)
(lan... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-18 | apreview_as_str() (langchain.utilities.ZapierNLAWrapper method)
aput() (langchain.utilities.TextRequestsWrapper method)
arbitrary_types_allowed (langchain.experimental.BabyAGI.Config attribute)
(langchain.experimental.GenerativeAgent.Config attribute)
(langchain.retrievers.WeaviateHybridSearchRetriever.Config attribute... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-19 | (langchain.tools.ShellTool attribute)
(langchain.tools.SleepTool attribute)
(langchain.tools.StructuredTool attribute)
(langchain.tools.Tool attribute)
(langchain.tools.WriteFileTool attribute)
ArizeCallbackHandler (class in langchain.callbacks)
aroute() (langchain.chains.LLMRouterChain method)
(langchain.chains.Router... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-20 | (langchain.chains.OpenAIModerationChain method)
(langchain.chains.OpenAPIEndpointChain method)
(langchain.chains.PALChain method)
(langchain.chains.QAGenerationChain method)
(langchain.chains.QAWithSourcesChain method)
(langchain.chains.RefineDocumentsChain method)
(langchain.chains.RetrievalQA method)
(langchain.chain... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-21 | asearch() (langchain.vectorstores.VectorStore method)
asimilarity_search() (langchain.vectorstores.VectorStore method)
asimilarity_search_by_vector() (langchain.vectorstores.VectorStore method)
asimilarity_search_with_relevance_scores() (langchain.vectorstores.VectorStore method)
assignee (langchain.document_loaders.Gi... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-22 | base_embeddings (langchain.chains.HypotheticalDocumentEmbedder attribute)
base_prompt (langchain.tools.ZapierNLARunAction attribute)
base_retriever (langchain.retrievers.ContextualCompressionRetriever attribute)
base_url (langchain.document_loaders.BlackboardLoader attribute)
(langchain.llms.AI21 attribute)
(langchain.... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-23 | BlockchainDocumentLoader (class in langchain.document_loaders)
body_params (langchain.tools.APIOperation property)
browser (langchain.document_loaders.SeleniumURLLoader attribute)
bs_get_text_kwargs (langchain.document_loaders.WebBaseLoader attribute)
BSHTMLLoader (class in langchain.document_loaders)
buffer (langchain... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-24 | (langchain.chains.LLMRequestsChain attribute)
(langchain.chains.LLMRouterChain attribute)
(langchain.chains.LLMSummarizationCheckerChain attribute)
(langchain.chains.MapReduceChain attribute)
(langchain.chains.MapReduceDocumentsChain attribute)
(langchain.chains.MapRerankDocumentsChain attribute)
(langchain.chains.Mult... | https://api.python.langchain.com/en/stable/genindex.html |
a1409c1b5e0f-25 | (langchain.chains.ConversationChain attribute)
(langchain.chains.FlareChain attribute)
(langchain.chains.GraphCypherQAChain attribute)
(langchain.chains.GraphQAChain attribute)
(langchain.chains.HypotheticalDocumentEmbedder attribute)
(langchain.chains.KuzuQAChain attribute)
(langchain.chains.LLMBashChain attribute)
(l... | https://api.python.langchain.com/en/stable/genindex.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.