id stringlengths 14 15 | text stringlengths 44 2.47k | source stringlengths 61 181 |
|---|---|---|
2e3508206da8-3 | classmethod update_forward_refs(**localns: Any) → None¶
Try to update ForwardRefs on fields based on this Model, globalns and localns.
classmethod validate(value: Any) → Model¶ | https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.generative_agent.GenerativeAgent.html |
25e96133d388-0 | langchain_experimental.generative_agents.memory.GenerativeAgentMemory¶
class langchain_experimental.generative_agents.memory.GenerativeAgentMemory[source]¶
Bases: BaseMemory
Memory for the generative agent.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the inp... | https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.memory.GenerativeAgentMemory.html |
25e96133d388-1 | Add an observations or memories to the agent’s memory.
add_memory(memory_content: str, now: Optional[datetime] = None) → List[str][source]¶
Add an observation or memory to the agent’s memory.
chain(prompt: PromptTemplate) → LLMChain[source]¶
clear() → None[source]¶
Clear memory contents.
classmethod construct(_fields_s... | https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.memory.GenerativeAgentMemory.html |
25e96133d388-2 | Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
fetch_memories(observation: str, now: Optional[datetime] = None) → List[Document][source]¶
Fetch related memories.
format_memories_detail(relevant_memories: List[Document]) → str[source]¶
format_memories_simple(... | https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.memory.GenerativeAgentMemory.html |
25e96133d388-3 | Return key-value pairs given the text input to the chain.
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
classmethod parse_obj(obj: Any) → Model¶
classmethod parse_raw(b: Union[str, bytes], *, conte... | https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.memory.GenerativeAgentMemory.html |
686c7b372b72-0 | langchain.adapters.openai.convert_message_to_dict¶
langchain.adapters.openai.convert_message_to_dict(message: BaseMessage) → dict[source]¶
Examples using convert_message_to_dict¶
Twitter (via Apify) | https://api.python.langchain.com/en/latest/adapters/langchain.adapters.openai.convert_message_to_dict.html |
efea08ea75b5-0 | langchain.adapters.openai.aenumerate¶
async langchain.adapters.openai.aenumerate(iterable: AsyncIterator[Any], start: int = 0) → AsyncIterator[tuple[int, Any]][source]¶
Async version of enumerate. | https://api.python.langchain.com/en/latest/adapters/langchain.adapters.openai.aenumerate.html |
cb02818ac128-0 | langchain.adapters.openai.convert_dict_to_message¶
langchain.adapters.openai.convert_dict_to_message(_dict: Mapping[str, Any]) → BaseMessage[source]¶ | https://api.python.langchain.com/en/latest/adapters/langchain.adapters.openai.convert_dict_to_message.html |
ee3048ee63e8-0 | langchain.adapters.openai.convert_messages_for_finetuning¶
langchain.adapters.openai.convert_messages_for_finetuning(sessions: Iterable[ChatSession]) → List[List[dict]][source]¶
Convert messages to a list of lists of dictionaries for fine-tuning.
Examples using convert_messages_for_finetuning¶
Facebook Messenger
Chat l... | https://api.python.langchain.com/en/latest/adapters/langchain.adapters.openai.convert_messages_for_finetuning.html |
dafa0e6b1f45-0 | langchain.adapters.openai.convert_openai_messages¶
langchain.adapters.openai.convert_openai_messages(messages: Sequence[Dict[str, Any]]) → List[BaseMessage][source]¶
Convert dictionaries representing OpenAI messages to LangChain format.
Parameters
messages – List of dictionaries representing OpenAI messages
Returns
Lis... | https://api.python.langchain.com/en/latest/adapters/langchain.adapters.openai.convert_openai_messages.html |
bba3cea23153-0 | langchain.adapters.openai.ChatCompletion¶
class langchain.adapters.openai.ChatCompletion[source]¶
Methods
__init__()
acreate()
create()
__init__()¶
async static acreate(messages: Sequence[Dict[str, Any]], *, provider: str = "'ChatOpenAI'", stream: Literal[False] = 'False', **kwargs: Any) → dict[source]¶
async static ac... | https://api.python.langchain.com/en/latest/adapters/langchain.adapters.openai.ChatCompletion.html |
d859d0dd668f-0 | langchain.llms.amazon_api_gateway.AmazonAPIGateway¶
class langchain.llms.amazon_api_gateway.AmazonAPIGateway[source]¶
Bases: LLM
Amazon API Gateway to access LLM models hosted on AWS.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parse... | https://api.python.langchain.com/en/latest/llms/langchain.llms.amazon_api_gateway.AmazonAPIGateway.html |
d859d0dd668f-1 | Check Cache and run the LLM on the given prompt and input.
async abatch(inputs: List[Union[PromptValue, str, List[BaseMessage]]], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Any) → List[str]¶
Default implementation of abatch, which calls ainvoke N ... | https://api.python.langchain.com/en/latest/llms/langchain.llms.amazon_api_gateway.AmazonAPIGateway.html |
d859d0dd668f-2 | Parameters
prompts – List of PromptValues. A PromptValue is an object that can be
converted to match the format of any language model (string for pure
text generation models and BaseMessages for chat models).
stop – Stop words to use when generating. Model output is cut off at the
first occurrence of any of these subst... | https://api.python.langchain.com/en/latest/llms/langchain.llms.amazon_api_gateway.AmazonAPIGateway.html |
d859d0dd668f-3 | Asynchronously pass messages to the model and return a message prediction.
Use this method when calling chat models and only the topcandidate generation is needed.
Parameters
messages – A sequence of chat messages corresponding to a single model input.
stop – Stop words to use when generating. Model output is cut off a... | https://api.python.langchain.com/en/latest/llms/langchain.llms.amazon_api_gateway.AmazonAPIGateway.html |
d859d0dd668f-4 | The jsonpatch ops can be applied in order to construct state.
async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶
Default implementation of atransform, which buffers input and calls astream.
Subclasses should override this method if th... | https://api.python.langchain.com/en/latest/llms/langchain.llms.amazon_api_gateway.AmazonAPIGateway.html |
d859d0dd668f-5 | the new model: you should trust this data
deep – set to True to make a deep copy of the model
Returns
new model instance
dict(**kwargs: Any) → Dict¶
Return a dictionary of the LLM.
classmethod from_orm(obj: Any) → Model¶
generate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Union[List[BaseCallbackHa... | https://api.python.langchain.com/en/latest/llms/langchain.llms.amazon_api_gateway.AmazonAPIGateway.html |
d859d0dd668f-6 | text generation models and BaseMessages for chat models).
stop – Stop words to use when generating. Model output is cut off at the
first occurrence of any of these substrings.
callbacks – Callbacks to pass through. Used for executing additional
functionality, such as logging or streaming, throughout generation.
**kwarg... | https://api.python.langchain.com/en/latest/llms/langchain.llms.amazon_api_gateway.AmazonAPIGateway.html |
d859d0dd668f-7 | invoke(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → str¶
classmethod is_lc_serializable() → bool¶
Is this class serializable?
json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Option... | https://api.python.langchain.com/en/latest/llms/langchain.llms.amazon_api_gateway.AmazonAPIGateway.html |
d859d0dd668f-8 | 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... | https://api.python.langchain.com/en/latest/llms/langchain.llms.amazon_api_gateway.AmazonAPIGateway.html |
d859d0dd668f-9 | stream(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → Iterator[str]¶
Default implementation of stream, which calls invoke.
Subclasses should override this method if they support streaming output.
to_json() → Union[Seriali... | https://api.python.langchain.com/en/latest/llms/langchain.llms.amazon_api_gateway.AmazonAPIGateway.html |
d859d0dd668f-10 | property InputType: TypeAlias¶
Get the input type for this runnable.
property OutputType: Type[str]¶
Get the input type for this runnable.
property input_schema: Type[pydantic.main.BaseModel]¶
property lc_attributes: Dict¶
List of attribute names that should be included in the serialized kwargs.
These attributes must b... | https://api.python.langchain.com/en/latest/llms/langchain.llms.amazon_api_gateway.AmazonAPIGateway.html |
5d9624c59233-0 | langchain.llms.sagemaker_endpoint.ContentHandlerBase¶
class langchain.llms.sagemaker_endpoint.ContentHandlerBase[source]¶
A handler class to transform input from LLM to a
format that SageMaker endpoint expects.
Similarly, the class handles transforming output from the
SageMaker endpoint to a format that LLM class expec... | https://api.python.langchain.com/en/latest/llms/langchain.llms.sagemaker_endpoint.ContentHandlerBase.html |
c8ec927b1845-0 | langchain.llms.ai21.AI21¶
class langchain.llms.ai21.AI21[source]¶
Bases: LLM
AI21 large language models.
To use, you should have the environment variable AI21_API_KEY
set with your API key.
Example
from langchain.llms import AI21
ai21 = AI21(model="j2-jumbo-instruct")
Create a new model by parsing and validating input ... | https://api.python.langchain.com/en/latest/llms/langchain.llms.ai21.AI21.html |
c8ec927b1845-1 | Metadata to add to the run trace.
param minTokens: int = 0¶
The minimum number of tokens to generate in the completion.
param model: str = 'j2-jumbo-instruct'¶
Model name to use.
param numResults: int = 1¶
How many completions to generate for each prompt.
param presencePenalty: langchain.llms.ai21.AI21PenaltyData = AI2... | https://api.python.langchain.com/en/latest/llms/langchain.llms.ai21.AI21.html |
c8ec927b1845-2 | Subclasses should override this method if they can batch more efficiently.
async agenerate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Union[List[BaseCallbackHandler], BaseCallbackManager, None, List[Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]]] = None, *, tags: Optional[Union[L... | https://api.python.langchain.com/en/latest/llms/langchain.llms.ai21.AI21.html |
c8ec927b1845-3 | functionality, such as logging or streaming, throughout generation.
**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 a... | https://api.python.langchain.com/en/latest/llms/langchain.llms.ai21.AI21.html |
c8ec927b1845-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[str]¶
Default implementation of astream, which calls ainvoke.
Subclasse... | https://api.python.langchain.com/en/latest/llms/langchain.llms.ai21.AI21.html |
c8ec927b1845-5 | input is still being generated.
batch(inputs: List[Union[PromptValue, str, List[BaseMessage]]], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Any) → List[str]¶
Default implementation of batch, which calls invoke N times.
Subclasses should override th... | https://api.python.langchain.com/en/latest/llms/langchain.llms.ai21.AI21.html |
c8ec927b1845-6 | classmethod from_orm(obj: Any) → Model¶
generate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Union[List[BaseCallbackHandler], BaseCallbackManager, None, List[Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]]] = None, *, tags: Optional[Union[List[str], List[List[str]]]] = None, metada... | https://api.python.langchain.com/en/latest/llms/langchain.llms.ai21.AI21.html |
c8ec927b1845-7 | functionality, such as logging or streaming, throughout generation.
**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.
classme... | https://api.python.langchain.com/en/latest/llms/langchain.llms.ai21.AI21.html |
c8ec927b1845-8 | 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... | https://api.python.langchain.com/en/latest/llms/langchain.llms.ai21.AI21.html |
c8ec927b1845-9 | 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... | https://api.python.langchain.com/en/latest/llms/langchain.llms.ai21.AI21.html |
c8ec927b1845-10 | stream(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → Iterator[str]¶
Default implementation of stream, which calls invoke.
Subclasses should override this method if they support streaming output.
to_json() → Union[Seriali... | https://api.python.langchain.com/en/latest/llms/langchain.llms.ai21.AI21.html |
c8ec927b1845-11 | property InputType: TypeAlias¶
Get the input type for this runnable.
property OutputType: Type[str]¶
Get the input type for this runnable.
property input_schema: Type[pydantic.main.BaseModel]¶
property lc_attributes: Dict¶
List of attribute names that should be included in the serialized kwargs.
These attributes must b... | https://api.python.langchain.com/en/latest/llms/langchain.llms.ai21.AI21.html |
92e64e28ac07-0 | langchain.llms.tongyi.stream_generate_with_retry¶
langchain.llms.tongyi.stream_generate_with_retry(llm: Tongyi, **kwargs: Any) → Any[source]¶
Use tenacity to retry the completion call. | https://api.python.langchain.com/en/latest/llms/langchain.llms.tongyi.stream_generate_with_retry.html |
3f1cd3203836-0 | langchain.llms.openai.OpenAI¶
class langchain.llms.openai.OpenAI[source]¶
Bases: BaseOpenAI
OpenAI large language models.
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 passed to the openai.create call c... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.OpenAI.html |
3f1cd3203836-1 | -1 returns as many tokens as possible given the prompt and
the models maximal context size.
param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run trace.
param model_kwargs: Dict[str, Any] [Optional]¶
Holds any model parameters valid for create call not explicitly specified.
param model_name: str =... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.OpenAI.html |
3f1cd3203836-2 | when using one of the many model providers that expose an OpenAI-like
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 top_p: float = 1¶
Total probability mass of tokens to consider at each step.
param verbose: bool [Optio... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.OpenAI.html |
3f1cd3203836-3 | Run the LLM on the given prompt and input.
async agenerate_prompt(prompts: List[PromptValue], stop: Optional[List[str]] = None, callbacks: Union[List[BaseCallbackHandler], BaseCallbackManager, None, List[Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]]] = None, **kwargs: Any) → LLMResult¶
Asynchronously... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.OpenAI.html |
3f1cd3203836-4 | Subclasses should override this method if they can run asynchronously.
async apredict(text: str, *, stop: Optional[Sequence[str]] = None, **kwargs: Any) → str¶
Asynchronously pass a string to the model and return a string prediction.
Use this method when calling pure text generation models and only the topcandidate gen... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.OpenAI.html |
3f1cd3203836-5 | Subclasses should override this method if they support streaming output.
async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Optional[Sequence[str]] = None, exclude_names: Optional[Sequence[... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.OpenAI.html |
3f1cd3203836-6 | Bind arguments to a Runnable, returning a new Runnable.
classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Behaves as if Config... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.OpenAI.html |
3f1cd3203836-7 | classmethod from_orm(obj: Any) → Model¶
generate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Union[List[BaseCallbackHandler], BaseCallbackManager, None, List[Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]]] = None, *, tags: Optional[Union[List[str], List[List[str]]]] = None, metada... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.OpenAI.html |
3f1cd3203836-8 | functionality, such as logging or streaming, throughout generation.
**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.
classme... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.OpenAI.html |
3f1cd3203836-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... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.OpenAI.html |
3f1cd3203836-10 | max_tokens = openai.modelname_to_contextsize("text-davinci-003")
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
classmethod parse_obj(obj: Any) → Model¶
classmethod parse_raw(b: Union[str, bytes], *... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.OpenAI.html |
3f1cd3203836-11 | to the model provider API call.
Returns
Top model prediction as a message.
save(file_path: Union[Path, str]) → None¶
Save the LLM.
Parameters
file_path – Path to file to save the LLM to.
Example:
.. code-block:: python
llm.save(file_path=”path/llm.yaml”)
classmethod schema(by_alias: bool = True, ref_template: unicode =... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.OpenAI.html |
3f1cd3203836-12 | Bind config to a Runnable, returning a new Runnable.
with_fallbacks(fallbacks: ~typing.Sequence[~langchain.schema.runnable.base.Runnable[~langchain.schema.runnable.utils.Input, ~langchain.schema.runnable.utils.Output]], *, exceptions_to_handle: ~typing.Tuple[~typing.Type[BaseException], ...] = (<class 'Exception'>,)) →... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.OpenAI.html |
3f1cd3203836-13 | Infino
Comet
Aim
Weights & Biases
SageMaker Tracking
OpenAI
Rebuff
MLflow
Helicone
Shale Protocol
WhyLabs
WandB Tracing
ClearML
Ray Serve
Log, Trace, and Monitor
Portkey
Chat Over Documents with Vectara
Vectara Text Generation
CSV
Xorbits
Jira
Spark Dataframe
Python
SQL Database
Natural Language APIs
JSON
Github
Pandas... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.OpenAI.html |
3f1cd3203836-14 | Defining Custom Tools
Tool Input Schema
Human-in-the-loop Tool Validation
Combine agents and vector stores
Access intermediate steps
Timeouts for agents
Streaming final agent output
Cap the max number of iterations
Async API
Tracking token usage
Serialization
Retry parser
Datetime parser
Pydantic (JSON) parser
Router
T... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.OpenAI.html |
0b5db1e54641-0 | langchain.llms.javelin_ai_gateway.Params¶
class langchain.llms.javelin_ai_gateway.Params[source]¶
Bases: BaseModel
Parameters for the Javelin AI Gateway LLM.
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.
p... | https://api.python.langchain.com/en/latest/llms/langchain.llms.javelin_ai_gateway.Params.html |
0b5db1e54641-1 | deep – set to True to make a deep copy of the model
Returns
new model instance
dict(*, 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, ex... | https://api.python.langchain.com/en/latest/llms/langchain.llms.javelin_ai_gateway.Params.html |
0b5db1e54641-2 | classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶
classmethod update_forward_refs(**localns: Any) → None¶
Try to update ForwardRefs on... | https://api.python.langchain.com/en/latest/llms/langchain.llms.javelin_ai_gateway.Params.html |
da8c2f5bb623-0 | langchain.llms.openai.AzureOpenAI¶
class langchain.llms.openai.AzureOpenAI[source]¶
Bases: BaseOpenAI
Azure-specific OpenAI large language models.
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 passed to... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.AzureOpenAI.html |
da8c2f5bb623-1 | Maximum number of retries to make when generating.
param max_tokens: int = 256¶
The maximum number of tokens to generate in the completion.
-1 returns as many tokens as possible given the prompt and
the models maximal context size.
param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run trace.
param... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.AzureOpenAI.html |
da8c2f5bb623-2 | them to be under a certain limit. By default, when set to None, this will
be the same as the embedding model name. However, there are some cases
where you may want to use this Embedding class with a model name not
supported by tiktoken. This can include when using Azure embeddings or
when using one of the many model pr... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.AzureOpenAI.html |
da8c2f5bb623-3 | Subclasses should override this method if they can batch more efficiently.
async agenerate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Union[List[BaseCallbackHandler], BaseCallbackManager, None, List[Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]]] = None, *, tags: Optional[Union[L... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.AzureOpenAI.html |
da8c2f5bb623-4 | functionality, such as logging or streaming, throughout generation.
**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 a... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.AzureOpenAI.html |
da8c2f5bb623-5 | 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[str]¶
Default implementation of astream, which calls ainvoke.
Subclasse... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.AzureOpenAI.html |
da8c2f5bb623-6 | input is still being generated.
batch(inputs: List[Union[PromptValue, str, List[BaseMessage]]], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Any) → List[str]¶
Default implementation of batch, which calls invoke N times.
Subclasses should override th... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.AzureOpenAI.html |
da8c2f5bb623-7 | dict(**kwargs: Any) → Dict¶
Return a dictionary of the LLM.
classmethod from_orm(obj: Any) → Model¶
generate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Union[List[BaseCallbackHandler], BaseCallbackManager, None, List[Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]]] = None, *, tags... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.AzureOpenAI.html |
da8c2f5bb623-8 | callbacks – Callbacks to pass through. Used for executing additional
functionality, such as logging or streaming, throughout generation.
**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 ea... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.AzureOpenAI.html |
da8c2f5bb623-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... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.AzureOpenAI.html |
da8c2f5bb623-10 | max_tokens = openai.modelname_to_contextsize("text-davinci-003")
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
classmethod parse_obj(obj: Any) → Model¶
classmethod parse_raw(b: Union[str, bytes], *... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.AzureOpenAI.html |
da8c2f5bb623-11 | to the model provider API call.
Returns
Top model prediction as a message.
save(file_path: Union[Path, str]) → None¶
Save the LLM.
Parameters
file_path – Path to file to save the LLM to.
Example:
.. code-block:: python
llm.save(file_path=”path/llm.yaml”)
classmethod schema(by_alias: bool = True, ref_template: unicode =... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.AzureOpenAI.html |
da8c2f5bb623-12 | Bind config to a Runnable, returning a new Runnable.
with_fallbacks(fallbacks: ~typing.Sequence[~langchain.schema.runnable.base.Runnable[~langchain.schema.runnable.utils.Input, ~langchain.schema.runnable.utils.Output]], *, exceptions_to_handle: ~typing.Tuple[~typing.Type[BaseException], ...] = (<class 'Exception'>,)) →... | https://api.python.langchain.com/en/latest/llms/langchain.llms.openai.AzureOpenAI.html |
1278d7d72502-0 | langchain.llms.deepinfra.DeepInfra¶
class langchain.llms.deepinfra.DeepInfra[source]¶
Bases: LLM
DeepInfra models.
To use, you should have the requests python package installed, and the
environment variable DEEPINFRA_API_TOKEN set with your API token, or pass
it as a named parameter to the constructor.
Only supports te... | https://api.python.langchain.com/en/latest/llms/langchain.llms.deepinfra.DeepInfra.html |
1278d7d72502-1 | Check Cache and run the LLM on the given prompt and input.
async abatch(inputs: List[Union[PromptValue, str, List[BaseMessage]]], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Any) → List[str]¶
Default implementation of abatch, which calls ainvoke N ... | https://api.python.langchain.com/en/latest/llms/langchain.llms.deepinfra.DeepInfra.html |
1278d7d72502-2 | Parameters
prompts – List of PromptValues. A PromptValue is an object that can be
converted to match the format of any language model (string for pure
text generation models and BaseMessages for chat models).
stop – Stop words to use when generating. Model output is cut off at the
first occurrence of any of these subst... | https://api.python.langchain.com/en/latest/llms/langchain.llms.deepinfra.DeepInfra.html |
1278d7d72502-3 | Asynchronously pass messages to the model and return a message prediction.
Use this method when calling chat models and only the topcandidate generation is needed.
Parameters
messages – A sequence of chat messages corresponding to a single model input.
stop – Stop words to use when generating. Model output is cut off a... | https://api.python.langchain.com/en/latest/llms/langchain.llms.deepinfra.DeepInfra.html |
1278d7d72502-4 | The jsonpatch ops can be applied in order to construct state.
async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶
Default implementation of atransform, which buffers input and calls astream.
Subclasses should override this method if th... | https://api.python.langchain.com/en/latest/llms/langchain.llms.deepinfra.DeepInfra.html |
1278d7d72502-5 | the new model: you should trust this data
deep – set to True to make a deep copy of the model
Returns
new model instance
dict(**kwargs: Any) → Dict¶
Return a dictionary of the LLM.
classmethod from_orm(obj: Any) → Model¶
generate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Union[List[BaseCallbackHa... | https://api.python.langchain.com/en/latest/llms/langchain.llms.deepinfra.DeepInfra.html |
1278d7d72502-6 | text generation models and BaseMessages for chat models).
stop – Stop words to use when generating. Model output is cut off at the
first occurrence of any of these substrings.
callbacks – Callbacks to pass through. Used for executing additional
functionality, such as logging or streaming, throughout generation.
**kwarg... | https://api.python.langchain.com/en/latest/llms/langchain.llms.deepinfra.DeepInfra.html |
1278d7d72502-7 | invoke(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → str¶
classmethod is_lc_serializable() → bool¶
Is this class serializable?
json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Option... | https://api.python.langchain.com/en/latest/llms/langchain.llms.deepinfra.DeepInfra.html |
1278d7d72502-8 | 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... | https://api.python.langchain.com/en/latest/llms/langchain.llms.deepinfra.DeepInfra.html |
1278d7d72502-9 | stream(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → Iterator[str]¶
Default implementation of stream, which calls invoke.
Subclasses should override this method if they support streaming output.
to_json() → Union[Seriali... | https://api.python.langchain.com/en/latest/llms/langchain.llms.deepinfra.DeepInfra.html |
1278d7d72502-10 | property InputType: TypeAlias¶
Get the input type for this runnable.
property OutputType: Type[str]¶
Get the input type for this runnable.
property input_schema: Type[pydantic.main.BaseModel]¶
property lc_attributes: Dict¶
List of attribute names that should be included in the serialized kwargs.
These attributes must b... | https://api.python.langchain.com/en/latest/llms/langchain.llms.deepinfra.DeepInfra.html |
cad1acd0d2f4-0 | langchain.llms.anthropic.Anthropic¶
class langchain.llms.anthropic.Anthropic[source]¶
Bases: LLM, _AnthropicCommon
Anthropic large language models.
To use, you should have the anthropic python package installed, and the
environment variable ANTHROPIC_API_KEY set with your API key, or pass
it as a named parameter to the... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anthropic.Anthropic.html |
cad1acd0d2f4-1 | param default_request_timeout: Optional[float] = None¶
Timeout for requests to Anthropic Completion API. Default is 600 seconds.
param max_tokens_to_sample: int = 256 (alias 'max_tokens')¶
Denotes the number of tokens to predict per generation.
param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anthropic.Anthropic.html |
cad1acd0d2f4-2 | Default implementation of abatch, which calls ainvoke N times.
Subclasses should override this method if they can batch more efficiently.
async agenerate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Union[List[BaseCallbackHandler], BaseCallbackManager, None, List[Optional[Union[List[BaseCallbackHand... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anthropic.Anthropic.html |
cad1acd0d2f4-3 | callbacks – Callbacks to pass through. Used for executing additional
functionality, such as logging or streaming, throughout generation.
**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 ea... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anthropic.Anthropic.html |
cad1acd0d2f4-4 | **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... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anthropic.Anthropic.html |
cad1acd0d2f4-5 | input is still being generated.
batch(inputs: List[Union[PromptValue, str, List[BaseMessage]]], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Any) → List[str]¶
Default implementation of batch, which calls invoke N times.
Subclasses should override th... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anthropic.Anthropic.html |
cad1acd0d2f4-6 | classmethod from_orm(obj: Any) → Model¶
generate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Union[List[BaseCallbackHandler], BaseCallbackManager, None, List[Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]]] = None, *, tags: Optional[Union[List[str], List[List[str]]]] = None, metada... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anthropic.Anthropic.html |
cad1acd0d2f4-7 | functionality, such as logging or streaming, throughout generation.
**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.
classme... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anthropic.Anthropic.html |
cad1acd0d2f4-8 | 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... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anthropic.Anthropic.html |
cad1acd0d2f4-9 | 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... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anthropic.Anthropic.html |
cad1acd0d2f4-10 | stream(input: Union[PromptValue, str, List[BaseMessage]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → Iterator[str]¶
Default implementation of stream, which calls invoke.
Subclasses should override this method if they support streaming output.
to_json() → Union[Seriali... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anthropic.Anthropic.html |
cad1acd0d2f4-11 | property InputType: TypeAlias¶
Get the input type for this runnable.
property OutputType: Type[str]¶
Get the input type for this runnable.
property input_schema: Type[pydantic.main.BaseModel]¶
property lc_attributes: Dict¶
List of attribute names that should be included in the serialized kwargs.
These attributes must b... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anthropic.Anthropic.html |
64fec41a2e50-0 | langchain.llms.anyscale.Anyscale¶
class langchain.llms.anyscale.Anyscale[source]¶
Bases: LLM
Anyscale Service models.
To use, you should have the environment variable ANYSCALE_SERVICE_URL,
ANYSCALE_SERVICE_ROUTE and ANYSCALE_SERVICE_TOKEN set with your Anyscale
Service, or pass it as a named parameter to the constructo... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anyscale.Anyscale.html |
64fec41a2e50-1 | param verbose: bool [Optional]¶
Whether to print out response text.
__call__(prompt: str, stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → str¶
Check Cache... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anyscale.Anyscale.html |
64fec41a2e50-2 | Asynchronously pass a sequence of prompts and return model generations.
This method should make use of batched calls for models that expose a batched
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 ag... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anyscale.Anyscale.html |
64fec41a2e50-3 | Parameters
text – String input to pass to the model.
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.... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anyscale.Anyscale.html |
64fec41a2e50-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... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anyscale.Anyscale.html |
64fec41a2e50-5 | 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] = None, deep: bool = False) → Model¶
Duplicate a model, optionally... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anyscale.Anyscale.html |
64fec41a2e50-6 | Pass a sequence of prompts to the model and return model generations.
This method should make use of batched calls for models that expose a batched
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 agno... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anyscale.Anyscale.html |
64fec41a2e50-7 | Useful for checking if an input will fit in a model’s context window.
Parameters
messages – The message inputs to tokenize.
Returns
The sum of the number of tokens across the messages.
get_token_ids(text: str) → List[int]¶
Return the ordered ids of the tokens in a text.
Parameters
text – The string input to tokenize.
R... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anyscale.Anyscale.html |
64fec41a2e50-8 | 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 = False) → Model¶
classmethod parse_obj(obj: Any) → Model¶
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = No... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anyscale.Anyscale.html |
64fec41a2e50-9 | save(file_path: Union[Path, str]) → None¶
Save the LLM.
Parameters
file_path – Path to file to save the LLM to.
Example:
.. code-block:: python
llm.save(file_path=”path/llm.yaml”)
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶
classmethod schema_json(*, by_alias... | https://api.python.langchain.com/en/latest/llms/langchain.llms.anyscale.Anyscale.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.