id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
27,930
import contextlib import functools import inspect import warnings from typing import Any, Callable, Generator, Type, TypeVar from langchain_core._api.internal import is_caller_internal class LangChainBetaWarning(DeprecationWarning): """A class for issuing beta warnings for LangChain users.""" The provided code sni...
Unmute LangChain beta warnings.
27,931
import os from pathlib import Path from typing import Optional, Union PACKAGE_DIR = HERE.parent SEPARATOR = os.sep def get_relative_path( file: Union[Path, str], *, relative_to: Path = PACKAGE_DIR ) -> str: """Get the path of the file as a relative path to the package directory.""" if isinstance(file, str):...
Path of the file as a LangChain import exclude langchain top namespace.
27,932
import contextlib import functools import inspect import warnings from typing import Any, Callable, Generator, Type, TypeVar from langchain_core._api.internal import is_caller_internal T = TypeVar("T", Type, Callable) def warn_deprecated( since: str, *, message: str = "", name: str = "", alternative...
Decorator to mark a function, a class, or a property as deprecated. When deprecating a classmethod, a staticmethod, or a property, the ``@deprecated`` decorator should go *under* ``@classmethod`` and ``@staticmethod`` (i.e., `deprecated` should directly decorate the underlying callable), but *over* ``@property``. When ...
27,933
import contextlib import functools import inspect import warnings from typing import Any, Callable, Generator, Type, TypeVar from langchain_core._api.internal import is_caller_internal class LangChainDeprecationWarning(DeprecationWarning): """A class for issuing deprecation warnings for LangChain users.""" class La...
Context manager to suppress LangChainDeprecationWarning.
27,934
import contextlib import functools import inspect import warnings from typing import Any, Callable, Generator, Type, TypeVar from langchain_core._api.internal import is_caller_internal class LangChainDeprecationWarning(DeprecationWarning): """A class for issuing deprecation warnings for LangChain users.""" class La...
Unmute LangChain deprecation warnings.
27,935
from __future__ import annotations import enum import threading from abc import abstractmethod from typing import ( Any, AsyncIterator, Callable, Dict, Iterator, List, Optional, Sequence, Tuple, Type, Union, cast, ) from weakref import WeakValueDictionary from langchain_c...
str.removeprefix() is only available in Python 3.9+.
27,936
from __future__ import annotations import enum import threading from abc import abstractmethod from typing import ( Any, AsyncIterator, Callable, Dict, Iterator, List, Optional, Sequence, Tuple, Type, Union, cast, ) from weakref import WeakValueDictionary from langchain_c...
Prefix the id of a ConfigurableFieldSpec. This is useful when a RunnableConfigurableAlternatives is used as a ConfigurableField of another RunnableConfigurableAlternatives. Args: spec: The ConfigurableFieldSpec to prefix. prefix: The prefix to add. Returns:
27,937
from __future__ import annotations import enum import threading from abc import abstractmethod from typing import ( Any, AsyncIterator, Callable, Dict, Iterator, List, Optional, Sequence, Tuple, Type, Union, cast, ) from weakref import WeakValueDictionary from langchain_c...
Make a ConfigurableFieldSpec for a ConfigurableFieldSingleOption or ConfigurableFieldMultiOption.
27,938
from __future__ import annotations import ast import asyncio import inspect import textwrap from functools import lru_cache from inspect import signature from itertools import groupby from typing import ( Any, AsyncIterable, Callable, Coroutine, Dict, Iterable, List, Mapping, NamedTu...
Check if a callable accepts a context argument.
27,939
from __future__ import annotations import ast import asyncio import inspect import textwrap from functools import lru_cache from inspect import signature from itertools import groupby from typing import ( Any, AsyncIterable, Callable, Coroutine, Dict, Iterable, List, Mapping, NamedTu...
Get the keys of the first argument of a function if it is a dict.
27,940
from __future__ import annotations import ast import asyncio import inspect import textwrap from functools import lru_cache from inspect import signature from itertools import groupby from typing import ( Any, AsyncIterable, Callable, Coroutine, Dict, Iterable, List, Mapping, NamedTu...
Get the source code of a lambda function. Args: func: a callable that can be a lambda function Returns: str: the source code of the lambda function
27,941
from __future__ import annotations import ast import asyncio import inspect import textwrap from functools import lru_cache from inspect import signature from itertools import groupby from typing import ( Any, AsyncIterable, Callable, Coroutine, Dict, Iterable, List, Mapping, NamedTu...
Get the nonlocal variables accessed by a function.
27,942
from __future__ import annotations import ast import asyncio import inspect import textwrap from functools import lru_cache from inspect import signature from itertools import groupby from typing import ( Any, AsyncIterable, Callable, Coroutine, Dict, Iterable, List, Mapping, NamedTu...
Indent all lines of text after the first line. Args: text: The text to indent prefix: Used to determine the number of spaces to indent Returns: str: The indented text
27,943
from __future__ import annotations import ast import asyncio import inspect import textwrap from functools import lru_cache from inspect import signature from itertools import groupby from typing import ( Any, AsyncIterable, Callable, Coroutine, Dict, Iterable, List, Mapping, NamedTu...
Asynchronously add a sequence of addable objects together.
27,944
from __future__ import annotations import ast import asyncio import inspect import textwrap from functools import lru_cache from inspect import signature from itertools import groupby from typing import ( Any, AsyncIterable, Callable, Coroutine, Dict, Iterable, List, Mapping, NamedTu...
Get the unique config specs from a sequence of config specs.
27,945
from __future__ import annotations import ast import asyncio import inspect import textwrap from functools import lru_cache from inspect import signature from itertools import groupby from typing import ( Any, AsyncIterable, Callable, Coroutine, Dict, Iterable, List, Mapping, NamedTu...
This might transform the first chunk of a stream into an AddableDict.
27,946
import math import os from typing import Any, Mapping, Sequence, Tuple class AsciiCanvas: """Class for drawing in ASCII. Args: cols (int): number of columns in the canvas. Should be > 1. lines (int): number of lines in the canvas. Should be > 1. """ TIMEOUT = 10 def __init__(self, co...
Build a DAG and draw it in ASCII. Args: vertices (list): list of graph vertices. edges (list): list of graph edges. Returns: str: ASCII representation Example: >>> from dvc.dagascii import draw >>> vertices = [1, 2, 3, 4] >>> edges = [(1, 2), (2, 3), (2, 4), (1, 4)] >>> print(draw(vertices, edges)) +---+ +---+ | 3 | | ...
27,947
from __future__ import annotations import asyncio import inspect import threading from typing import ( TYPE_CHECKING, Any, AsyncIterator, Awaitable, Callable, Dict, Iterator, List, Mapping, Optional, Type, Union, cast, ) from langchain_core.pydantic_v1 import BaseMode...
Identity function
27,948
from __future__ import annotations import asyncio import inspect import threading from typing import ( TYPE_CHECKING, Any, AsyncIterator, Awaitable, Callable, Dict, Iterator, List, Mapping, Optional, Type, Union, cast, ) from langchain_core.pydantic_v1 import BaseMode...
Async identity function
27,949
from __future__ import annotations import asyncio import uuid import warnings from concurrent.futures import Executor, Future, ThreadPoolExecutor from contextlib import contextmanager from contextvars import ContextVar, copy_context from functools import partial from typing import ( TYPE_CHECKING, Any, Awai...
Get a list of configs from a single config or a list of configs. It is useful for subclasses overriding batch() or abatch(). Args: config (Optional[Union[RunnableConfig, List[RunnableConfig]]]): The config or list of configs. length (int): The length of the list. Returns: List[RunnableConfig]: The list of configs. Rais...
27,950
from __future__ import annotations import asyncio import uuid import warnings from concurrent.futures import Executor, Future, ThreadPoolExecutor from contextlib import contextmanager from contextvars import ContextVar, copy_context from functools import partial from typing import ( TYPE_CHECKING, Any, Awai...
Merge multiple configs into one. Args: *configs (Optional[RunnableConfig]): The configs to merge. Returns: RunnableConfig: The merged config.
27,951
from __future__ import annotations import asyncio import uuid import warnings from concurrent.futures import Executor, Future, ThreadPoolExecutor from contextlib import contextmanager from contextvars import ContextVar, copy_context from functools import partial from typing import ( TYPE_CHECKING, Any, Awai...
Call function that may optionally accept a run_manager and/or config. Args: func (Union[Callable[[Input], Output], Callable[[Input, CallbackManagerForChainRun], Output], Callable[[Input, CallbackManagerForChainRun, RunnableConfig], Output]]): The function to call. input (Input): The input to the function. run_manager (...
27,952
from __future__ import annotations import asyncio import uuid import warnings from concurrent.futures import Executor, Future, ThreadPoolExecutor from contextlib import contextmanager from contextvars import ContextVar, copy_context from functools import partial from typing import ( TYPE_CHECKING, Any, Awai...
Call function that may optionally accept a run_manager and/or config. Args: func (Union[Callable[[Input], Awaitable[Output]], Callable[[Input, AsyncCallbackManagerForChainRun], Awaitable[Output]], Callable[[Input, AsyncCallbackManagerForChainRun, RunnableConfig], Awaitable[Output]]]): The function to call. input (Input...
27,953
from __future__ import annotations import asyncio import uuid import warnings from concurrent.futures import Executor, Future, ThreadPoolExecutor from contextlib import contextmanager from contextvars import ContextVar, copy_context from functools import partial from typing import ( TYPE_CHECKING, Any, Awai...
Get a callback manager for a config. Args: config (RunnableConfig): The config. Returns: CallbackManager: The callback manager.
27,954
from __future__ import annotations import asyncio import uuid import warnings from concurrent.futures import Executor, Future, ThreadPoolExecutor from contextlib import contextmanager from contextvars import ContextVar, copy_context from functools import partial from typing import ( TYPE_CHECKING, Any, Awai...
Get an async callback manager for a config. Args: config (RunnableConfig): The config. Returns: AsyncCallbackManager: The async callback manager.
27,955
from __future__ import annotations import inspect from dataclasses import dataclass, field from typing import ( TYPE_CHECKING, Any, Dict, List, NamedTuple, Optional, Type, TypedDict, Union, overload, ) from uuid import UUID, uuid4 from langchain_core.pydantic_v1 import BaseModel ...
null
27,956
from __future__ import annotations import asyncio import collections import inspect import threading from abc import ABC, abstractmethod from concurrent.futures import FIRST_COMPLETED, wait from contextvars import copy_context from functools import wraps from itertools import groupby, tee from operator import itemgette...
null
27,957
from __future__ import annotations import asyncio import collections import inspect import threading from abc import ABC, abstractmethod from concurrent.futures import FIRST_COMPLETED, wait from contextvars import copy_context from functools import wraps from itertools import groupby, tee from operator import itemgette...
null
27,958
from __future__ import annotations import asyncio import collections import inspect import threading from abc import ABC, abstractmethod from concurrent.futures import FIRST_COMPLETED, wait from contextvars import copy_context from functools import wraps from itertools import groupby, tee from operator import itemgette...
null
27,959
from __future__ import annotations import asyncio import collections import inspect import threading from abc import ABC, abstractmethod from concurrent.futures import FIRST_COMPLETED, wait from contextvars import copy_context from functools import wraps from itertools import groupby, tee from operator import itemgette...
null
27,960
from __future__ import annotations import asyncio import collections import inspect import threading from abc import ABC, abstractmethod from concurrent.futures import FIRST_COMPLETED, wait from contextvars import copy_context from functools import wraps from itertools import groupby, tee from operator import itemgette...
null
27,961
from __future__ import annotations import asyncio import collections import inspect import threading from abc import ABC, abstractmethod from concurrent.futures import FIRST_COMPLETED, wait from contextvars import copy_context from functools import wraps from itertools import groupby, tee from operator import itemgette...
null
27,962
from __future__ import annotations import asyncio import collections import inspect import threading from abc import ABC, abstractmethod from concurrent.futures import FIRST_COMPLETED, wait from contextvars import copy_context from functools import wraps from itertools import groupby, tee from operator import itemgette...
Decorate a function to make it a Runnable. Sets the name of the runnable to the name of the function. Any runnables called by the function will be traced as dependencies. Args: func: A callable. Returns: A Runnable. Example: .. code-block:: python from langchain_core.runnables import chain from langchain_core.prompts i...
27,963
from __future__ import annotations import inspect from typing import ( TYPE_CHECKING, Any, Callable, Dict, List, Optional, Sequence, Type, Union, ) from langchain_core.chat_history import BaseChatMessageHistory from langchain_core.load.load import load from langchain_core.pydantic_v1...
Get the parameter names of the callable.
27,964
import logging import re from typing import List, Optional, Sequence, Union from urllib.parse import urljoin, urlparse logger = logging.getLogger(__name__) def find_all_links( raw_html: str, *, pattern: Union[str, re.Pattern, None] = None ) -> List[str]: """Extract all links from a raw html string. Args: ...
Extract all links from a raw html string and convert into absolute paths. Args: raw_html: original html. url: the url of the html. base_url: the base url to check for outside links against. pattern: Regex to use for extracting links from raw html. prevent_outside: If True, ignore external links which are not children o...
27,965
import contextlib import datetime import functools import importlib import warnings from importlib.metadata import version from typing import Any, Callable, Dict, Optional, Set, Tuple, Union from packaging.version import parse from requests import HTTPError, Response from langchain_core.pydantic_v1 import SecretStr Th...
Validate specified keyword args are mutually exclusive.
27,966
import contextlib import datetime import functools import importlib import warnings from importlib.metadata import version from typing import Any, Callable, Dict, Optional, Set, Tuple, Union from packaging.version import parse from requests import HTTPError, Response from langchain_core.pydantic_v1 import SecretStr Th...
Raise an error with the response text.
27,967
import contextlib import datetime import functools import importlib import warnings from importlib.metadata import version from typing import Any, Callable, Dict, Optional, Set, Tuple, Union from packaging.version import parse from requests import HTTPError, Response from langchain_core.pydantic_v1 import SecretStr Th...
Context manager for mocking out datetime.now() in unit tests. Example: with mock_now(datetime.datetime(2011, 2, 3, 10, 11)): assert datetime.datetime.now() == datetime.datetime(2011, 2, 3, 10, 11)
27,968
import contextlib import datetime import functools import importlib import warnings from importlib.metadata import version from typing import Any, Callable, Dict, Optional, Set, Tuple, Union from packaging.version import parse from requests import HTTPError, Response from langchain_core.pydantic_v1 import SecretStr Th...
Dynamically imports a module and raises a helpful exception if the module is not installed.
27,969
import contextlib import datetime import functools import importlib import warnings from importlib.metadata import version from typing import Any, Callable, Dict, Optional, Set, Tuple, Union from packaging.version import parse from requests import HTTPError, Response from langchain_core.pydantic_v1 import SecretStr Th...
Check the version of a package.
27,970
import contextlib import datetime import functools import importlib import warnings from importlib.metadata import version from typing import Any, Callable, Dict, Optional, Set, Tuple, Union from packaging.version import parse from requests import HTTPError, Response from langchain_core.pydantic_v1 import SecretStr Th...
Get field names, including aliases, for a pydantic class. Args: pydantic_cls: Pydantic class.
27,971
import contextlib import datetime import functools import importlib import warnings from importlib.metadata import version from typing import Any, Callable, Dict, Optional, Set, Tuple, Union from packaging.version import parse from requests import HTTPError, Response from langchain_core.pydantic_v1 import SecretStr Th...
Build extra kwargs from values and extra_kwargs. Args: extra_kwargs: Extra kwargs passed in by user. values: Values passed in by user. all_required_field_names: All required field names for the pydantic class.
27,972
import contextlib import datetime import functools import importlib import warnings from importlib.metadata import version from typing import Any, Callable, Dict, Optional, Set, Tuple, Union from packaging.version import parse from requests import HTTPError, Response from langchain_core.pydantic_v1 import SecretStr Th...
Convert a string to a SecretStr if needed.
27,973
from __future__ import annotations from typing import Any, Dict The provided code snippet includes necessary dependencies for implementing the `merge_dicts` function. Write a Python function `def merge_dicts(left: Dict[str, Any], right: Dict[str, Any]) -> Dict[str, Any]` to solve the following problem: Merge two dicts...
Merge two dicts, handling specific scenarios where a key exists in both dictionaries but has a value of None in 'left'. In such cases, the method uses the value from 'right' for that key in the merged dictionary. Example: If left = {"function_call": {"arguments": None}} and right = {"function_call": {"arguments": "{\n"...
27,974
from typing import Dict, List, Optional, TextIO _TEXT_COLOR_MAPPING = { "blue": "36;1", "yellow": "33;1", "pink": "38;5;200", "green": "32;1", "red": "31;1", } The provided code snippet includes necessary dependencies for implementing the `get_color_mapping` function. Write a Python function `def g...
Get mapping for items to a support color.
27,975
from typing import Dict, List, Optional, TextIO The provided code snippet includes necessary dependencies for implementing the `get_bolded_text` function. Write a Python function `def get_bolded_text(text: str) -> str` to solve the following problem: Get bolded text. Here is the function: def get_bolded_text(text: s...
Get bolded text.
27,976
from typing import Dict, List, Optional, TextIO def get_colored_text(text: str, color: str) -> str: """Get colored text.""" color_str = _TEXT_COLOR_MAPPING[color] return f"\u001b[{color_str}m\033[1;3m{text}\u001b[0m" The provided code snippet includes necessary dependencies for implementing the `print_text...
Print text with highlighting and no end characters.
27,977
from __future__ import annotations import inspect from typing import ( TYPE_CHECKING, Any, Callable, Dict, List, Literal, Optional, Tuple, Type, Union, cast, ) from typing_extensions import TypedDict from langchain_core._api import deprecated from langchain_core.pydantic_v1 i...
Converts a Pydantic model to a function description for the OpenAI API.
27,978
from __future__ import annotations import inspect from typing import ( TYPE_CHECKING, Any, Callable, Dict, List, Literal, Optional, Tuple, Type, Union, cast, ) from typing_extensions import TypedDict from langchain_core._api import deprecated from langchain_core.pydantic_v1 i...
Format tool into the OpenAI function API.
27,979
The provided code snippet includes necessary dependencies for implementing the `get_pydantic_major_version` function. Write a Python function `def get_pydantic_major_version() -> int` to solve the following problem: Get the major version of Pydantic. Here is the function: def get_pydantic_major_version() -> int: ...
Get the major version of Pydantic.
27,980
import base64 import mimetypes def encode_image(image_path: str) -> str: """Get base64 string from image URI.""" with open(image_path, "rb") as image_file: return base64.b64encode(image_file.read()).decode("utf-8") def image_to_data_url(image_path: str) -> str: encoding = encode_image(image_path) ...
null
27,981
from collections import deque from itertools import islice from typing import ( Any, ContextManager, Deque, Generator, Generic, Iterable, Iterator, List, Optional, Tuple, TypeVar, Union, overload, ) from typing_extensions import Literal T = TypeVar("T") The provided ...
An individual iterator of a :py:func:`~.tee`
27,982
from collections import deque from itertools import islice from typing import ( Any, ContextManager, Deque, Generator, Generic, Iterable, Iterator, List, Optional, Tuple, TypeVar, Union, overload, ) from typing_extensions import Literal T = TypeVar("T") The provided ...
Utility batching function.
27,983
from __future__ import annotations import os from typing import Any, Dict, Optional def get_from_env(key: str, env_key: str, default: Optional[str] = None) -> str: """Get a value from a dictionary or an environment variable.""" if env_key in os.environ and os.environ[env_key]: return os.environ[env_key]...
Get a value from a dictionary or an environment variable.
27,984
from collections import deque from typing import ( Any, AsyncContextManager, AsyncGenerator, AsyncIterator, Awaitable, Callable, Deque, Generic, Iterator, List, Optional, Tuple, TypeVar, Union, cast, overload, ) T = TypeVar("T") _no_default = object() The...
Pure-Python implementation of anext() for testing purposes. Closely matches the builtin anext() C implementation. Can be used to compare the built-in implementation of the inner coroutines machinery to C-implementation of __anext__() and send() or throw() on the returned generator.
27,985
from collections import deque from typing import ( Any, AsyncContextManager, AsyncGenerator, AsyncIterator, Awaitable, Callable, Deque, Generic, Iterator, List, Optional, Tuple, TypeVar, Union, cast, overload, ) T = TypeVar("T") The provided code snippet ...
An individual iterator of a :py:func:`~.tee`
27,986
from typing import Any, List The provided code snippet includes necessary dependencies for implementing the `comma_list` function. Write a Python function `def comma_list(items: List[Any]) -> str` to solve the following problem: Convert a list to a comma-separated string. Here is the function: def comma_list(items: ...
Convert a list to a comma-separated string.
27,987
from langchain.output_parsers.regex import RegexParser The provided code snippet includes necessary dependencies for implementing the `load_output_parser` function. Write a Python function `def load_output_parser(config: dict) -> dict` to solve the following problem: Load an output parser. Args: config: config dict Re...
Load an output parser. Args: config: config dict Returns: config dict with output parser loaded
27,988
from __future__ import annotations from typing import Any, List from langchain_core.output_parsers import BaseOutputParser from langchain_core.output_parsers.json import parse_and_check_json_markdown from langchain_core.pydantic_v1 import BaseModel from langchain.output_parsers.format_instructions import ( STRUCTUR...
null
27,989
import random from datetime import datetime, timedelta from typing import List from langchain_core.exceptions import OutputParserException from langchain_core.output_parsers import BaseOutputParser from langchain_core.utils import comma_list The provided code snippet includes necessary dependencies for implementing th...
Generates n random datetime strings conforming to the given pattern within the specified date range. Pattern should be a string containing the desired format codes. start_date and end_date should be datetime objects representing the start and end of the date range.
27,990
from __future__ import annotations import json from typing import TYPE_CHECKING, Any, Optional from langchain_core.load.dump import dumps from langchain_core.load.load import loads from langchain_core.prompts import BasePromptTemplate def _get_client(api_url: Optional[str] = None, api_key: Optional[str] = None) -> Clie...
Pushes an object to the hub and returns the URL it can be viewed at in a browser. :param repo_full_name: The full name of the repo to push to in the format of `owner/repo`. :param object: The LangChain to serialize and push to the hub. :param api_url: The URL of the LangChain Hub API. Defaults to the hosted API service...
27,991
from __future__ import annotations import json from typing import TYPE_CHECKING, Any, Optional from langchain_core.load.dump import dumps from langchain_core.load.load import loads from langchain_core.prompts import BasePromptTemplate def _get_client(api_url: Optional[str] = None, api_key: Optional[str] = None) -> Clie...
Pulls an object from the hub and returns it as a LangChain object. :param owner_repo_commit: The full name of the repo to pull from in the format of `owner/repo:commit_hash`. :param api_url: The URL of the LangChain Hub API. Defaults to the hosted API service if you have an api key set, or a localhost instance if not. ...
27,992
from abc import ABC, abstractmethod from typing import Callable, List, Tuple from langchain_core.language_models import BaseLanguageModel from langchain_core.language_models.chat_models import BaseChatModel from langchain_core.language_models.llms import BaseLLM from langchain_core.prompts import BasePromptTemplate fro...
Check if the language model is a LLM. Args: llm: Language model to check. Returns: True if the language model is a BaseLLM model, False otherwise.
27,993
from abc import ABC, abstractmethod from typing import Callable, List, Tuple from langchain_core.language_models import BaseLanguageModel from langchain_core.language_models.chat_models import BaseChatModel from langchain_core.language_models.llms import BaseLLM from langchain_core.prompts import BasePromptTemplate fro...
Check if the language model is a chat model. Args: llm: Language model to check. Returns: True if the language model is a BaseChatModel model, False otherwise.
27,994
from __future__ import annotations from typing import Any, Dict, List, Optional, Sequence, Tuple from urllib.parse import urlparse from langchain_community.utilities.requests import TextRequestsWrapper from langchain_core.callbacks import ( AsyncCallbackManagerForChainRun, CallbackManagerForChainRun, ) from lan...
Check if a URL is in the allowed domains. Args: url (str): The input URL. limit_to_domains (Sequence[str]): The allowed domains. Returns: bool: True if the URL is in the allowed domains, False otherwise.
27,995
from __future__ import annotations import re from typing import Any, Dict, List, Optional from langchain_community.graphs import NeptuneGraph from langchain_core.callbacks import CallbackManagerForChainRun from langchain_core.language_models import BaseLanguageModel from langchain_core.prompts.base import BasePromptTem...
Trim the query to only include Cypher keywords.
27,996
from __future__ import annotations import re from typing import Any, Dict, List, Optional from langchain_community.graphs import NeptuneGraph from langchain_core.callbacks import CallbackManagerForChainRun from langchain_core.language_models import BaseLanguageModel from langchain_core.prompts.base import BasePromptTem...
Extract Cypher code from text using Regex.
27,997
from __future__ import annotations import re from typing import Any, Dict, List, Optional from langchain_community.graphs import NeptuneGraph from langchain_core.callbacks import CallbackManagerForChainRun from langchain_core.language_models import BaseLanguageModel from langchain_core.prompts.base import BasePromptTem...
Decides whether to use the simple prompt
27,998
from __future__ import annotations from typing import Any, Dict, List, Optional from langchain_community.graphs import GremlinGraph from langchain_core.callbacks.manager import CallbackManager, CallbackManagerForChainRun from langchain_core.language_models import BaseLanguageModel from langchain_core.prompts import Bas...
Extract Gremlin code from a text. Args: text: Text to extract Gremlin code from. Returns: Gremlin code extracted from the text.
27,999
from __future__ import annotations import re from typing import Any, Dict, List, Optional from langchain_community.graphs import FalkorDBGraph from langchain_core.callbacks import CallbackManagerForChainRun from langchain_core.language_models import BaseLanguageModel from langchain_core.prompts import BasePromptTemplat...
Extract Cypher code from a text. Args: text: Text to extract Cypher code from. Returns: Cypher code extracted from the text.
28,000
from __future__ import annotations import re from typing import Any, Dict, List, Optional from langchain_community.graphs.graph_store import GraphStore from langchain_core.callbacks import CallbackManagerForChainRun from langchain_core.language_models import BaseLanguageModel from langchain_core.prompts import BaseProm...
Extract Cypher code from a text. Args: text: Text to extract Cypher code from. Returns: Cypher code extracted from the text.
28,001
from __future__ import annotations import re from typing import Any, Dict, List, Optional from langchain_community.graphs.graph_store import GraphStore from langchain_core.callbacks import CallbackManagerForChainRun from langchain_core.language_models import BaseLanguageModel from langchain_core.prompts import BaseProm...
Filter the schema based on included or excluded types
28,002
from __future__ import annotations from typing import Any, Dict, List, Optional from langchain_community.graphs import NeptuneRdfGraph from langchain_core.language_models import BaseLanguageModel from langchain_core.prompts.base import BasePromptTemplate from langchain_core.prompts.prompt import PromptTemplate from lan...
null
28,003
import inspect from typing import ( Any, Callable, Dict, List, Optional, Sequence, Tuple, Type, Union, cast, ) from langchain_core.language_models import BaseLanguageModel from langchain_core.output_parsers import ( BaseGenerationOutputParser, BaseLLMOutputParser, Bas...
Create a runnable that uses an Ernie function to get a structured output. Args: output_schema: Either a dictionary or pydantic.BaseModel class. If a dictionary is passed in, it's assumed to already be a valid JsonSchema. For best results, pydantic.BaseModels should have docstrings describing what the schema represents ...
28,004
import inspect from typing import ( Any, Callable, Dict, List, Optional, Sequence, Tuple, Type, Union, cast, ) from langchain_core.language_models import BaseLanguageModel from langchain_core.output_parsers import ( BaseGenerationOutputParser, BaseLLMOutputParser, Bas...
[Legacy] Create an LLMChain that uses an Ernie function to get a structured output. Args: output_schema: Either a dictionary or pydantic.BaseModel class. If a dictionary is passed in, it's assumed to already be a valid JsonSchema. For best results, pydantic.BaseModels should have docstrings describing what the schema r...
28,005
from __future__ import annotations from typing import Any, Mapping, Optional, Protocol from langchain_core.language_models import BaseLanguageModel from langchain_core.prompts import BasePromptTemplate from langchain.chains.combine_documents.base import BaseCombineDocumentsChain from langchain.chains.combine_documents....
Load a question answering with sources chain. Args: llm: Language Model to use in the chain. chain_type: Type of document combining chain to use. Should be one of "stuff", "map_reduce", "refine" and "map_rerank". verbose: Whether chains should be run in verbose mode or not. Note that this applies to all chains that mak...
28,006
from __future__ import annotations import inspect import warnings from abc import abstractmethod from pathlib import Path from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union from langchain_core.callbacks import ( AsyncCallbackManagerForChainRun, CallbackManagerForChainRun, Callbacks, ...
null
28,007
from __future__ import annotations import warnings from typing import Any, Dict, List, Optional, Sequence, Tuple, Union, cast from langchain_core.callbacks import ( AsyncCallbackManager, AsyncCallbackManagerForChainRun, CallbackManager, CallbackManagerForChainRun, Callbacks, ) from langchain_core.la...
null
28,008
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
Load LLM chain from config dict.
28,009
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
Load hypothetical document embedder chain from config dict.
28,010
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,011
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,012
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,013
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,014
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,015
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,016
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,017
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,018
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,019
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,020
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,021
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,022
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,023
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,024
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,025
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,026
import json from pathlib import Path from typing import Any, Union import yaml from langchain_community.llms.loading import load_llm, load_llm_from_config from langchain_core.prompts.loading import ( _load_output_parser, load_prompt, load_prompt_from_config, ) from langchain_core.utils.loading import try_lo...
null
28,027
from typing import List, Type, Union from langchain_core.language_models import BaseLanguageModel from langchain_core.prompts import ChatPromptTemplate from langchain_core.pydantic_v1 import BaseModel from langchain_core.runnables import Runnable from langchain_core.utils.function_calling import convert_pydantic_to_ope...
Creates a chain that extracts information from a passage. Args: pydantic_schemas: The schema of the entities to extract. llm: The language model to use. system_message: The system message to use for extraction. Returns: A runnable that extracts information from a passage.
28,028
from __future__ import annotations import re from abc import abstractmethod from typing import Any, Dict, List, Optional, Sequence, Tuple import numpy as np from langchain_community.llms.openai import OpenAI from langchain_core.callbacks import ( CallbackManagerForChainRun, ) from langchain_core.language_models imp...
null
28,029
import json from typing import Any, Callable, Dict, Literal, Optional, Sequence, Type, Union from langchain_core.output_parsers import ( BaseGenerationOutputParser, BaseOutputParser, JsonOutputParser, ) from langchain_core.output_parsers.openai_functions import ( JsonOutputFunctionsParser, PydanticA...
Create a runnable for extracting structured outputs. Args: output_schema: Either a dictionary or pydantic.BaseModel class. If a dictionary is passed in, it's assumed to already be a valid JsonSchema. For best results, pydantic.BaseModels should have docstrings describing what the schema represents and descriptions for ...