id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
28,230
import re from collections import defaultdict from dataclasses import dataclass, field from typing import TYPE_CHECKING, Dict, List MappingDataType = Dict[str, Dict[str, str]] def format_duplicated_operator(operator_name: str, count: int) -> str: """Format the operator name with the count.""" clean_operator_nam...
Create or update the mapping used to anonymize and/or deanonymize a text. This method exploits the results returned by the analysis and anonymization processes. If is_reversed is True, it constructs a mapping from each original entity to its anonymized value. If is_reversed is False, it constructs a mapping from each a...
28,231
import string from typing import Callable, Dict, Optional The provided code snippet includes necessary dependencies for implementing the `get_pseudoanonymizer_mapping` function. Write a Python function `def get_pseudoanonymizer_mapping(seed: Optional[int] = None) -> Dict[str, Callable]` to solve the following problem:...
Get a mapping of entities to pseudo anonymize them.
28,232
import re from typing import List from langchain_experimental.data_anonymizer.deanonymizer_mapping import MappingDataType MappingDataType = Dict[str, Dict[str, str]] The provided code snippet includes necessary dependencies for implementing the `case_insensitive_matching_strategy` function. Write a Python function `d...
Case insensitive matching strategy for deanonymization. It replaces all the anonymized entities with the original ones irrespective of their letter case. Args: text: text to deanonymize deanonymizer_mapping: mapping between anonymized entities and original ones Examples of matching: keanu reeves -> Keanu Reeves JOHN F....
28,233
import re from typing import List from langchain_experimental.data_anonymizer.deanonymizer_mapping import MappingDataType def exact_matching_strategy(text: str, deanonymizer_mapping: MappingDataType) -> str: """Exact matching strategy for deanonymization. It replaces all the anonymized entities with the origina...
Combined exact and fuzzy matching strategy for deanonymization. It is a RECOMMENDED STRATEGY. Args: text: text to deanonymize deanonymizer_mapping: mapping between anonymized entities and original ones max_l_dist: maximum Levenshtein distance between the anonymized entity and the text segment to consider it a match Exa...
28,234
import re from typing import List from langchain_experimental.data_anonymizer.deanonymizer_mapping import MappingDataType MappingDataType = Dict[str, Dict[str, str]] The provided code snippet includes necessary dependencies for implementing the `ngram_fuzzy_matching_strategy` function. Write a Python function `def ng...
N-gram fuzzy matching strategy for deanonymization. It replaces all the anonymized entities with the original ones. It uses fuzzy matching to find the position of the anonymized entity in the text. It generates n-grams of the same length as the anonymized entity from the text and uses fuzzy matching to find the positio...
28,235
from __future__ import annotations import json from pathlib import Path from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Union import yaml from langchain_experimental.data_anonymizer.base import ( DEFAULT_DEANONYMIZER_MATCHING_STRATEGY, AnonymizerBase, ReversibleAnonymizerBase, ) from langc...
null
28,236
from __future__ import annotations import json from pathlib import Path from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Union import yaml from langchain_experimental.data_anonymizer.base import ( DEFAULT_DEANONYMIZER_MATCHING_STRATEGY, AnonymizerBase, ReversibleAnonymizerBase, ) from langc...
null
28,237
from __future__ import annotations import json from pathlib import Path from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Union import yaml from langchain_experimental.data_anonymizer.base import ( DEFAULT_DEANONYMIZER_MATCHING_STRATEGY, AnonymizerBase, ReversibleAnonymizerBase, ) from langc...
null
28,238
from __future__ import annotations import json from pathlib import Path from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Union import yaml from langchain_experimental.data_anonymizer.base import ( DEFAULT_DEANONYMIZER_MATCHING_STRATEGY, AnonymizerBase, ReversibleAnonymizerBase, ) from langc...
null
28,239
from typing import Any, List, Optional, Sequence from langchain_community.graphs.graph_document import GraphDocument, Node, Relationship from langchain_core.documents import Document from langchain_core.language_models import BaseLanguageModel from langchain_core.prompts import ChatPromptTemplate from langchain_core.py...
Simple model allows to limit node and/or relationship types. Doesn't have any node or relationship properties.
28,240
from typing import Any, List, Optional, Sequence from langchain_community.graphs.graph_document import GraphDocument, Node, Relationship from langchain_core.documents import Document from langchain_core.language_models import BaseLanguageModel from langchain_core.prompts import ChatPromptTemplate from langchain_core.py...
Map the SimpleRelationship to the base Relationship.
28,241
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union import requests from langchain.utils import get_from_env from langchain_community.graphs.graph_document import GraphDocument, Node, Relationship from langchain_core.documents import Document The provided code snippet includes necessary dependencies f...
Formats a string to be used as a property key.
28,242
from __future__ import annotations import json from typing import TYPE_CHECKING, Any, List, Optional, cast from langchain.callbacks.manager import CallbackManagerForLLMRun from langchain_community.llms.huggingface_pipeline import HuggingFacePipeline from langchain_experimental.pydantic_v1 import Field, root_validator ...
Lazily import of the jsonformer package.
28,243
import json from collections import defaultdict from html.parser import HTMLParser from typing import Any, DefaultDict, Dict, List, Optional, cast from langchain.callbacks.manager import ( CallbackManagerForLLMRun, ) from langchain.schema import ( ChatGeneration, ChatResult, ) from langchain_community.chat_...
null
28,244
from __future__ import annotations from typing import TYPE_CHECKING, Any, List, Optional from langchain.callbacks.manager import CallbackManagerForLLMRun from langchain.schema import LLMResult from langchain_community.llms.huggingface_pipeline import HuggingFacePipeline from langchain_experimental.pydantic_v1 import Fi...
Lazily import of the lmformatenforcer package.
28,245
import json import logging from typing import ( Any, Dict, List, Mapping, Optional, Tuple, ) from langchain.callbacks.manager import CallbackManagerForLLMRun from langchain.schema import ( ChatGeneration, ChatResult, ) from langchain_core.language_models import BaseChatModel from langcha...
null
28,246
import json import logging from typing import ( Any, Dict, List, Mapping, Optional, Tuple, ) from langchain.callbacks.manager import CallbackManagerForLLMRun from langchain.schema import ( ChatGeneration, ChatResult, ) from langchain_core.language_models import BaseChatModel from langcha...
null
28,247
from __future__ import annotations from typing import TYPE_CHECKING, Any, List, Optional, cast from langchain.callbacks.manager import CallbackManagerForLLMRun from langchain_community.llms.huggingface_pipeline import HuggingFacePipeline from langchain_community.llms.utils import enforce_stop_tokens from langchain_expe...
Lazily import of the rellm package.
28,248
from typing import List from langchain.agents.agent import AgentExecutor from langchain.agents.structured_chat.base import StructuredChatAgent from langchain.tools import BaseTool from langchain_core.language_models import BaseLanguageModel from langchain_experimental.plan_and_execute.executors.base import ChainExecuto...
Load an agent executor. Args: llm: BaseLanguageModel tools: List[BaseTool] verbose: bool. Defaults to False. include_task_in_prompt: bool. Defaults to False. Returns: ChainExecutor
28,249
import re from langchain.chains import LLMChain from langchain.prompts import ChatPromptTemplate, HumanMessagePromptTemplate from langchain_core.language_models import BaseLanguageModel from langchain_core.messages import SystemMessage from langchain_experimental.plan_and_execute.planners.base import LLMPlanner from la...
Load a chat planner. Args: llm: Language model. system_prompt: System prompt. Returns: LLMPlanner
28,250
from typing import Any, Dict, Optional from langchain.agents.agent import AgentExecutor, BaseSingleActionAgent from langchain.agents.mrkl.base import ZeroShotAgent from langchain.agents.openai_functions_agent.base import OpenAIFunctionsAgent from langchain.agents.types import AgentType from langchain.callbacks.base imp...
Construct a python agent from an LLM and tool.
28,251
from __future__ import annotations from io import IOBase from typing import TYPE_CHECKING, Any, List, Optional, Union from langchain_experimental.agents.agent_toolkits.pandas.base import ( create_pandas_dataframe_agent, ) def create_pandas_dataframe_agent( llm: LanguageModelLike, df: Any, agent_type: U...
Create pandas dataframe agent by loading csv to a dataframe. Args: llm: Language model to use for the agent. path: A string path, file-like object or a list of string paths/file-like objects that can be read in as pandas DataFrames with pd.read_csv(). pandas_kwargs: Named arguments to pass to pd.read_csv(). **kwargs: A...
28,252
from typing import Any, Dict, List, Optional from langchain.agents.agent import AgentExecutor from langchain.agents.mrkl.base import ZeroShotAgent from langchain.callbacks.base import BaseCallbackManager from langchain.chains.llm import LLMChain from langchain_core.language_models import BaseLLM from langchain_experime...
Construct a xorbits agent from an LLM and dataframe.
28,253
from typing import Any, Dict, List, Optional from langchain.agents.agent import AgentExecutor from langchain.agents.mrkl.base import ZeroShotAgent from langchain.callbacks.base import BaseCallbackManager from langchain.chains.llm import LLMChain from langchain_core.language_models import BaseLLM from langchain_experime...
Construct a Spark agent from an LLM and dataframe.
28,254
import json from textwrap import dedent from typing import List from langchain.prompts import PromptTemplate from langchain_core.output_parsers import BaseOutputParser from langchain_experimental.tot.thought import ThoughtValidity The provided code snippet includes necessary dependencies for implementing the `get_cot_...
Get the prompt for the Chain of Thought (CoT) chain.
28,255
import json from textwrap import dedent from typing import List from langchain.prompts import PromptTemplate from langchain_core.output_parsers import BaseOutputParser from langchain_experimental.tot.thought import ThoughtValidity class JSONListOutputParser(BaseOutputParser): """Parse the output of a PROPOSE_PROMPT...
Get the prompt for the PROPOSE_PROMPT chain.
28,256
import copy import re from typing import Any, Dict, Iterable, List, Literal, Optional, Sequence, Tuple, cast import numpy as np from langchain_community.utils.math import ( cosine_similarity, ) from langchain_core.documents import BaseDocumentTransformer, Document from langchain_core.embeddings import Embeddings T...
Combine sentences based on buffer size. Args: sentences: List of sentences to combine. buffer_size: Number of sentences to combine. Defaults to 1. Returns: List of sentences with combined sentences.
28,257
import copy import re from typing import Any, Dict, Iterable, List, Literal, Optional, Sequence, Tuple, cast import numpy as np from langchain_community.utils.math import ( cosine_similarity, ) from langchain_core.documents import BaseDocumentTransformer, Document from langchain_core.embeddings import Embeddings d...
Calculate cosine distances between sentences. Args: sentences: List of sentences to calculate distances for. Returns: Tuple of distances and sentences.
28,258
from __future__ import annotations from typing import Any, Dict, List, Optional, Sequence, Union from langchain.callbacks.manager import CallbackManagerForChainRun from langchain.chains.llm import LLMChain from langchain.chains.sql_database.prompt import PROMPT, SQL_PROMPTS from langchain.prompts.prompt import PromptTe...
Get result from SQL Database.
28,259
from typing import Any, Dict, Optional, Type, Union from langchain.chains.openai_functions import create_structured_output_chain from langchain.prompts import PromptTemplate from langchain.pydantic_v1 import BaseModel from langchain.schema import BaseLLMOutputParser, BasePromptTemplate from langchain_community.chat_mod...
Create an instance of SyntheticDataGenerator tailored for OpenAI models. This function creates an LLM chain designed for structured output based on the provided schema, language model, and prompt template. The resulting chain is then used to instantiate and return a SyntheticDataGenerator. Args: output_schema (Union[Di...
28,260
import functools import logging import multiprocessing import sys from io import StringIO from typing import Dict, Optional from langchain.pydantic_v1 import BaseModel, Field logger = logging.getLogger(__name__) The provided code snippet includes necessary dependencies for implementing the `warn_once` function. Write ...
Warn once about the dangers of PythonREPL.
28,261
import importlib.util import json from pathlib import Path from typing import Union import yaml from langchain.prompts.loading import load_prompt_from_config, try_load_from_hub from langchain_core.prompts import BasePromptTemplate def _load_prompt_from_file(file: Union[str, Path]) -> BasePromptTemplate: """Load pro...
Unified method for loading a prompt from LangChainHub or local file system.
28,262
from __future__ import annotations import logging import os from abc import ABC, abstractmethod from typing import ( TYPE_CHECKING, Any, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, ) from langchain.callbacks.manager import CallbackManagerForChainRun from langchain...
Parse the input string into a list of examples.
28,263
from __future__ import annotations import logging import os from abc import ABC, abstractmethod from typing import ( TYPE_CHECKING, Any, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, ) from langchain.callbacks.manager import CallbackManagerForChainRun from langchain...
Get the BasedOn and ToSelectFrom from the inputs.
28,264
from __future__ import annotations import logging import os from abc import ABC, abstractmethod from typing import ( TYPE_CHECKING, Any, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, ) from langchain.callbacks.manager import CallbackManagerForChainRun from langchain...
Prepare the inputs for auto embedding. Go over all the inputs and if something is either wrapped in _ToSelectFrom or _BasedOn, and if their inner values are not already _Embed, then wrap them in EmbedAndKeep while retaining their _ToSelectFrom or _BasedOn status
28,265
from __future__ import annotations import logging import os from abc import ABC, abstractmethod from typing import ( TYPE_CHECKING, Any, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, ) from langchain.callbacks.manager import CallbackManagerForChainRun from langchain...
Check if an item is a string.
28,266
from __future__ import annotations import logging import os from abc import ABC, abstractmethod from typing import ( TYPE_CHECKING, Any, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, ) from langchain.callbacks.manager import CallbackManagerForChainRun from langchain...
Embed the actions or context using the SentenceTransformer model (or a model that has an `encode` function). Attributes: to_embed: (Union[Union(str, _Embed(str)), Dict, List[Union(str, _Embed(str))], List[Dict]], required) The text to be embedded, either a string, a list of strings or a dictionary or a list of dictiona...
28,267
from __future__ import annotations from typing import TYPE_CHECKING, Union from langchain.pydantic_v1 import Field, root_validator from langchain.tools.base import BaseTool def _model_default_factory( model_name: str = "laiyer/deberta-v3-base-prompt-injection", ) -> Pipeline: try: from transformers imp...
null
28,268
import json import re from abc import abstractmethod from typing import Any, Dict, List, Optional, Union from langchain.base_language import BaseLanguageModel from langchain.callbacks.manager import Callbacks from langchain.chains import LLMChain from langchain.prompts.chat import ( AIMessagePromptTemplate, Cha...
Load the chat planner.
28,269
from typing import Any, List, Optional from langchain.base_language import BaseLanguageModel from langchain.callbacks.manager import Callbacks from langchain.chains import LLMChain from langchain.prompts import PromptTemplate class ResponseGenerationChain(LLMChain): """Chain to execute tasks.""" def from_llm(cl...
Load the ResponseGenerator.
28,270
import json from typing import List from langchain.tools.base import BaseTool class PromptGenerator: """Generator of custom prompt strings. Does this based on constraints, commands, resources, and performance evaluations. """ def __init__(self) -> None: """Initialize the PromptGenerator object. ...
Generates a prompt string. It includes various constraints, commands, resources, and performance evaluations. Returns: str: The generated prompt string.
28,271
import json import re from abc import abstractmethod from typing import Dict, NamedTuple from langchain_core.output_parsers import BaseOutputParser The provided code snippet includes necessary dependencies for implementing the `preprocess_json_input` function. Write a Python function `def preprocess_json_input(input_s...
Preprocesses a string to be parsed as json. Replace single backslashes with double backslashes, while leaving already escaped ones intact. Args: input_str: String to be preprocessed Returns: Preprocessed string
28,272
import ast import re import sys from contextlib import redirect_stdout from io import StringIO from typing import Any, Dict, Optional, Type from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.pydantic_v1 import BaseModel, Field, root_validator fr...
null
28,273
import ast import re import sys from contextlib import redirect_stdout from io import StringIO from typing import Any, Dict, Optional, Type from langchain.callbacks.manager import ( AsyncCallbackManagerForToolRun, CallbackManagerForToolRun, ) from langchain.pydantic_v1 import BaseModel, Field, root_validator fr...
Sanitize input to the python REPL. Remove whitespace, backtick & python (if llm mistakes python console as terminal) Args: query: The query to sanitize Returns: str: The sanitized query
28,274
import logging from typing import Any, Dict, List, Optional import requests from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models.llms import LLM The provided code snippet includes necessary dependencies for implementing the `clean_url` function. Write a Python function `def...
Remove trailing slash and /api from url if present.
28,275
import importlib.util import logging from typing import Any, Callable, List, Mapping, Optional from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.pydantic_v1 import Extra from langchain_community.llms.self_hosted import SelfHostedPipeline from langchain_community.llms.utils import enforce...
Inference function to send to the remote hardware. Accepts a Hugging Face pipeline (or more likely, a key pointing to such a pipeline on the cluster's object store) and returns generated text.
28,276
import importlib.util import logging from typing import Any, Callable, List, Mapping, Optional from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.pydantic_v1 import Extra from langchain_community.llms.self_hosted import SelfHostedPipeline from langchain_community.llms.utils import enforce...
Inference function to send to the remote hardware. Accepts a huggingface model_id and returns a pipeline for the task.
28,277
from __future__ import annotations import asyncio import functools import logging from typing import ( Any, AsyncIterable, AsyncIterator, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Tuple, TypeVar, ) from langchain_core.callbacks import ( AsyncCallbac...
Use tenacity to retry the completion call.
28,278
from __future__ import annotations import asyncio import functools import logging from typing import ( Any, AsyncIterable, AsyncIterator, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Tuple, TypeVar, ) from langchain_core.callbacks import ( AsyncCallbac...
Async version of `stream_generate_with_retry`. Because the dashscope SDK doesn't provide an async API, we wrap `stream_generate_with_retry` with an async generator.
28,279
from __future__ import annotations import asyncio import functools import logging from typing import ( Any, AsyncIterable, AsyncIterator, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Tuple, TypeVar, ) from langchain_core.callbacks import ( AsyncCallbac...
Generate elements from an iterable, and a boolean indicating if it is the last element.
28,280
from __future__ import annotations import asyncio import functools import logging from typing import ( Any, AsyncIterable, AsyncIterator, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Tuple, TypeVar, ) from langchain_core.callbacks import ( AsyncCallbac...
Generate elements from an async iterable, and a boolean indicating if it is the last element.
28,281
from __future__ import annotations from concurrent.futures import Executor, ThreadPoolExecutor from typing import TYPE_CHECKING, Any, ClassVar, Dict, Iterator, List, Optional, Union from langchain_core._api.deprecation import deprecated from langchain_core.callbacks.manager import ( AsyncCallbackManagerForLLMRun, ...
Returns True if the model name is a Codey model.
28,282
from __future__ import annotations from concurrent.futures import Executor, ThreadPoolExecutor from typing import TYPE_CHECKING, Any, ClassVar, Dict, Iterator, List, Optional, Union from langchain_core._api.deprecation import deprecated from langchain_core.callbacks.manager import ( AsyncCallbackManagerForLLMRun, ...
Returns True if the model name is a Gemini model.
28,283
from __future__ import annotations from concurrent.futures import Executor, ThreadPoolExecutor from typing import TYPE_CHECKING, Any, ClassVar, Dict, Iterator, List, Optional, Union from langchain_core._api.deprecation import deprecated from langchain_core.callbacks.manager import ( AsyncCallbackManagerForLLMRun, ...
Use tenacity to retry the completion call.
28,284
from __future__ import annotations from concurrent.futures import Executor, ThreadPoolExecutor from typing import TYPE_CHECKING, Any, ClassVar, Dict, Iterator, List, Optional, Union from langchain_core._api.deprecation import deprecated from langchain_core.callbacks.manager import ( AsyncCallbackManagerForLLMRun, ...
Use tenacity to retry the completion call.
28,285
import asyncio import json import warnings from abc import ABC from typing import ( Any, AsyncGenerator, AsyncIterator, Dict, Iterator, List, Mapping, Optional, ) from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from langchain_core...
null
28,286
import asyncio import json import warnings from abc import ABC from typing import ( Any, AsyncGenerator, AsyncIterator, Dict, Iterator, List, Mapping, Optional, ) from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from langchain_core...
Convert a stream response to a generation chunk.
28,287
import asyncio from concurrent.futures import ThreadPoolExecutor from typing import Any, AsyncIterator, Callable, Dict, Iterator, List, Optional, Union from langchain_core._api.deprecation import deprecated from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from la...
Convert a stream response to a generation chunk.
28,288
import asyncio from concurrent.futures import ThreadPoolExecutor from typing import Any, AsyncIterator, Callable, Dict, Iterator, List, Optional, Union from langchain_core._api.deprecation import deprecated from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from la...
Use tenacity to retry the completion call.
28,289
import asyncio from concurrent.futures import ThreadPoolExecutor from typing import Any, AsyncIterator, Callable, Dict, Iterator, List, Optional, Union from langchain_core._api.deprecation import deprecated from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from la...
Use tenacity to retry the completion call.
28,290
import asyncio from concurrent.futures import ThreadPoolExecutor from typing import Any, AsyncIterator, Callable, Dict, Iterator, List, Optional, Union from langchain_core._api.deprecation import deprecated from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from la...
Use tenacity to retry the completion call.
28,291
import asyncio from concurrent.futures import ThreadPoolExecutor from typing import Any, AsyncIterator, Callable, Dict, Iterator, List, Optional, Union from langchain_core._api.deprecation import deprecated from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from la...
Use tenacity to retry the completion call.
28,292
import asyncio from concurrent.futures import ThreadPoolExecutor from typing import Any, AsyncIterator, Callable, Dict, Iterator, List, Optional, Union from langchain_core._api.deprecation import deprecated from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from la...
Use tenacity to retry the completion call for streaming.
28,293
import json import logging from typing import Any, List, Optional, Union from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models.llms import LLM from langchain_core.messages import ( AIMessage, BaseMessage, FunctionMessage, HumanMessage, SystemMessage, ) fro...
null
28,294
import dataclasses import os from typing import Any, Dict, List, Mapping, Optional, Union, cast import requests from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models.llms import LLM from langchain_core.pydantic_v1 import Extra, root_validator from langchain_core.utils import ...
List available models
28,295
import dataclasses import os from typing import Any, Dict, List, Mapping, Optional, Union, cast import requests from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models.llms import LLM from langchain_core.pydantic_v1 import Extra, root_validator from langchain_core.utils import ...
Get completions from Aviary models.
28,296
from __future__ import annotations import logging from typing import Any, Callable, Dict, List, Optional, Sequence from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from langchain_core.language_models.llms import LLM from langchain_core.load.serializable import Se...
Use tenacity to retry the completion call.
28,297
from __future__ import annotations import logging from typing import Any, Callable, Dict, List, Optional, Sequence from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from langchain_core.language_models.llms import LLM from langchain_core.load.serializable import Se...
Use tenacity to retry the async completion call.
28,298
import json from typing import Any, AsyncIterator, Dict, Iterator, List, Mapping, Optional, Union import aiohttp import requests from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from langchain_core.language_models import BaseLanguageModel from langchain_core.lang...
Convert a stream response to a generation chunk.
28,299
from typing import ( Any, Dict, List, Mapping, Optional, Set, ) from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from langchain_core.outputs import Generation, GenerationChunk, LLMResult from langchain_core.pydantic_v1 import Field, Secret...
Update token usage.
28,300
from typing import ( Any, Dict, List, Mapping, Optional, Set, ) from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from langchain_core.outputs import Generation, GenerationChunk, LLMResult from langchain_core.pydantic_v1 import Field, Secret...
Create the LLMResult from the choices and prompts.
28,301
import os import re import warnings from abc import ABC, abstractmethod from typing import Any, Callable, Dict, List, Mapping, Optional import requests from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models import LLM from langchain_core.pydantic_v1 import ( BaseModel, ...
null
28,302
import os import re import warnings from abc import ABC, abstractmethod from typing import Any, Callable, Dict, List, Mapping, Optional import requests from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models import LLM from langchain_core.pydantic_v1 import ( BaseModel, ...
null
28,303
import os import re import warnings from abc import ABC, abstractmethod from typing import Any, Callable, Dict, List, Mapping, Optional import requests from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models import LLM from langchain_core.pydantic_v1 import ( BaseModel, ...
null
28,304
import os import re import warnings from abc import ABC, abstractmethod from typing import Any, Callable, Dict, List, Mapping, Optional import requests from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models import LLM from langchain_core.pydantic_v1 import ( BaseModel, ...
Gets the default Databricks workspace hostname. Raises an error if the hostname cannot be automatically determined.
28,305
import os import re import warnings from abc import ABC, abstractmethod from typing import Any, Callable, Dict, List, Mapping, Optional import requests from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models import LLM from langchain_core.pydantic_v1 import ( BaseModel, ...
Gets the default Databricks personal access token. Raises an error if the token cannot be automatically determined.
28,306
import os import re import warnings from abc import ABC, abstractmethod from typing import Any, Callable, Dict, List, Mapping, Optional import requests from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models import LLM from langchain_core.pydantic_v1 import ( BaseModel, ...
Checks if a data is a valid hexadecimal string using a regular expression.
28,307
import os import re import warnings from abc import ABC, abstractmethod from typing import Any, Callable, Dict, List, Mapping, Optional import requests from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models import LLM from langchain_core.pydantic_v1 import ( BaseModel, ...
Loads a pickled function from a hexadecimal string.
28,308
import os import re import warnings from abc import ABC, abstractmethod from typing import Any, Callable, Dict, List, Mapping, Optional import requests from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models import LLM from langchain_core.pydantic_v1 import ( BaseModel, ...
Pickles a function and returns the hexadecimal string.
28,309
from __future__ import annotations import os from typing import Any, AsyncIterator, Dict, Iterator, List, Optional from langchain_core.callbacks.manager import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from langchain_core.language_models.llms import LLM from langchain_core.load.serializable i...
Convert a stream response to a generation chunk.
28,310
from __future__ import annotations from typing import Any, Dict, Iterator, List, Optional from langchain_core._api.deprecation import deprecated from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models import LanguageModelInput from langchain_core.outputs import Generation, Gene...
Use tenacity to retry the completion call.
28,311
from __future__ import annotations from typing import Any, Dict, Iterator, List, Optional from langchain_core._api.deprecation import deprecated from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models import LanguageModelInput from langchain_core.outputs import Generation, Gene...
null
28,312
from __future__ import annotations from typing import Any, Dict, Iterator, List, Optional from langchain_core._api.deprecation import deprecated from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models import LanguageModelInput from langchain_core.outputs import Generation, Gene...
Strip erroneous leading spaces from text. The PaLM API will sometimes erroneously return a single leading space in all lines > 1. This function strips that space.
28,313
import json import logging from typing import Any, Callable, Dict, List, Mapping, Optional import requests from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models.llms import LLM from langchain_core.pydantic_v1 import Extra, SecretStr, root_validator from langchain_core.utils i...
Use tenacity to retry the completion call.
28,314
from __future__ import annotations import logging import os import sys import warnings from typing import ( AbstractSet, Any, AsyncIterator, Callable, Collection, Dict, Iterator, List, Literal, Mapping, Optional, Set, Tuple, Union, ) from langchain_core._api.depre...
Update token usage.
28,315
from __future__ import annotations import logging import os import sys import warnings from typing import ( AbstractSet, Any, AsyncIterator, Callable, Collection, Dict, Iterator, List, Literal, Mapping, Optional, Set, Tuple, Union, ) from langchain_core._api.depre...
Convert a stream response to a generation chunk.
28,316
from __future__ import annotations import logging import os import sys import warnings from typing import ( AbstractSet, Any, AsyncIterator, Callable, Collection, Dict, Iterator, List, Literal, Mapping, Optional, Set, Tuple, Union, ) from langchain_core._api.depre...
Update response from the stream response.
28,317
from __future__ import annotations import logging import os import sys import warnings from typing import ( AbstractSet, Any, AsyncIterator, Callable, Collection, Dict, Iterator, List, Literal, Mapping, Optional, Set, Tuple, Union, ) from langchain_core._api.depre...
null
28,318
from __future__ import annotations import logging import os import sys import warnings from typing import ( AbstractSet, Any, AsyncIterator, Callable, Collection, Dict, Iterator, List, Literal, Mapping, Optional, Set, Tuple, Union, ) from langchain_core._api.depre...
Use tenacity to retry the completion call.
28,319
from __future__ import annotations import logging import os import sys import warnings from typing import ( AbstractSet, Any, AsyncIterator, Callable, Collection, Dict, Iterator, List, Literal, Mapping, Optional, Set, Tuple, Union, ) from langchain_core._api.depre...
Use tenacity to retry the async completion call.
28,320
import json from typing import Any, AsyncIterator, Dict, Iterator, List, Mapping, Optional import aiohttp from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from langchain_core.language_models.llms import LLM from langchain_core.outputs import GenerationChunk from ...
null
28,321
import json from typing import Any, AsyncIterator, Dict, Iterator, List, Mapping, Optional import aiohttp from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from langchain_core.language_models.llms import LLM from langchain_core.outputs import GenerationChunk from ...
null
28,322
import json from typing import Any, AsyncIterator, Dict, Iterator, List, Mapping, Optional import aiohttp from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from langchain_core.language_models.llms import LLM from langchain_core.outputs import GenerationChunk from ...
null
28,323
from typing import Any, Callable, List, Mapping, Optional from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models.llms import LLM from langchain_core.pydantic_v1 import Field from langchain_community.llms.utils import enforce_stop_tokens The provided code snippet includes nece...
Displays the given prompt to the user.
28,324
from typing import Any, Callable, List, Mapping, Optional from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models.llms import LLM from langchain_core.pydantic_v1 import Field from langchain_community.llms.utils import enforce_stop_tokens The provided code snippet includes nece...
Collects and returns user input as a single string.
28,325
import importlib.util import logging import pickle from typing import Any, Callable, List, Mapping, Optional from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models.llms import LLM from langchain_core.pydantic_v1 import Extra from langchain_community.llms.utils import enforce_s...
Inference function to send to the remote hardware. Accepts a pipeline callable (or, more likely, a key pointing to the model on the cluster's object store) and returns text predictions for each document in the batch.
28,326
import importlib.util import logging import pickle from typing import Any, Callable, List, Mapping, Optional from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models.llms import LLM from langchain_core.pydantic_v1 import Extra from langchain_community.llms.utils import enforce_s...
Send a pipeline to a device on the cluster.
28,327
from __future__ import annotations import logging from typing import Any, Callable, Dict, List, Optional from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from langchain_core.language_models.llms import LLM from langchain_core.load.serializable import Serializable...
Use tenacity to retry the completion call.
28,328
from __future__ import annotations import logging from typing import Any, Callable, Dict, List, Optional from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, ) from langchain_core.language_models.llms import LLM from langchain_core.load.serializable import Serializable...
Use tenacity to retry the completion call.
28,329
from typing import Dict, List import numpy as np from langchain_core.example_selectors import BaseExampleSelector from langchain_core.prompts import PromptTemplate from langchain_core.pydantic_v1 import BaseModel, root_validator The provided code snippet includes necessary dependencies for implementing the `ngram_over...
Compute ngram overlap score of source and example as sentence_bleu score from NLTK package. Use sentence_bleu with method1 smoothing function and auto reweighting. Return float value between 0.0 and 1.0 inclusive. https://www.nltk.org/_modules/nltk/translate/bleu_score.html https://aclanthology.org/P02-1040.pdf