id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
28,130
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,131
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,132
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,133
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,134
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,135
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,136
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,137
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,138
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,139
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,140
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,141
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,142
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,143
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,144
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,145
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,146
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,147
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,148
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,149
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,150
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,151
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
null
28,152
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
Loads a tool from the HuggingFace Hub. Args: task_or_repo_id: Task or model repo id. model_repo_id: Optional model repo id. token: Optional token. remote: Optional remote. Defaults to False. **kwargs: Returns: A tool.
28,153
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
Load tools based on their name. Tools allow agents to interact with various resources and services like APIs, databases, file systems, etc. Please scope the permissions of each tools to the minimum required for the application. For example, if an application only needs to read from a database, the database tool should ...
28,154
import warnings from typing import Any, Dict, List, Optional, Callable, Tuple from mypy_extensions import Arg, KwArg from langchain_core.tools import Tool from langchain_core.language_models import BaseLanguageModel from langchain_core.callbacks import BaseCallbackManager from langchain_core.callbacks import Callbacks ...
Get a list of all possible tool names.
28,155
from __future__ import annotations import hashlib import json import uuid from functools import partial from typing import Callable, List, Sequence, Union, cast from langchain_core.embeddings import Embeddings from langchain_core.stores import BaseStore, ByteStore from langchain.storage.encoder_backed import EncoderBac...
Create an encoder for a key.
28,156
from __future__ import annotations import hashlib import json import uuid from functools import partial from typing import Callable, List, Sequence, Union, cast from langchain_core.embeddings import Embeddings from langchain_core.stores import BaseStore, ByteStore from langchain.storage.encoder_backed import EncoderBac...
Serialize a value.
28,157
from __future__ import annotations import hashlib import json import uuid from functools import partial from typing import Callable, List, Sequence, Union, cast from langchain_core.embeddings import Embeddings from langchain_core.stores import BaseStore, ByteStore from langchain.storage.encoder_backed import EncoderBac...
Deserialize a value.
28,158
from typing import Any, Dict, List, Optional, Sequence, Type, Union from langchain_community.chat_models.openai import ChatOpenAI from langchain_core.language_models import BaseLanguageModel from langchain.chains.base import Chain from langchain.evaluation.agents.trajectory_eval_chain import TrajectoryEvalChain from la...
Load a dataset from the `LangChainDatasets on HuggingFace <https://huggingface.co/LangChainDatasets>`_. Args: uri: The uri of the dataset to load. Returns: A list of dictionaries, each representing a row in the dataset. **Prerequisites** .. code-block:: shell pip install datasets Examples -------- .. code-block:: pytho...
28,159
from typing import Any, Dict, List, Optional, Sequence, Type, Union from langchain_community.chat_models.openai import ChatOpenAI from langchain_core.language_models import BaseLanguageModel from langchain.chains.base import Chain from langchain.evaluation.agents.trajectory_eval_chain import TrajectoryEvalChain from la...
Load evaluators specified by a list of evaluator types. Parameters ---------- evaluators : Sequence[EvaluatorType] The list of evaluator types to load. llm : BaseLanguageModel, optional The language model to use for evaluation, if none is provided, a default ChatOpenAI gpt-4 model will be used. config : dict, optional ...
28,160
from __future__ import annotations import logging import re from typing import Any, Dict, List, Optional, Union from langchain_community.chat_models.azure_openai import AzureChatOpenAI from langchain_community.chat_models.openai import ChatOpenAI from langchain_core.language_models import BaseLanguageModel from langcha...
Resolve the criteria for the pairwise evaluator. Args: criteria (Union[CRITERIA_TYPE, str], optional): The criteria to use. Returns: dict: The resolved criteria.
28,161
from __future__ import annotations import re import string from typing import Any, List, Optional, Sequence, Tuple from langchain_core.language_models import BaseLanguageModel from langchain_core.prompts import PromptTemplate from langchain_core.pydantic_v1 import Extra from langchain.callbacks.manager import Callbacks...
Parse the output text. Args: text (str): The output text to parse. Returns: Any: The parsed output.
28,162
from enum import Enum from typing import Any, Callable, Dict, List, Optional from langchain_core.pydantic_v1 import Field, root_validator from langchain.callbacks.manager import ( AsyncCallbackManagerForChainRun, CallbackManagerForChainRun, Callbacks, ) from langchain.chains.base import Chain from langchain...
Load the RapidFuzz library. Raises: ImportError: If the rapidfuzz library is not installed. Returns: Any: The rapidfuzz.distance module.
28,163
from __future__ import annotations import logging import re from typing import Any, Dict, List, Optional, Union from langchain_community.chat_models.azure_openai import AzureChatOpenAI from langchain_community.chat_models.openai import ChatOpenAI from langchain_core.language_models import BaseLanguageModel from langcha...
Resolve the criteria for the pairwise evaluator. Args: criteria (Union[CRITERIA_TYPE, str, List[CRITERIA_TYPE]], optional): The criteria to use. Returns: dict: The resolved criteria.
28,164
from __future__ import annotations import re from enum import Enum from typing import Any, Dict, List, Mapping, Optional, Union from langchain_core.language_models import BaseLanguageModel from langchain_core.output_parsers import BaseOutputParser from langchain_core.prompts import BasePromptTemplate from langchain_cor...
Resolve the criteria to evaluate. Parameters ---------- criteria : CRITERIA_TYPE The criteria to evaluate the runs against. It can be: - a mapping of a criterion name to its description - a single criterion name present in one of the default criteria - a single `ConstitutionalPrinciple` instance Returns ------- Dict[st...
28,165
from typing import Any, Dict, List The provided code snippet includes necessary dependencies for implementing the `get_prompt_input_key` function. Write a Python function `def get_prompt_input_key(inputs: Dict[str, Any], memory_variables: List[str]) -> str` to solve the following problem: Get the prompt input key. Arg...
Get the prompt input key. Args: inputs: Dict[str, Any] memory_variables: List[str] Returns: A prompt input key.
28,166
import platform from functools import lru_cache The provided code snippet includes necessary dependencies for implementing the `get_runtime_environment` function. Write a Python function `def get_runtime_environment() -> dict` to solve the following problem: Get information about the LangChain runtime environment. He...
Get information about the LangChain runtime environment.
28,167
from typing import Any, Dict, List, Optional, Type from langchain_community.document_loaders.base import BaseLoader from langchain_community.embeddings.openai import OpenAIEmbeddings from langchain_community.llms.openai import OpenAI from langchain_community.vectorstores.chroma import Chroma from langchain_core.documen...
null
28,168
from __future__ import annotations import hashlib import json import uuid from itertools import islice from typing import ( Any, AsyncIterable, AsyncIterator, Callable, Dict, Iterable, Iterator, List, Literal, Optional, Sequence, Set, TypedDict, TypeVar, Union...
Hashes a string and returns the corresponding UUID.
28,169
from __future__ import annotations import hashlib import json import uuid from itertools import islice from typing import ( Any, AsyncIterable, AsyncIterator, Callable, Dict, Iterable, Iterator, List, Literal, Optional, Sequence, Set, TypedDict, TypeVar, Union...
Hashes a nested dictionary and returns the corresponding UUID.
28,170
from __future__ import annotations import hashlib import json import uuid from itertools import islice from typing import ( Any, AsyncIterable, AsyncIterator, Callable, Dict, Iterable, Iterator, List, Literal, Optional, Sequence, Set, TypedDict, TypeVar, Union...
Index data from the loader into the vector store. Indexing functionality uses a manager to keep track of which documents are in the vector store. This allows us to keep track of which documents were updated, and which documents were deleted, which documents should be skipped. For the time being, documents are indexed u...
28,171
from __future__ import annotations import hashlib import json import uuid from itertools import islice from typing import ( Any, AsyncIterable, AsyncIterator, Callable, Dict, Iterable, Iterator, List, Literal, Optional, Sequence, Set, TypedDict, TypeVar, Union...
Index data from the loader into the vector store. Indexing functionality uses a manager to keep track of which documents are in the vector store. This allows us to keep track of which documents were updated, and which documents were deleted, which documents should be skipped. For the time being, documents are indexed u...
28,172
from typing import Callable, Optional from langchain_core.documents import Document from langchain_core.load import Serializable, dumps, loads from langchain_core.stores import BaseStore, ByteStore from langchain.storage.encoder_backed import EncoderBackedStore def _dump_as_bytes(obj: Serializable) -> bytes: """Ret...
Create a store for langchain serializable objects from a bytes store. Args: store: A bytes store to use as the underlying store. key_encoder: A function to encode keys; if None uses identity function. Returns: A key-value store for documents.
28,173
from typing import Callable, Optional from langchain_core.documents import Document from langchain_core.load import Serializable, dumps, loads from langchain_core.stores import BaseStore, ByteStore from langchain.storage.encoder_backed import EncoderBackedStore def _dump_document_as_bytes(obj: Document) -> bytes: "...
Create a store for langchain Document objects from a bytes store. This store does run time type checking to ensure that the values are Document objects. Args: store: A bytes store to use as the underlying store. key_encoder: A function to encode keys; if None uses identity function. Returns: A key-value store for docum...
28,174
from typing import Callable, List from langchain_core.tools import BaseTool from langchain_core.utils.function_calling import ( format_tool_to_openai_function, format_tool_to_openai_tool, ) class BaseTool(RunnableSerializable[Union[str, Dict], Any]): """Interface LangChain tools must implement.""" def...
Render the tool name and description in plain text. Output will be in the format of: .. code-block:: markdown search: This tool is used for search calculator: This tool is used for math
28,175
from typing import Callable, List from langchain_core.tools import BaseTool from langchain_core.utils.function_calling import ( format_tool_to_openai_function, format_tool_to_openai_tool, ) class BaseTool(RunnableSerializable[Union[str, Dict], Any]): """Interface LangChain tools must implement.""" def...
Render the tool name, description, and args in plain text. Output will be in the format of: .. code-block:: markdown search: This tool is used for search, args: {"query": {"type": "string"}} calculator: This tool is used for math, \ args: {"expression": {"type": "string"}}
28,176
from functools import partial from typing import Optional from langchain_core.callbacks.manager import ( Callbacks, ) from langchain_core.prompts import BasePromptTemplate, PromptTemplate, format_document from langchain_core.pydantic_v1 import BaseModel, Field from langchain_core.retrievers import BaseRetriever fro...
Create a tool to do retrieval of documents. Args: retriever: The retriever to use for the retrieval name: The name for the tool. This will be passed to the language model, so should be unique and somewhat descriptive. description: The description for the tool. This will be passed to the language model, so should be des...
28,177
The provided code snippet includes necessary dependencies for implementing the `is_interactive_env` function. Write a Python function `def is_interactive_env() -> bool` to solve the following problem: Determine if running within IPython or Jupyter. Here is the function: def is_interactive_env() -> bool: """Dete...
Determine if running within IPython or Jupyter.
28,178
from __future__ import annotations import logging import os import sys from typing import ( AbstractSet, Any, AsyncIterator, Collection, Dict, Iterator, List, Literal, Mapping, Optional, Set, Tuple, Union, ) import openai import tiktoken from langchain_core.callbacks ...
Update token usage.
28,179
from __future__ import annotations import logging import os import sys from typing import ( AbstractSet, Any, AsyncIterator, Collection, Dict, Iterator, List, Literal, Mapping, Optional, Set, Tuple, Union, ) import openai import tiktoken from langchain_core.callbacks ...
Convert a stream response to a generation chunk.
28,180
from __future__ import annotations import logging import os import sys from operator import itemgetter from typing import ( Any, AsyncIterator, Callable, Dict, Iterator, List, Literal, Mapping, Optional, Sequence, Tuple, Type, TypedDict, TypeVar, Union, ca...
Convert a dictionary to a LangChain message. Args: _dict: The dictionary. Returns: The LangChain message.
28,181
from __future__ import annotations import logging import os import sys from operator import itemgetter from typing import ( Any, AsyncIterator, Callable, Dict, Iterator, List, Literal, Mapping, Optional, Sequence, Tuple, Type, TypedDict, TypeVar, Union, ca...
Convert a LangChain message to a dictionary. Args: message: The LangChain message. Returns: The dictionary.
28,182
from __future__ import annotations import logging import os import sys from operator import itemgetter from typing import ( Any, AsyncIterator, Callable, Dict, Iterator, List, Literal, Mapping, Optional, Sequence, Tuple, Type, TypedDict, TypeVar, Union, ca...
null
28,183
from __future__ import annotations import logging import os import sys from operator import itemgetter from typing import ( Any, AsyncIterator, Callable, Dict, Iterator, List, Literal, Mapping, Optional, Sequence, Tuple, Type, TypedDict, TypeVar, Union, ca...
null
28,184
from enum import Enum from typing import List, Union import numpy as np def cosine_similarity(X: Matrix, Y: Matrix) -> np.ndarray: """Row-wise cosine similarity between two equal-width matrices.""" if len(X) == 0 or len(Y) == 0: return np.array([]) X = np.array(X) Y = np.array(Y) if X.shape[...
Calculate maximal marginal relevance.
28,185
import logging from typing import List, Union import numpy as np def cosine_similarity(X: Matrix, Y: Matrix) -> np.ndarray: """Row-wise cosine similarity between two equal-width matrices.""" if len(X) == 0 or len(Y) == 0: return np.array([]) X = np.array(X) Y = np.array(Y) if X.shape[1] != Y...
Calculate maximal marginal relevance.
28,186
import json import logging import time from importlib.metadata import version from typing import Any, Callable, Dict, Optional, Union from langchain_core.caches import RETURN_VAL_TYPE, BaseCache from langchain_core.embeddings import Embeddings from langchain_core.load.dump import dumps from langchain_core.load.load imp...
null
28,187
import json import logging import time from importlib.metadata import version from typing import Any, Callable, Dict, Optional, Union from langchain_core.caches import RETURN_VAL_TYPE, BaseCache from langchain_core.embeddings import Embeddings from langchain_core.load.dump import dumps from langchain_core.load.load imp...
Serialization for generic RETURN_VAL_TYPE, i.e. sequence of `Generation` Args: generations (RETURN_VAL_TYPE): A list of language model generations. Returns: str: a single string representing a list of generations. This function (+ its counterpart `_loads_generations`) rely on the dumps/loads pair with Reviver, so are a...
28,188
import json import logging import time from importlib.metadata import version from typing import Any, Callable, Dict, Optional, Union from langchain_core.caches import RETURN_VAL_TYPE, BaseCache from langchain_core.embeddings import Embeddings from langchain_core.load.dump import dumps from langchain_core.load.load imp...
Deserialization of a string into a generic RETURN_VAL_TYPE (i.e. a sequence of `Generation`). See `_dumps_generations`, the inverse of this function. Args: generations_str (str): A string representing a list of generations. Compatible with the legacy cache-blob format Does not raise exceptions for malformed entries, ju...
28,189
import json import logging import time from importlib.metadata import version from typing import Any, Callable, Dict, Optional, Union from langchain_core.caches import RETURN_VAL_TYPE, BaseCache from langchain_core.embeddings import Embeddings from langchain_core.load.dump import dumps from langchain_core.load.load imp...
Wait up to 10 seconds (by default) for predicate to be true. E.g.: wait_until(lambda: client.primary == ('a', 1), 'connect to the primary') If the lambda-expression isn't true after 10 seconds, we raise AssertionError("Didn't ever connect to the primary"). Returns the predicate's first true value.
28,190
from __future__ import annotations import importlib.util import logging from operator import itemgetter from typing import ( Any, AsyncIterator, Callable, Dict, Iterator, List, Optional, Sequence, Tuple, Type, Union, cast, ) from langchain_core._api import beta from langc...
null
28,191
from __future__ import annotations import importlib.util import logging from operator import itemgetter from typing import ( Any, AsyncIterator, Callable, Dict, Iterator, List, Optional, Sequence, Tuple, Type, Union, cast, ) from langchain_core._api import beta from langc...
Use tenacity to retry the async completion call.
28,192
from __future__ import annotations import importlib.util import logging from operator import itemgetter from typing import ( Any, AsyncIterator, Callable, Dict, Iterator, List, Optional, Sequence, Tuple, Type, Union, cast, ) from langchain_core._api import beta from langc...
null
28,193
from __future__ import annotations import importlib.util import logging from operator import itemgetter from typing import ( Any, AsyncIterator, Callable, Dict, Iterator, List, Optional, Sequence, Tuple, Type, Union, cast, ) from langchain_core._api import beta from langc...
null
28,194
from enum import Enum from typing import List, Union import numpy as np from elasticsearch import BadRequestError, ConflictError, Elasticsearch, NotFoundError from langchain_core import __version__ as langchain_version def with_user_agent_header(client: Elasticsearch, header_prefix: str) -> Elasticsearch: headers ...
null
28,195
from enum import Enum from typing import List, Union import numpy as np from elasticsearch import BadRequestError, ConflictError, Elasticsearch, NotFoundError from langchain_core import __version__ as langchain_version def cosine_similarity(X: Matrix, Y: Matrix) -> np.ndarray: """Row-wise cosine similarity between ...
Calculate maximal marginal relevance.
28,196
from enum import Enum from typing import List, Union import numpy as np from elasticsearch import BadRequestError, ConflictError, Elasticsearch, NotFoundError from langchain_core import __version__ as langchain_version def check_if_model_deployed(client: Elasticsearch, model_id: str) -> None: try: dummy = ...
null
28,197
from typing import Any, Dict, Optional from elasticsearch import Elasticsearch def create_elasticsearch_client( url: Optional[str] = None, cloud_id: Optional[str] = None, api_key: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, params: Optional[Dict[str, An...
null
28,198
from __future__ import annotations import logging import os from operator import itemgetter from typing import ( Any, AsyncIterator, Callable, Dict, Iterator, List, Literal, Mapping, Optional, Sequence, Tuple, Type, TypedDict, Union, cast, ) from fireworks.cli...
Convert a dictionary to a LangChain message. Args: _dict: The dictionary. Returns: The LangChain message.
28,199
from __future__ import annotations import logging import os from operator import itemgetter from typing import ( Any, AsyncIterator, Callable, Dict, Iterator, List, Literal, Mapping, Optional, Sequence, Tuple, Type, TypedDict, Union, cast, ) from fireworks.cli...
Convert a LangChain message to a dictionary. Args: message: The LangChain message. Returns: The dictionary.
28,200
from __future__ import annotations import logging import os from operator import itemgetter from typing import ( Any, AsyncIterator, Callable, Dict, Iterator, List, Literal, Mapping, Optional, Sequence, Tuple, Type, TypedDict, Union, cast, ) from fireworks.cli...
null
28,201
from __future__ import annotations import logging import os from operator import itemgetter from typing import ( Any, AsyncIterator, Callable, Dict, Iterator, List, Literal, Mapping, Optional, Sequence, Tuple, Type, TypedDict, Union, cast, ) from fireworks.cli...
null
28,202
import os from typing import Dict from exa_py import Exa from langchain_core.utils import convert_to_secret_str The provided code snippet includes necessary dependencies for implementing the `initialize_client` function. Write a Python function `def initialize_client(values: Dict) -> Dict` to solve the following prob...
Initialize the client.
28,203
from typing import Any, Dict, List, Literal, Optional, Union from exa_py import Exa from exa_py.api import HighlightsContentsOptions, TextContentsOptions from langchain_core.callbacks import CallbackManagerForRetrieverRun from langchain_core.documents import Document from langchain_core.pydantic_v1 import Field, Secr...
Get the metadata from a result object.
28,204
from __future__ import annotations import os import warnings from typing import ( Any, AsyncIterator, Dict, Iterator, List, Mapping, Optional, Tuple, Type, Union, cast, ) from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, )...
Convert a LangChain message to a dictionary. Args: message: The LangChain message. Returns: The dictionary.
28,205
from __future__ import annotations import os import warnings from typing import ( Any, AsyncIterator, Dict, Iterator, List, Mapping, Optional, Tuple, Type, Union, cast, ) from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, )...
null
28,206
from __future__ import annotations import os import warnings from typing import ( Any, AsyncIterator, Dict, Iterator, List, Mapping, Optional, Tuple, Type, Union, cast, ) from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, )...
Convert a dictionary to a LangChain message. Args: _dict: The dictionary. Returns: The LangChain message.
28,207
import os import re from typing import Any, AsyncIterator, Dict, Iterator, List, Optional, Tuple, Union import anthropic from langchain_core._api.deprecation import deprecated from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from langchain_core.language_models.ch...
Format messages for anthropic.
28,208
import json from typing import ( Any, AsyncIterator, Dict, Iterator, List, Optional, Sequence, Type, Union, cast, ) from langchain_core._api.beta_decorator import beta from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from l...
null
28,209
import json from typing import ( Any, AsyncIterator, Dict, Iterator, List, Optional, Sequence, Type, Union, cast, ) from langchain_core._api.beta_decorator import beta from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from l...
Convert an XML element and its children into a dictionary of dictionaries.
28,210
from dataclasses import dataclass from typing import List, Tuple from langchain_core.utils.json_schema import dereference_refs class ReducedOpenAPISpec: """A reduced OpenAPI spec. This is reduced representation for OpenAPI specs. Attributes: servers: The servers in the spec. description: The...
Simplify OpenAPI spec to only required information for the agent
28,211
from dataclasses import dataclass from typing import List, Tuple from langchain_core.utils.json_schema import dereference_refs The provided code snippet includes necessary dependencies for implementing the `get_required_param_descriptions` function. Write a Python function `def get_required_param_descriptions(endpoint...
Get an OpenAPI endpoint required parameter descriptions
28,212
from dataclasses import dataclass from typing import List, Tuple from langchain_core.utils.json_schema import dereference_refs type_mapping = { "string": str, "integer": int, "number": float, "object": dict, "array": list, "boolean": bool, "null": type(None), } The provided code snippet inc...
Get an OpenAPI endpoint parameter details
28,213
from itertools import islice from typing import Any, Iterator, List, Optional from ai21.models import EmbedType from langchain_core.embeddings import Embeddings from langchain_ai21.ai21_base import AI21Base def _split_texts_into_batches(texts: List[str], batch_size: int) -> Iterator[List[str]]: texts_itr = iter(te...
null
28,214
import asyncio from functools import partial from typing import Any, List, Mapping, Optional, Tuple, cast from ai21.models import ChatMessage, RoleType from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from langchain_core.language_models.chat_models import BaseCha...
null
28,215
import asyncio from functools import partial from typing import Any, List, Mapping, Optional, Tuple, cast from ai21.models import ChatMessage, RoleType from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from langchain_core.language_models.chat_models import BaseCha...
null
28,216
from fastapi import FastAPI from fastapi.responses import RedirectResponse from langserve import add_routes async def redirect_root_to_docs(): return RedirectResponse("/docs")
null
28,217
from typing import Optional import typer from typing_extensions import Annotated from langchain_cli.namespaces import app as app_namespace from langchain_cli.namespaces import integration as integration_namespace from langchain_cli.namespaces import template as template_namespace from langchain_cli.utils.packages impor...
null
28,218
from typing import Optional import typer from typing_extensions import Annotated from langchain_cli.namespaces import app as app_namespace from langchain_cli.namespaces import integration as integration_namespace from langchain_cli.namespaces import template as template_namespace from langchain_cli.utils.packages impor...
Start the LangServe app, whether it's a template or an app.
28,219
import shutil import subprocess import sys from pathlib import Path from typing import Dict, List, Optional, Tuple import typer from typing_extensions import Annotated from langchain_cli.utils.events import create_events from langchain_cli.utils.git import ( DependencySource, copy_repo, parse_dependencies, ...
Create a new LangServe application.
28,220
import shutil import subprocess import sys from pathlib import Path from typing import Dict, List, Optional, Tuple import typer from typing_extensions import Annotated from langchain_cli.utils.events import create_events from langchain_cli.utils.git import ( DependencySource, copy_repo, parse_dependencies, ...
Removes the specified package from the current LangServe app.
28,221
import shutil import subprocess import sys from pathlib import Path from typing import Dict, List, Optional, Tuple import typer from typing_extensions import Annotated from langchain_cli.utils.events import create_events from langchain_cli.utils.git import ( DependencySource, copy_repo, parse_dependencies, ...
Starts the LangServe app.
28,222
import re import shutil import subprocess from pathlib import Path from typing import Optional import typer from typing_extensions import Annotated from langchain_cli.utils.packages import get_langserve_export, get_package_root The provided code snippet includes necessary dependencies for implementing the `new` functi...
Creates a new template package.
28,223
import re import shutil import subprocess from pathlib import Path from typing import Optional import typer from typing_extensions import Annotated from langchain_cli.utils.packages import get_langserve_export, get_package_root def get_package_root(cwd: Optional[Path] = None) -> Path: # traverse path for routes to...
Starts a demo app for this template.
28,224
import re import shutil import subprocess from pathlib import Path from typing import Optional import typer from typing_extensions import Annotated from langchain_cli.utils.packages import get_langserve_export, get_package_root def list_packages(*, contains: Optional[str] = None): conn = http.client.HTTPSConnectio...
List all or search for available templates.
28,225
import re import shutil import subprocess from pathlib import Path from typing import Optional import typer from typing_extensions import Annotated, TypedDict from langchain_cli.utils.find_replace import replace_glob def _process_name(name: str): preprocessed = name.replace("_", "-").lower() if preprocessed.sta...
Creates a new integration package. Should be run from libs/partners
28,226
from typing import Sequence from fastapi import FastAPI from langserve import add_routes from langchain_cli.utils.packages import get_langserve_export, get_package_root def create_demo_server( *, config_keys: Sequence[str] = (), ): """ Creates a demo server for the current template. """ app = Fa...
null
28,227
from __future__ import annotations import re from typing import Any, List, Optional from langchain_text_splitters.base import Language, TextSplitter def _split_text_with_regex( text: str, separator: str, keep_separator: bool ) -> List[str]: # Now that we have the separator, split the text if separator: ...
null
28,228
from __future__ import annotations from typing import Any, List from langchain_text_splitters.base import TextSplitter def _make_spacy_pipeline_for_splitting( pipeline: str, *, max_length: int = 1_000_000 ) -> Any: # avoid importing spacy try: import spacy except ImportError: raise ImportE...
null
28,229
from __future__ import annotations import copy import logging from abc import ABC, abstractmethod from dataclasses import dataclass from enum import Enum from typing import ( AbstractSet, Any, Callable, Collection, Iterable, List, Literal, Optional, Sequence, Type, TypeVar, ...
Split incoming text and return chunks using tokenizer.