id
stringlengths
14
16
text
stringlengths
31
2.41k
source
stringlengths
53
121
76417e48a30b-14
constructor. property lc_namespace: List[str] Return the namespace of the langchain object. eg. [β€œlangchain”, β€œllms”, β€œopenai”] property lc_secrets: Dict[str, str] Return a map of constructor argument names to secret ids. eg. {β€œopenai_api_key”: β€œOPENAI_API_KEY”} property lc_serializable: bool This class is LangChain...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-15
the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False) Generate a dictionar...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-16
Return type unicode classmethod update_forward_refs(**localns) Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None property lc_attributes: Dict Return a list of attribute names that should be included in the serialized kwargs. These attributes mu...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-17
message (langchain.schema.BaseMessage) – Return type None attribute generation_info: Optional[Dict[str, Any]] = None Raw generation info response from the provider attribute text: str = '' Generated text output. classmethod construct(_fields_set=None, **values) Creates a new model setting __dict__ and __fields_set_...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-18
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny json(*, include=None, exclude=None, by...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-19
property lc_namespace: List[str] Return the namespace of the langchain object. eg. [β€œlangchain”, β€œllms”, β€œopenai”] property lc_secrets: Dict[str, str] Return a map of constructor argument names to secret ids. eg. {β€œopenai_api_key”: β€œOPENAI_API_KEY”} property lc_serializable: bool This class is LangChain serializable...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-20
self (Model) – Returns new model instance Return type Model dict(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False) Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters i...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-21
Parameters localns (Any) – Return type None class langchain.schema.ChatResult(*, generations, llm_output=None)[source] Bases: pydantic.main.BaseModel Class that contains all relevant information for a Chat Result. Parameters generations (List[langchain.schema.ChatGeneration]) – llm_output (Optional[dict]) – Return ...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-22
self (Model) – Returns new model instance Return type Model dict(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False) Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters i...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-23
Parameters localns (Any) – Return type None class langchain.schema.LLMResult(*, generations, llm_output=None, run=None)[source] Bases: pydantic.main.BaseModel Class that contains all relevant information for an LLM Result. Parameters generations (List[List[langchain.schema.Generation]]) – llm_output (Optional[dict])...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-24
update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(*, include=None, exclude=None, by_...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-25
exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode classmethod update_forward_refs(**localns) Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters l...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-26
self (Model) – Returns new model instance Return type Model dict(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude_defaults=False, exclude_none=False) Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters i...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-27
abstract to_string()[source] Return prompt as string. Return type str classmethod update_forward_refs(**localns) Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None property lc_attributes: Dict Return a list of attribute names that should be inc...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-28
Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes preced...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-29
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (b...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-30
property lc_serializable: bool Return whether or not the class is serializable. abstract property memory_variables: List[str] Input keys this memory class will load dynamically. class langchain.schema.BaseChatMessageHistory[source] Bases: abc.ABC Base interface for chat message history See ChatMessageHistory for def...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-31
Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes preced...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-32
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (b...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-33
Get documents relevant for a query. Parameters query (str) – string to find relevant documents for Returns List of relevant documents Return type List[langchain.schema.Document] langchain.schema.Memory alias of langchain.schema.BaseMemory class langchain.schema.BaseLLMOutputParser[source] Bases: langchain.load.serial...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-34
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-35
Return type None property lc_attributes: Dict Return a list of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor. property lc_namespace: List[str] Return the namespace of the langchain object. eg. [β€œlangchain”, β€œllms”, β€œopenai”] property lc_secrets:...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-36
update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(**kwargs)[source] Return dictiona...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-37
Returns structured output Return type langchain.schema.T parse_result(result)[source] Parse LLM Result. Parameters result (List[langchain.schema.Generation]) – Return type langchain.schema.T parse_with_prompt(completion, prompt)[source] Optional method to parse the output of an LLM call with a prompt. The prompt is ...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-38
Return type None classmethod construct(_fields_set=None, **values) 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.extra = β€˜allow’ was set since it adds all passed values Parameters _fie...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-39
Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-40
serialized kwargs. These attributes must be accepted by the constructor. property lc_namespace: List[str] Return the namespace of the langchain object. eg. [β€œlangchain”, β€œllms”, β€œopenai”] property lc_secrets: Dict[str, str] Return a map of constructor argument names to secret ids. eg. {β€œopenai_api_key”: β€œOPENAI_API_K...
https://api.python.langchain.com/en/stable/modules/base_classes.html
76417e48a30b-41
Asynchronously transform a list of documents. Parameters documents (Sequence[langchain.schema.Document]) – kwargs (Any) – Return type Sequence[langchain.schema.Document]
https://api.python.langchain.com/en/stable/modules/base_classes.html
a506c7ad03e7-0
Chat Models class langchain.chat_models.ChatOpenAI(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model='gpt-3.5-turbo', temperature=0.7, model_kwargs=None, openai_api_key=None, openai_api_base=None, openai_organization=None, openai_proxy=None, request_timeout=None, max_ret...
https://api.python.langchain.com/en/stable/modules/chat_models.html
a506c7ad03e7-1
max_retries (int) – streaming (bool) – n (int) – max_tokens (Optional[int]) – tiktoken_model_name (Optional[str]) – Return type None attribute max_retries: int = 6 Maximum number of retries to make when generating. attribute max_tokens: Optional[int] = None Maximum number of tokens to generate. attribute model_k...
https://api.python.langchain.com/en/stable/modules/chat_models.html
a506c7ad03e7-2
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 providers that expose an OpenAI-like API but with different models. In those...
https://api.python.langchain.com/en/stable/modules/chat_models.html
a506c7ad03e7-3
property lc_serializable: bool Return whether or not the class is serializable. class langchain.chat_models.AzureChatOpenAI(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model='gpt-3.5-turbo', temperature=0.7, model_kwargs=None, openai_api_key='', openai_api_base='', opena...
https://api.python.langchain.com/en/stable/modules/chat_models.html
a506c7ad03e7-4
Parameters cache (Optional[bool]) – verbose (bool) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – tags (Optional[List[str]]) – client (Any) – model (str) –...
https://api.python.langchain.com/en/stable/modules/chat_models.html
a506c7ad03e7-5
Fake ChatModel for testing purposes. Parameters cache (Optional[bool]) – verbose (bool) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – tags (Optional[List[st...
https://api.python.langchain.com/en/stable/modules/chat_models.html
a506c7ad03e7-6
Generation object. cache (Optional[bool]) – verbose (bool) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – tags (Optional[List[str]]) – client (Any) – model...
https://api.python.langchain.com/en/stable/modules/chat_models.html
a506c7ad03e7-7
Wrapper around Anthropic’s large language model. 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 constructor. Example import anthropic from langchain.llms import Anthropic model = ChatAnthropic(m...
https://api.python.langchain.com/en/stable/modules/chat_models.html
a506c7ad03e7-8
property lc_serializable: bool Return whether or not the class is serializable. class langchain.chat_models.ChatGooglePalm(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model_name='models/chat-bison-001', google_api_key=None, temperature=None, top_p=None, top_k=None, n=1)[...
https://api.python.langchain.com/en/stable/modules/chat_models.html
a506c7ad03e7-9
not return the full n completions if duplicates are generated. attribute temperature: Optional[float] = None Run inference with this temperature. Must by in the closed interval [0.0, 1.0]. attribute top_k: Optional[int] = None Decode using top-k sampling: consider the set of top_k most probable tokens. Must be positi...
https://api.python.langchain.com/en/stable/modules/chat_models.html
a506c7ad03e7-10
location (str) – credentials (Any) – request_parallelism (int) – Return type None attribute model_name: str = 'chat-bison' Model name to use.
https://api.python.langchain.com/en/stable/modules/chat_models.html
a44a60c1f5be-0
LLMs Wrappers on top of large language models APIs. class langchain.llms.AI21(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, model='j2-jumbo-instruct', temperature=0.7, maxTokens=256, minTokens=0, topP=1.0, presencePenalty=AI21PenaltyData(scale=0, applyToWhitespaces=True, applyToPunctua...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-1
maxTokens (int) – minTokens (int) – topP (float) – presencePenalty (langchain.llms.ai21.AI21PenaltyData) – countPenalty (langchain.llms.ai21.AI21PenaltyData) – frequencyPenalty (langchain.llms.ai21.AI21PenaltyData) – numResults (int) – logitBias (Optional[Dict[str, float]]) – ai21_api_key (Optional[str]) – sto...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-2
Model name to use. attribute numResults: int = 1 How many completions to generate for each prompt. attribute presencePenalty: langchain.llms.ai21.AI21PenaltyData = AI21PenaltyData(scale=0, applyToWhitespaces=True, applyToPunctuations=True, applyToNumbers=True, applyToStopwords=True, applyToEmojis=True) Penalizes repe...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-3
async agenerate_prompt(prompts, stop=None, callbacks=None, **kwargs) Take in a list of prompt values and return an LLMResult. Parameters prompts (List[langchain.schema.PromptValue]) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.B...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-4
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-5
Get the number of tokens in the message. Parameters messages (List[langchain.schema.BaseMessage]) – Return type int get_token_ids(text) Get the token present in the text. Parameters text (str) – Return type List[int] json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-6
save(file_path) Save the LLM. Parameters file_path (Union[pathlib.Path, str]) – Path to file to save the LLM to. Return type None Example: .. code-block:: python llm.save(file_path=”path/llm.yaml”) classmethod update_forward_refs(**localns) Try to update ForwardRefs on fields based on this Model, globalns and localns...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-7
property lc_serializable: bool Return whether or not the class is serializable. class langchain.llms.AlephAlpha(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model='luminous-base', maximum_tokens=64, temperature=0.0, top_k=0, top_p=0.0, presence_penalty=0.0, frequency_pena...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-8
Example from langchain.llms import AlephAlpha aleph_alpha = AlephAlpha(aleph_alpha_api_key="my-api-key") Parameters cache (Optional[bool]) – verbose (bool) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – callback_manager (Optional[lang...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-9
completion_bias_exclusion_first_token_only (bool) – contextual_control_threshold (Optional[float]) – control_log_additive (Optional[bool]) – repetition_penalties_include_completion (bool) – raw_completion (bool) – aleph_alpha_api_key (Optional[str]) – stop_sequences (Optional[List[str]]) – Return type None attri...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-10
The maximum number of tokens to be generated. attribute minimum_tokens: Optional[int] = 0 Generate at least this number of tokens. attribute model: Optional[str] = 'luminous-base' Model name to use. attribute n: int = 1 How many completions to generate for each prompt. attribute penalty_bias: Optional[str] = None P...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-11
Total probability mass of tokens to consider at each step. attribute use_multiplicative_presence_penalty: Optional[bool] = False Flag deciding whether presence penalty is applied multiplicatively (True) or additively (False). attribute verbose: bool [Optional] Whether to print out response text. __call__(prompt, stop...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-12
Predict text from text. Parameters text (str) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type str async apredict_messages(messages, *, stop=None, **kwargs) Predict message from messages. Parameters messages (List[langchain.schema.BaseMessage]) – stop (Optional[Sequence[str]]) – kwargs (Any) – Retur...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-13
Parameters kwargs (Any) – Return type Dict generate(prompts, stop=None, callbacks=None, *, tags=None, **kwargs) Run the LLM on the given prompt and input. Parameters prompts (List[str]) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.b...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-14
Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, Map...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-15
Return a list of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor. property lc_namespace: List[str] Return the namespace of the langchain object. eg. [β€œlangchain”, β€œllms”, β€œopenai”] property lc_secrets: Dict[str, str] Return a map of constructor ar...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-16
output transform functions to handle formats between LLM and the endpoint. attribute model_kwargs: Optional[Dict] = None Key word arguments to pass to the model. attribute tags: Optional[List[str]] = None Tags to add to the run trace. attribute verbose: bool [Optional] Whether to print out response text. __call__(pr...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-17
Predict text from text. Parameters text (str) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type str async apredict_messages(messages, *, stop=None, **kwargs) Predict message from messages. Parameters messages (List[langchain.schema.BaseMessage]) – stop (Optional[Sequence[str]]) – kwargs (Any) – Retur...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-18
Parameters kwargs (Any) – Return type Dict generate(prompts, stop=None, callbacks=None, *, tags=None, **kwargs) Run the LLM on the given prompt and input. Parameters prompts (List[str]) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.b...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-19
Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, Map...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-20
Return a list of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor. property lc_namespace: List[str] Return the namespace of the langchain object. eg. [β€œlangchain”, β€œllms”, β€œopenai”] property lc_secrets: Dict[str, str] Return a map of constructor ar...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-21
# Or if you want to use the chat mode, build a few-shot-prompt, or # put words in the Assistant's mouth, use HUMAN_PROMPT and AI_PROMPT: raw_prompt = "What are the biggest risks facing humanity?" prompt = f"{anthropic.HUMAN_PROMPT} {prompt}{anthropic.AI_PROMPT}" response = model(prompt) Parameters client (Any) – model...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-22
Whether to stream the results. attribute tags: Optional[List[str]] = None Tags to add to the run trace. attribute temperature: Optional[float] = None A non-negative float that tunes the degree of randomness in generation. attribute top_k: Optional[int] = None Number of most likely tokens to consider at each step. at...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-23
kwargs (Any) – Return type langchain.schema.LLMResult async apredict(text, *, stop=None, **kwargs) Predict text from text. Parameters text (str) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type str async apredict_messages(messages, *, stop=None, **kwargs) Predict message from messages. Parameters mes...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-24
Returns new model instance Return type Model dict(**kwargs) Return a dictionary of the LLM. Parameters kwargs (Any) – Return type Dict generate(prompts, stop=None, callbacks=None, *, tags=None, **kwargs) Run the LLM on the given prompt and input. Parameters prompts (List[str]) – stop (Optional[List[str]]) – callba...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-25
Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, Map...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-26
Parameters prompt (str) – The prompt to pass into the model. stop (Optional[List[str]]) – Optional list of stop words to use when generating. Returns A generator representing the stream of tokens from Anthropic. Return type Generator Example prompt = "Write a poem about a stream." prompt = f"\n\nHuman: {prompt}\n\nAssi...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-27
Service, or pass it as a named parameter to the constructor. Example from langchain.llms import Anyscale anyscale = Anyscale(anyscale_service_url="SERVICE_URL", anyscale_service_route="SERVICE_ROUTE", anyscale_service_token="SERVICE_TOKEN") # Use Ray for distributed processing im...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-28
kwargs (Any) – Return type str async agenerate(prompts, stop=None, callbacks=None, *, tags=None, **kwargs) Run the LLM on the given prompt and input. Parameters prompts (List[str]) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.B...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-29
Default values are respected, but no other validation is performed. Behaves as if Config.extra = β€˜allow’ was set since it adds all passed values Parameters _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy(*, include=None, exclude=None, update=None, deep=False) Duplicate a model, optionally choo...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-30
Take in a list of prompt values and return an LLMResult. Parameters prompts (List[langchain.schema.PromptValue]) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – kwargs (Any) – Return type langchain.schema....
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-31
dumps_kwargs (Any) – Return type unicode predict(text, *, stop=None, **kwargs) Predict text from text. Parameters text (str) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type str predict_messages(messages, *, stop=None, **kwargs) Predict message from messages. Parameters messages (List[langchain.schem...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-32
property lc_serializable: bool Return whether or not the class is serializable. class langchain.llms.Aviary(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, model='amazon/LightGPT', aviary_url=None, aviary_token=None, use_prompt_format=True, version=None)[source] Bases: langchain.llms.ba...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-33
Tags to add to the run trace. attribute verbose: bool [Optional] Whether to print out response text. __call__(prompt, stop=None, callbacks=None, **kwargs) Check Cache and run the LLM on the given prompt and input. Parameters prompt (str) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callba...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-34
Predict message from messages. Parameters messages (List[langchain.schema.BaseMessage]) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type langchain.schema.BaseMessage classmethod construct(_fields_set=None, **values) Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated d...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-35
Parameters prompts (List[str]) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – tags (Optional[List[str]]) – kwargs (Any) – Return type langchain.schema.LLMResult generate_prompt(prompts, stop=None, callba...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-36
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (b...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-37
property lc_namespace: List[str] Return the namespace of the langchain object. eg. [β€œlangchain”, β€œllms”, β€œopenai”] property lc_secrets: Dict[str, str] Return a map of constructor argument names to secret ids. eg. {β€œopenai_api_key”: β€œOPENAI_API_KEY”} property lc_serializable: bool Return whether or not the class is s...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-38
attribute content_formatter: Any = None The content formatter that provides an input and output transform function to handle formats between the LLM and the endpoint attribute deployment_name: str = '' Deployment Name for Endpoint. Should be passed to constructor or specified as env var AZUREML_DEPLOYMENT_NAME. attri...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-39
kwargs (Any) – Return type langchain.schema.LLMResult async agenerate_prompt(prompts, stop=None, callbacks=None, **kwargs) Take in a list of prompt values and return an LLMResult. Parameters prompts (List[langchain.schema.PromptValue]) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callback...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-40
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-41
Get the number of tokens in the message. Parameters messages (List[langchain.schema.BaseMessage]) – Return type int get_token_ids(text) Get the token present in the text. Parameters text (str) – Return type List[int] json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-42
save(file_path) Save the LLM. Parameters file_path (Union[pathlib.Path, str]) – Path to file to save the LLM to. Return type None Example: .. code-block:: python llm.save(file_path=”path/llm.yaml”) classmethod update_forward_refs(**localns) Try to update ForwardRefs on fields based on this Model, globalns and localns...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-43
property lc_serializable: bool Return whether or not the class is serializable. class langchain.llms.AzureOpenAI(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model='text-davinci-003', temperature=0.7, max_tokens=256, top_p=1, frequency_penalty=0, presence_penalty=0, n=1, ...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-44
max_tokens (int) – top_p (float) – frequency_penalty (float) – presence_penalty (float) – n (int) – best_of (int) – model_kwargs (Dict[str, Any]) – openai_api_key (Optional[str]) – openai_api_base (Optional[str]) – openai_organization (Optional[str]) – openai_proxy (Optional[str]) – batch_size (int) – reque...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-45
attribute logit_bias: Optional[Dict[str, float]] [Optional] Adjust the probability of specific tokens being generated. attribute max_retries: int = 6 Maximum number of retries to make when generating. attribute max_tokens: int = 256 The maximum number of tokens to generate in the completion. -1 returns as many token...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-46
supported by tiktoken. This can include when using Azure embeddings or 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. attribute top_p: float = 1 Total prob...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-47
kwargs (Any) – Return type langchain.schema.LLMResult async apredict(text, *, stop=None, **kwargs) Predict text from text. Parameters text (str) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type str async apredict_messages(messages, *, stop=None, **kwargs) Predict message from messages. Parameters mes...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-48
self (Model) – Returns new model instance Return type Model create_llm_result(choices, prompts, token_usage) Create the LLMResult from the choices and prompts. Parameters choices (Any) – prompts (List[str]) – token_usage (Dict[str, int]) – Return type langchain.schema.LLMResult dict(**kwargs) Return a dictionary ...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-49
Parameters messages (List[langchain.schema.BaseMessage]) – Return type int get_sub_prompts(params, prompts, stop=None) Get the sub prompts for llm call. Parameters params (Dict[str, Any]) – prompts (List[str]) – stop (Optional[List[str]]) – Return type List[List[str]] get_token_ids(text) Get the token IDs using t...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-50
int Example max_tokens = openai.max_token_for_prompt("Tell me a joke.") static modelname_to_contextsize(modelname) Calculate the maximum number of tokens possible to generate for a model. Parameters modelname (str) – The modelname we want to know the context size for. Returns The maximum context size Return type int E...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-51
stop (Optional[List[str]]) – Optional list of stop words to use when generating. Returns A generator representing the stream of tokens from OpenAI. Return type Generator Example generator = openai.stream("Tell me a joke.") for token in generator: yield token classmethod update_forward_refs(**localns) Try to update...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-52
Example from langchain.llms import Banana banana = Banana(model_key="") Parameters cache (Optional[bool]) – verbose (bool) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – callback_manager (Optional[langchain.callbacks.base.BaseCallback...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-53
kwargs (Any) – Return type langchain.schema.LLMResult async agenerate_prompt(prompts, stop=None, callbacks=None, **kwargs) Take in a list of prompt values and return an LLMResult. Parameters prompts (List[langchain.schema.PromptValue]) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callback...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-54
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-55
Get the number of tokens in the message. Parameters messages (List[langchain.schema.BaseMessage]) – Return type int get_token_ids(text) Get the token present in the text. Parameters text (str) – Return type List[int] json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-56
save(file_path) Save the LLM. Parameters file_path (Union[pathlib.Path, str]) – Path to file to save the LLM to. Return type None Example: .. code-block:: python llm.save(file_path=”path/llm.yaml”) classmethod update_forward_refs(**localns) Try to update ForwardRefs on fields based on this Model, globalns and localns...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-57
be passed in with the format input={model_param: value, …} The Baseten model must accept a dictionary of input with the key β€œprompt” and return a dictionary with a key β€œdata” which maps to a list of response strings. Example Parameters cache (Optional[bool]) – verbose (bool) – callbacks (Optional[Union[List[langchain...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-58
kwargs (Any) – Return type langchain.schema.LLMResult async agenerate_prompt(prompts, stop=None, callbacks=None, **kwargs) Take in a list of prompt values and return an LLMResult. Parameters prompts (List[langchain.schema.PromptValue]) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[langchain.callback...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-59
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool...
https://api.python.langchain.com/en/stable/modules/llms.html
a44a60c1f5be-60
Get the number of tokens in the message. Parameters messages (List[langchain.schema.BaseMessage]) – Return type int get_token_ids(text) Get the token present in the text. Parameters text (str) – Return type List[int] json(*, include=None, exclude=None, by_alias=False, skip_defaults=None, exclude_unset=False, exclude...
https://api.python.langchain.com/en/stable/modules/llms.html