id
stringlengths
14
16
text
stringlengths
13
2.7k
source
stringlengths
57
178
8d5b453c2c64-1
yield_keys(*[, prefix]) Get an iterator over keys that match the given prefix. __init__(store: BaseStore[str, Any], key_encoder: Callable[[K], str], value_serializer: Callable[[V], bytes], value_deserializer: Callable[[Any], V]) → None[source]¶ Initialize an EncodedStore. mdelete(keys: Sequence[K]) → None[source]¶ Dele...
lang/api.python.langchain.com/en/latest/storage/langchain.storage.encoder_backed.EncoderBackedStore.html
b95956eebac7-0
langchain.storage.exceptions.InvalidKeyException¶ class langchain.storage.exceptions.InvalidKeyException[source]¶ Raised when a key is invalid; e.g., uses incorrect characters.
lang/api.python.langchain.com/en/latest/storage/langchain.storage.exceptions.InvalidKeyException.html
cdac9d96bbde-0
langchain.storage.upstash_redis.UpstashRedisStore¶ class langchain.storage.upstash_redis.UpstashRedisStore(*, client: Any = None, url: Optional[str] = None, token: Optional[str] = None, ttl: Optional[int] = None, namespace: Optional[str] = None)[source]¶ BaseStore implementation using Upstash Redis as the underlying st...
lang/api.python.langchain.com/en/latest/storage/langchain.storage.upstash_redis.UpstashRedisStore.html
cdac9d96bbde-1
namespace – if provided, all keys will be prefixed with this namespace mdelete(keys: Sequence[str]) → None[source]¶ Delete the given keys. mget(keys: Sequence[str]) → List[Optional[str]][source]¶ Get the values associated with the given keys. mset(key_value_pairs: Sequence[Tuple[str, str]]) → None[source]¶ Set the give...
lang/api.python.langchain.com/en/latest/storage/langchain.storage.upstash_redis.UpstashRedisStore.html
8e24a93086ed-0
langchain.storage.in_memory.InMemoryStore¶ class langchain.storage.in_memory.InMemoryStore[source]¶ In-memory implementation of the BaseStore using a dictionary. store¶ The underlying dictionary that stores the key-value pairs. Type Dict[str, Any] Examples from langchain.storage import InMemoryStore store = InMemorySto...
lang/api.python.langchain.com/en/latest/storage/langchain.storage.in_memory.InMemoryStore.html
8e24a93086ed-1
Set the values for the given keys. Parameters key_value_pairs (Sequence[Tuple[str, V]]) – A sequence of key-value pairs. Returns None yield_keys(prefix: Optional[str] = None) → Iterator[str][source]¶ Get an iterator over keys that match the given prefix. Parameters prefix (str, optional) – The prefix to match. Defaults...
lang/api.python.langchain.com/en/latest/storage/langchain.storage.in_memory.InMemoryStore.html
e1f0f80ccab6-0
langchain.storage.file_system.LocalFileStore¶ class langchain.storage.file_system.LocalFileStore(root_path: Union[str, Path])[source]¶ BaseStore interface that works on the local file system. Examples Create a LocalFileStore instance and perform operations on it: from langchain.storage import LocalFileStore # Instantia...
lang/api.python.langchain.com/en/latest/storage/langchain.storage.file_system.LocalFileStore.html
e1f0f80ccab6-1
Delete the given keys and their associated values. Parameters keys (Sequence[str]) – A sequence of keys to delete. Returns None mget(keys: Sequence[str]) → List[Optional[bytes]][source]¶ Get the values associated with the given keys. Parameters keys – A sequence of keys. Returns A sequence of optional values associated...
lang/api.python.langchain.com/en/latest/storage/langchain.storage.file_system.LocalFileStore.html
8bb910f670a1-0
langchain.storage.redis.RedisStore¶ class langchain.storage.redis.RedisStore(*, client: Any = None, redis_url: Optional[str] = None, client_kwargs: Optional[dict] = None, ttl: Optional[int] = None, namespace: Optional[str] = None)[source]¶ BaseStore implementation using Redis as the underlying store. Examples Create a ...
lang/api.python.langchain.com/en/latest/storage/langchain.storage.redis.RedisStore.html
8bb910f670a1-1
yield_keys(*[, prefix]) Yield keys in the store. __init__(*, client: Any = None, redis_url: Optional[str] = None, client_kwargs: Optional[dict] = None, ttl: Optional[int] = None, namespace: Optional[str] = None) → None[source]¶ Initialize the RedisStore with a Redis connection. Must provide either a Redis client or a r...
lang/api.python.langchain.com/en/latest/storage/langchain.storage.redis.RedisStore.html
fecdc9b60418-0
langchain.agents.format_scratchpad.log.format_log_to_str¶ langchain.agents.format_scratchpad.log.format_log_to_str(intermediate_steps: List[Tuple[AgentAction, str]], observation_prefix: str = 'Observation: ', llm_prefix: str = 'Thought: ') → str[source]¶ Construct the scratchpad that lets the agent continue its thought...
lang/api.python.langchain.com/en/latest/agents.format_scratchpad/langchain.agents.format_scratchpad.log.format_log_to_str.html
0af5685a05d2-0
langchain.agents.format_scratchpad.log_to_messages.format_log_to_messages¶ langchain.agents.format_scratchpad.log_to_messages.format_log_to_messages(intermediate_steps: List[Tuple[AgentAction, str]], template_tool_response: str = '{observation}') → List[BaseMessage][source]¶ Construct the scratchpad that lets the agent...
lang/api.python.langchain.com/en/latest/agents.format_scratchpad/langchain.agents.format_scratchpad.log_to_messages.format_log_to_messages.html
73cb3a0be3c2-0
langchain.agents.format_scratchpad.openai_functions.format_to_openai_function_messages¶ langchain.agents.format_scratchpad.openai_functions.format_to_openai_function_messages(intermediate_steps: Sequence[Tuple[AgentAction, str]]) → List[BaseMessage][source]¶ Convert (AgentAction, tool output) tuples into FunctionMessag...
lang/api.python.langchain.com/en/latest/agents.format_scratchpad/langchain.agents.format_scratchpad.openai_functions.format_to_openai_function_messages.html
a225ea3598e8-0
langchain.agents.format_scratchpad.xml.format_xml¶ langchain.agents.format_scratchpad.xml.format_xml(intermediate_steps: List[Tuple[AgentAction, str]]) → str[source]¶ Format the intermediate steps as XML. Parameters intermediate_steps – The intermediate steps. Returns The intermediate steps as XML.
lang/api.python.langchain.com/en/latest/agents.format_scratchpad/langchain.agents.format_scratchpad.xml.format_xml.html
c38314461eee-0
langchain.chat_models.baidu_qianfan_endpoint.QianfanChatEndpoint¶ class langchain.chat_models.baidu_qianfan_endpoint.QianfanChatEndpoint[source]¶ Bases: BaseChatModel Baidu Qianfan chat models. To use, you should have the qianfan python package installed, and the environment variable qianfan_ak and qianfan_sk set with ...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.baidu_qianfan_endpoint.QianfanChatEndpoint.html
c38314461eee-1
Default is ERNIE-Bot-turbo. param model_kwargs: Dict[str, Any] [Optional]¶ param penalty_score: Optional[float] = 1¶ Model params, only supported in ERNIE-Bot and ERNIE-Bot-turbo. In the case of other model, passing these params will not affect the result. param qianfan_ak: Optional[str] = None¶ param qianfan_sk: Optio...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.baidu_qianfan_endpoint.QianfanChatEndpoint.html
c38314461eee-2
e.g., if the underlying runnable uses an API which supports a batch mode. async agenerate(messages: List[List[BaseMessage]], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.baidu_qianfan_endpoint.QianfanChatEndpoint.html
c38314461eee-3
async ainvoke(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → BaseMessage¶ Default implementation of ainvoke, calls invoke from a thread. The default implementation allows usage of async code even if the runnable did not i...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.baidu_qianfan_endpoint.QianfanChatEndpoint.html
c38314461eee-4
to the model provider API call. Returns Top model prediction as a message. async astream(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → AsyncIterator[BaseMessageChunk]¶ Default implementation of astream, which calls ainvo...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.baidu_qianfan_endpoint.QianfanChatEndpoint.html
c38314461eee-5
input is still being generated. batch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → List[Output]¶ Default implementation runs invoke in parallel using a thread pool executor. The default implementation of batch w...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.baidu_qianfan_endpoint.QianfanChatEndpoint.html
c38314461eee-6
Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.baidu_qianfan_endpoint.QianfanChatEndpoint.html
c38314461eee-7
API. Use this method when you want to: take advantage of batched calls, need more output from the model than just the top generated value, are building chains that are agnostic to the underlying language modeltype (e.g., pure text completion models vs chat models). Parameters prompts – List of PromptValues. A PromptVal...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.baidu_qianfan_endpoint.QianfanChatEndpoint.html
c38314461eee-8
get_num_tokens(text: str) → int¶ Get the number of tokens present in the text. Useful for checking if an input will fit in a model’s context window. Parameters text – The string input to tokenize. Returns The integer number of tokens in the text. get_num_tokens_from_messages(messages: List[BaseMessage]) → int¶ Get the ...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.baidu_qianfan_endpoint.QianfanChatEndpoint.html
c38314461eee-9
config – A config to use when invoking the runnable. The config supports standard keys like ‘tags’, ‘metadata’ for tracing purposes, ‘max_concurrency’ for controlling how much work to do in parallel, and other keys. Please refer to the RunnableConfig for more details. Returns The output of the runnable. classmethod is_...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.baidu_qianfan_endpoint.QianfanChatEndpoint.html
c38314461eee-10
classmethod parse_obj(obj: Any) → Model¶ classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ predict(text: str, *, stop: Optional[Sequence[str]] = None, **kwargs: Any) → str¶ Pass a single string input to t...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.baidu_qianfan_endpoint.QianfanChatEndpoint.html
c38314461eee-11
stream(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → Iterator[BaseMessageChunk]¶ Default implementation of stream, which calls invoke. Subclasses should override this method if they support streaming output. to_json() → ...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.baidu_qianfan_endpoint.QianfanChatEndpoint.html
c38314461eee-12
fallback in order, upon failures. with_listeners(*, on_start: Optional[Listener] = None, on_end: Optional[Listener] = None, on_error: Optional[Listener] = None) → Runnable[Input, Output]¶ Bind lifecycle listeners to a Runnable, returning a new Runnable. on_start: Called before the runnable starts running, with the Run ...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.baidu_qianfan_endpoint.QianfanChatEndpoint.html
c38314461eee-13
List configurable fields for this runnable. property input_schema: Type[pydantic.main.BaseModel]¶ The type of input this runnable accepts specified as a pydantic model. property lc_attributes: Dict¶ List of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constr...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.baidu_qianfan_endpoint.QianfanChatEndpoint.html
ba0a3c536927-0
langchain.chat_models.cohere.ChatCohere¶ class langchain.chat_models.cohere.ChatCohere[source]¶ Bases: BaseChatModel, BaseCohere Cohere chat large language models. To use, you should have the cohere python package installed, and the environment variable COHERE_API_KEY set with your API key, or pass it as a named parame...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.cohere.ChatCohere.html
ba0a3c536927-1
param verbose: bool [Optional]¶ Whether to print out response text. __call__(messages: List[BaseMessage], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → BaseMessage¶ Call self as a function. async abatch(inputs: List[Input], config: ...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.cohere.ChatCohere.html
ba0a3c536927-2
need more output from the model than just the top generated value, are building chains that are agnostic to the underlying language modeltype (e.g., pure text completion models vs chat models). Parameters prompts – List of PromptValues. A PromptValue is an object that can be converted to match the format of any languag...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.cohere.ChatCohere.html
ba0a3c536927-3
**kwargs – Arbitrary additional keyword arguments. These are usually passed to the model provider API call. Returns Top model prediction as a string. async apredict_messages(messages: List[BaseMessage], *, stop: Optional[Sequence[str]] = None, **kwargs: Any) → BaseMessage¶ Asynchronously pass messages to the model and ...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.cohere.ChatCohere.html
ba0a3c536927-4
This includes all inner runs of LLMs, Retrievers, Tools, etc. Output is streamed as Log objects, which include a list of jsonpatch ops that describe how the state of the run has changed in each step, and the final state of the run. The jsonpatch ops can be applied in order to construct state. async atransform(input: As...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.cohere.ChatCohere.html
ba0a3c536927-5
Returns A pydantic model that can be used to validate config. configurable_alternatives(which: ConfigurableField, default_key: str = 'default', **kwargs: Union[Runnable[Input, Output], Callable[[], Runnable[Input, Output]]]) → RunnableSerializable[Input, Output]¶ configurable_fields(**kwargs: Union[ConfigurableField, C...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.cohere.ChatCohere.html
ba0a3c536927-6
classmethod from_orm(obj: Any) → Model¶ generate(messages: List[List[BaseMessage]], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, run_name: Optional[str] = None, **kwarg...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.cohere.ChatCohere.html
ba0a3c536927-7
Get a pydantic model that can be used to validate input to the runnable. Runnables that leverage the configurable_fields and configurable_alternatives methods will have a dynamic input schema that depends on which configuration the runnable is invoked with. This method allows to get an input schema for a specific confi...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.cohere.ChatCohere.html
ba0a3c536927-8
Parameters text – The string input to tokenize. Returns A list of ids corresponding to the tokens in the text, in order they occurin the text. invoke(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → BaseMessage¶ Transform a...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.cohere.ChatCohere.html
ba0a3c536927-9
to the object. map() → Runnable[List[Input], List[Output]]¶ Return a new Runnable that maps a list of inputs to a list of outputs, by calling invoke() with each input. classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool =...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.cohere.ChatCohere.html
ba0a3c536927-10
first occurrence of any of these substrings. **kwargs – Arbitrary additional keyword arguments. These are usually passed to the model provider API call. Returns Top model prediction as a message. classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ classmethod schema_...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.cohere.ChatCohere.html
ba0a3c536927-11
Add fallbacks to a runnable, returning a new Runnable. Parameters fallbacks – A sequence of runnables to try if the original runnable fails. exceptions_to_handle – A tuple of exception types to handle. Returns A new Runnable that will try the original runnable, and then each fallback in order, upon failures. with_liste...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.cohere.ChatCohere.html
ba0a3c536927-12
Bind input and output types to a Runnable, returning a new Runnable. property InputType: TypeAlias¶ Get the input type for this runnable. property OutputType: Any¶ Get the output type for this runnable. property config_specs: List[langchain.schema.runnable.utils.ConfigurableFieldSpec]¶ List configurable fields for this...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.cohere.ChatCohere.html
32fbee5e9608-0
langchain.chat_models.fireworks.convert_dict_to_message¶ langchain.chat_models.fireworks.convert_dict_to_message(_dict: Any) → BaseMessage[source]¶ Convert a dict response to a message.
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.fireworks.convert_dict_to_message.html
f871d18d01c3-0
langchain.chat_models.tongyi.ChatTongyi¶ class langchain.chat_models.tongyi.ChatTongyi[source]¶ Bases: BaseChatModel Alibaba Tongyi Qwen chat models API. To use, you should have the dashscope python package installed, and set env DASHSCOPE_API_KEY with your API key, or pass it as a named parameter to the constructor. E...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.tongyi.ChatTongyi.html
f871d18d01c3-1
param tags: Optional[List[str]] = None¶ Tags to add to the run trace. param top_p: float = 0.8¶ Total probability mass of tokens to consider at each step. param verbose: bool [Optional]¶ Whether to print out response text. __call__(messages: List[BaseMessage], stop: Optional[List[str]] = None, callbacks: Optional[Union...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.tongyi.ChatTongyi.html
f871d18d01c3-2
API. Use this method when you want to: take advantage of batched calls, need more output from the model than just the top generated value, are building chains that are agnostic to the underlying language modeltype (e.g., pure text completion models vs chat models). Parameters prompts – List of PromptValues. A PromptVal...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.tongyi.ChatTongyi.html
f871d18d01c3-3
stop – Stop words to use when generating. Model output is cut off at the first occurrence of any of these substrings. **kwargs – Arbitrary additional keyword arguments. These are usually passed to the model provider API call. Returns Top model prediction as a string. async apredict_messages(messages: List[BaseMessage],...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.tongyi.ChatTongyi.html
f871d18d01c3-4
Stream all output from a runnable, as reported to the callback system. This includes all inner runs of LLMs, Retrievers, Tools, etc. Output is streamed as Log objects, which include a list of jsonpatch ops that describe how the state of the run has changed in each step, and the final state of the run. The jsonpatch ops...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.tongyi.ChatTongyi.html
f871d18d01c3-5
The type of config this runnable accepts specified as a pydantic model. To mark a field as configurable, see the configurable_fields and configurable_alternatives methods. Parameters include – A list of fields to include in the config schema. Returns A pydantic model that can be used to validate config. configurable_al...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.tongyi.ChatTongyi.html
f871d18d01c3-6
Returns new model instance dict(**kwargs: Any) → Dict¶ Return a dictionary of the LLM. classmethod from_orm(obj: Any) → Model¶ generate(messages: List[List[BaseMessage]], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = N...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.tongyi.ChatTongyi.html
f871d18d01c3-7
to the model provider API call. Returns An LLMResult, which contains a list of candidate Generations for each inputprompt and additional model provider-specific output. get_input_schema(config: Optional[RunnableConfig] = None) → Type[BaseModel]¶ Get a pydantic model that can be used to validate input to the runnable. R...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.tongyi.ChatTongyi.html
f871d18d01c3-8
Runnables that leverage the configurable_fields and configurable_alternatives methods will have a dynamic output schema that depends on which configuration the runnable is invoked with. This method allows to get an output schema for a specific configuration. Parameters config – A config to use when generating the schem...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.tongyi.ChatTongyi.html
f871d18d01c3-9
classmethod is_lc_serializable() → bool¶ Is this class serializable? json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defa...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.tongyi.ChatTongyi.html
f871d18d01c3-10
Pass a single string input to the model and return a string prediction. Use this method when passing in raw text. If you want to pass in specifictypes of chat messages, use predict_messages. Parameters text – String input to pass to the model. stop – Stop words to use when generating. Model output is cut off at the fir...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.tongyi.ChatTongyi.html
f871d18d01c3-11
Subclasses should override this method if they support streaming output. stream_completion_with_retry(run_manager: Optional[CallbackManagerForLLMRun] = None, **kwargs: Any) → Any[source]¶ Use tenacity to retry the completion call. to_json() → Union[SerializedConstructor, SerializedNotImplemented]¶ to_json_not_implement...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.tongyi.ChatTongyi.html
f871d18d01c3-12
Bind lifecycle listeners to a Runnable, returning a new Runnable. on_start: Called before the runnable starts running, with the Run object. on_end: Called after the runnable finishes running, with the Run object. on_error: Called if the runnable throws an error, with the Run object. The Run object contains information ...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.tongyi.ChatTongyi.html
f871d18d01c3-13
List of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor. property lc_secrets: Dict[str, str]¶ A map of constructor argument names to secret ids. For example,{“openai_api_key”: “OPENAI_API_KEY”} property lc_serializable: bool¶ property output_schema:...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.tongyi.ChatTongyi.html
27e062735ae5-0
langchain.chat_models.anthropic.convert_messages_to_prompt_anthropic¶ langchain.chat_models.anthropic.convert_messages_to_prompt_anthropic(messages: List[BaseMessage], *, human_prompt: str = '\n\nHuman:', ai_prompt: str = '\n\nAssistant:') → str[source]¶ Format a list of messages into a full prompt for the Anthropic mo...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.anthropic.convert_messages_to_prompt_anthropic.html
2b629bb98d29-0
langchain.chat_models.fireworks.ChatFireworks¶ class langchain.chat_models.fireworks.ChatFireworks[source]¶ Bases: BaseChatModel Fireworks Chat models. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param c...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.fireworks.ChatFireworks.html
2b629bb98d29-1
Default implementation runs ainvoke in parallel using asyncio.gather. The default implementation of batch works well for IO bound runnables. Subclasses should override this method if they can batch more efficiently; e.g., if the underlying runnable uses an API which supports a batch mode. async agenerate(messages: List...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.fireworks.ChatFireworks.html
2b629bb98d29-2
**kwargs – Arbitrary additional keyword arguments. These are usually passed to the model provider API call. Returns An LLMResult, which contains a list of candidate Generations for each inputprompt and additional model provider-specific output. async ainvoke(input: Union[PromptValue, str, List[BaseMessage]], config: Op...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.fireworks.ChatFireworks.html
2b629bb98d29-3
**kwargs – Arbitrary additional keyword arguments. These are usually passed to the model provider API call. Returns Top model prediction as a message. async astream(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → AsyncIter...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.fireworks.ChatFireworks.html
2b629bb98d29-4
input is still being generated. batch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → List[Output]¶ Default implementation runs invoke in parallel using a thread pool executor. The default implementation of batch w...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.fireworks.ChatFireworks.html
2b629bb98d29-5
Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.fireworks.ChatFireworks.html
2b629bb98d29-6
API. Use this method when you want to: take advantage of batched calls, need more output from the model than just the top generated value, are building chains that are agnostic to the underlying language modeltype (e.g., pure text completion models vs chat models). Parameters prompts – List of PromptValues. A PromptVal...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.fireworks.ChatFireworks.html
2b629bb98d29-7
get_num_tokens(text: str) → int¶ Get the number of tokens present in the text. Useful for checking if an input will fit in a model’s context window. Parameters text – The string input to tokenize. Returns The integer number of tokens in the text. get_num_tokens_from_messages(messages: List[BaseMessage]) → int¶ Get the ...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.fireworks.ChatFireworks.html
2b629bb98d29-8
config – A config to use when invoking the runnable. The config supports standard keys like ‘tags’, ‘metadata’ for tracing purposes, ‘max_concurrency’ for controlling how much work to do in parallel, and other keys. Please refer to the RunnableConfig for more details. Returns The output of the runnable. classmethod is_...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.fireworks.ChatFireworks.html
2b629bb98d29-9
classmethod parse_obj(obj: Any) → Model¶ classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ predict(text: str, *, stop: Optional[Sequence[str]] = None, **kwargs: Any) → str¶ Pass a single string input to t...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.fireworks.ChatFireworks.html
2b629bb98d29-10
stream(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → Iterator[BaseMessageChunk]¶ Default implementation of stream, which calls invoke. Subclasses should override this method if they support streaming output. to_json() → ...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.fireworks.ChatFireworks.html
2b629bb98d29-11
fallback in order, upon failures. with_listeners(*, on_start: Optional[Listener] = None, on_end: Optional[Listener] = None, on_error: Optional[Listener] = None) → Runnable[Input, Output]¶ Bind lifecycle listeners to a Runnable, returning a new Runnable. on_start: Called before the runnable starts running, with the Run ...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.fireworks.ChatFireworks.html
2b629bb98d29-12
List configurable fields for this runnable. property input_schema: Type[pydantic.main.BaseModel]¶ The type of input this runnable accepts specified as a pydantic model. property lc_attributes: Dict¶ List of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constr...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.fireworks.ChatFireworks.html
a6834ad372fe-0
langchain.chat_models.base.BaseChatModel¶ class langchain.chat_models.base.BaseChatModel[source]¶ Bases: BaseLanguageModel[BaseMessage], ABC Base class for Chat models. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a val...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.base.BaseChatModel.html
a6834ad372fe-1
e.g., if the underlying runnable uses an API which supports a batch mode. async agenerate(messages: List[List[BaseMessage]], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.base.BaseChatModel.html
a6834ad372fe-2
async ainvoke(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → BaseMessage[source]¶ Default implementation of ainvoke, calls invoke from a thread. The default implementation allows usage of async code even if the runnable d...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.base.BaseChatModel.html
a6834ad372fe-3
to the model provider API call. Returns Top model prediction as a message. async astream(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → AsyncIterator[BaseMessageChunk][source]¶ Default implementation of astream, which cal...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.base.BaseChatModel.html
a6834ad372fe-4
input is still being generated. batch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → List[Output]¶ Default implementation runs invoke in parallel using a thread pool executor. The default implementation of batch w...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.base.BaseChatModel.html
a6834ad372fe-5
Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.base.BaseChatModel.html
a6834ad372fe-6
API. Use this method when you want to: take advantage of batched calls, need more output from the model than just the top generated value, are building chains that are agnostic to the underlying language modeltype (e.g., pure text completion models vs chat models). Parameters prompts – List of PromptValues. A PromptVal...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.base.BaseChatModel.html
a6834ad372fe-7
get_num_tokens(text: str) → int¶ Get the number of tokens present in the text. Useful for checking if an input will fit in a model’s context window. Parameters text – The string input to tokenize. Returns The integer number of tokens in the text. get_num_tokens_from_messages(messages: List[BaseMessage]) → int¶ Get the ...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.base.BaseChatModel.html
a6834ad372fe-8
config – A config to use when invoking the runnable. The config supports standard keys like ‘tags’, ‘metadata’ for tracing purposes, ‘max_concurrency’ for controlling how much work to do in parallel, and other keys. Please refer to the RunnableConfig for more details. Returns The output of the runnable. classmethod is_...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.base.BaseChatModel.html
a6834ad372fe-9
classmethod parse_obj(obj: Any) → Model¶ classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ predict(text: str, *, stop: Optional[Sequence[str]] = None, **kwargs: Any) → str[source]¶ Pass a single string in...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.base.BaseChatModel.html
a6834ad372fe-10
stream(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → Iterator[BaseMessageChunk][source]¶ Default implementation of stream, which calls invoke. Subclasses should override this method if they support streaming output. to_j...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.base.BaseChatModel.html
a6834ad372fe-11
fallback in order, upon failures. with_listeners(*, on_start: Optional[Listener] = None, on_end: Optional[Listener] = None, on_error: Optional[Listener] = None) → Runnable[Input, Output]¶ Bind lifecycle listeners to a Runnable, returning a new Runnable. on_start: Called before the runnable starts running, with the Run ...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.base.BaseChatModel.html
a6834ad372fe-12
List configurable fields for this runnable. property input_schema: Type[pydantic.main.BaseModel]¶ The type of input this runnable accepts specified as a pydantic model. property lc_attributes: Dict¶ List of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constr...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.base.BaseChatModel.html
655a72473bb7-0
langchain.chat_models.openai.ChatOpenAI¶ class langchain.chat_models.openai.ChatOpenAI[source]¶ Bases: BaseChatModel OpenAI Chat large language models API. To use, you should have the openai python package installed, and the environment variable OPENAI_API_KEY set with your API key. Any parameters that are valid to be ...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
655a72473bb7-1
Model name to use. param n: int = 1¶ Number of chat completions to generate for each prompt. param openai_api_base: Optional[str] = None (alias 'base_url')¶ Base URL path for API requests, leave blank if not using a proxy or service emulator. param openai_api_key: Optional[str] = None (alias 'api_key')¶ Automatically i...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
655a72473bb7-2
API but with different models. In those cases, in order to avoid erroring when tiktoken is called, you can specify a model name to use here. param verbose: bool [Optional]¶ Whether to print out response text. __call__(messages: List[BaseMessage], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCall...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
655a72473bb7-3
API. Use this method when you want to: take advantage of batched calls, need more output from the model than just the top generated value, are building chains that are agnostic to the underlying language modeltype (e.g., pure text completion models vs chat models). Parameters prompts – List of PromptValues. A PromptVal...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
655a72473bb7-4
stop – Stop words to use when generating. Model output is cut off at the first occurrence of any of these substrings. **kwargs – Arbitrary additional keyword arguments. These are usually passed to the model provider API call. Returns Top model prediction as a string. async apredict_messages(messages: List[BaseMessage],...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
655a72473bb7-5
Stream all output from a runnable, as reported to the callback system. This includes all inner runs of LLMs, Retrievers, Tools, etc. Output is streamed as Log objects, which include a list of jsonpatch ops that describe how the state of the run has changed in each step, and the final state of the run. The jsonpatch ops...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
655a72473bb7-6
Can be a dictionary, pydantic model, or callable. Pydantic models and callables will be automatically converted to their schema dictionary representation. function_call – Which function to require the model to call. Must be the name of the single provided function or “auto” to automatically determine which function to...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
655a72473bb7-7
Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
655a72473bb7-8
API. Use this method when you want to: take advantage of batched calls, need more output from the model than just the top generated value, are building chains that are agnostic to the underlying language modeltype (e.g., pure text completion models vs chat models). Parameters prompts – List of PromptValues. A PromptVal...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
655a72473bb7-9
get_num_tokens(text: str) → int¶ Get the number of tokens present in the text. Useful for checking if an input will fit in a model’s context window. Parameters text – The string input to tokenize. Returns The integer number of tokens in the text. get_num_tokens_from_messages(messages: List[BaseMessage]) → int[source]¶ ...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
655a72473bb7-10
purposes, ‘max_concurrency’ for controlling how much work to do in parallel, and other keys. Please refer to the RunnableConfig for more details. Returns The output of the runnable. classmethod is_lc_serializable() → bool[source]¶ Return whether this model can be serialized by Langchain. json(*, include: Optional[Union...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
655a72473bb7-11
predict(text: str, *, stop: Optional[Sequence[str]] = None, **kwargs: Any) → str¶ Pass a single string input to the model and return a string prediction. Use this method when passing in raw text. If you want to pass in specifictypes of chat messages, use predict_messages. Parameters text – String input to pass to the m...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
655a72473bb7-12
Default implementation of stream, which calls invoke. Subclasses should override this method if they support streaming output. to_json() → Union[SerializedConstructor, SerializedNotImplemented]¶ to_json_not_implemented() → SerializedNotImplemented¶ transform(input: Iterator[Input], config: Optional[RunnableConfig] = No...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
655a72473bb7-13
on_start: Called before the runnable starts running, with the Run object. on_end: Called after the runnable finishes running, with the Run object. on_error: Called if the runnable throws an error, with the Run object. The Run object contains information about the run, including its id, type, input, output, error, start...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
655a72473bb7-14
List of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor. property lc_secrets: Dict[str, str]¶ A map of constructor argument names to secret ids. For example,{“openai_api_key”: “OPENAI_API_KEY”} property output_schema: Type[pydantic.main.BaseModel]¶ ...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
655a72473bb7-15
Use LangChain, GPT and Activeloop’s Deep Lake to work with code base Structure answers with OpenAI functions QA using Activeloop’s DeepLake Neptune Open Cypher QA Chain NebulaGraphQAChain Memgraph QA chain KuzuQAChain HugeGraph QA Chain GraphSparqlQAChain Diffbot Graph Transformer ArangoDB QA chain Neo4j DB QA chain Fa...
lang/api.python.langchain.com/en/latest/chat_models/langchain.chat_models.openai.ChatOpenAI.html
7e6a7dcc4d8f-0
langchain_experimental.chat_models.llm_wrapper.Llama2Chat¶ class langchain_experimental.chat_models.llm_wrapper.Llama2Chat[source]¶ Bases: ChatWrapper Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to form a valid model. param ai...
lang/api.python.langchain.com/en/latest/chat_models/langchain_experimental.chat_models.llm_wrapper.Llama2Chat.html