id stringlengths 14 16 | text stringlengths 20 3.26k | source stringlengths 65 181 |
|---|---|---|
01e680dec4f4-12 | exclude_types (Optional[Sequence[str]]) – Exclude logs with these types.
exclude_tags (Optional[Sequence[str]]) – Exclude logs with these tags.
kwargs (Any) –
Return type
Union[AsyncIterator[RunLogPatch], AsyncIterator[RunLog]]
async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kw... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-13 | kwargs (Any) –
Return type
List[str]
batch_as_completed(inputs: Sequence[Input], config: Optional[Union[RunnableConfig, Sequence[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → Iterator[Tuple[int, Union[Output, Exception]]]¶
Run invoke in parallel on a list of inputs,
yielding ... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-14 | 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 (Optional[Sequence[str]]) – A list of fields to include in the config schema.
Returns
A pydantic model that can be used to valida... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-15 | Return type
RunnableSerializable[Input, Output]
configurable_fields(**kwargs: Union[ConfigurableField, ConfigurableFieldSingleOption, ConfigurableFieldMultiOption]) → RunnableSerializable[Input, Output]¶
Configure particular runnable fields at runtime.
from langchain_core.runnables import ConfigurableField
from langcha... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-16 | values (Any) –
Return type
Model
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 choose which fields to include, exclude an... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-17 | Parameters
obj (Any) –
Return type
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, meta... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-18 | tags (Optional[Union[List[str], List[List[str]]]]) –
metadata (Optional[Union[Dict[str, Any], List[Dict[str, Any]]]]) –
run_name (Optional[Union[str, List[str]]]) –
run_id (Optional[Union[UUID, List[Optional[UUID]]]]) –
**kwargs –
Returns
An LLMResult, which contains a list of candidate Generations for each inputp... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-19 | functionality, such as logging or streaming, throughout generation.
**kwargs (Any) – 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.
R... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-20 | 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 (str) – The string input to tokenize.
Returns
The integer number of tokens in the text.
Return type
int
get_num_tokens_from_messages(messages: List[BaseMessage]) → int¶
Get the number of t... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-21 | Return type
List[int]
invoke(input: Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → str¶
Transform a single input into an output. Override to implement.
Parameters
input... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-22 | 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/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-23 | Parameters
obj (Any) –
Return type
Model
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
Parameters
b (Union[str, bytes]) –
content_type (unicode) –
encoding (unicode) –
proto (Protocol) –
allow_pi... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-24 | )
chain.invoke("[1, 2, 3]")
# -> {"str": "[1, 2, 3]", "json": [1, 2, 3], "bytes": b"[1, 2, 3]"}
json_and_bytes_chain = chain.pick(["json", "bytes"])
json_and_bytes_chain.invoke("[1, 2, 3]")
# -> {"json": [1, 2, 3], "bytes": b"[1, 2, 3]"}
Parameters
keys (Union[str, List[str]]) –
Return type
RunnableSerializable[Any, A... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-25 | # -> [4, 6, 8]
Parameters
others (Union[Runnable[Any, Other], Callable[[Any], Other]]) –
name (Optional[str]) –
Return type
RunnableSerializable[Input, Other]
predict(text: str, *, stop: Optional[Sequence[str]] = None, **kwargs: Any) → str¶
[Deprecated]
Notes
Deprecated since version langchain-core==0.1.7: Use invoke... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-26 | Parameters
by_alias (bool) –
ref_template (unicode) –
dumps_kwargs (Any) –
Return type
unicode
stream(input: Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → Iterator[... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-27 | Parameters
localns (Any) –
Return type
None
classmethod validate(value: Any) → Model¶
Parameters
value (Any) –
Return type
Model
with_alisteners(*, on_start: Optional[AsyncListener] = None, on_end: Optional[AsyncListener] = None, on_error: Optional[AsyncListener] = None) → Runnable[Input, Output]¶
Bind asynchronous l... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-28 | Example
from typing import Iterator
from langchain_core.runnables import RunnableGenerator
def _generate_immediate_error(input: Iterator) -> Iterator[str]:
raise ValueError()
yield ""
def _generate(input: Iterator) -> Iterator[str]:
yield from "foo bar"
runnable = RunnableGenerator(_generate_immediate_error... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-29 | 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_time, end_time, and any tags or metadata
added to the run.
Example:
from ... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-30 | count = 0
def _lambda(x: int) -> None:
global count
count = count + 1
if x == 1:
raise ValueError("x is 1")
else:
pass
runnable = RunnableLambda(_lambda)
try:
runnable.with_retry(
stop_after_attempt=2,
retry_if_exception_type=(ValueError,),
).invoke(1)
except Val... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
01e680dec4f4-31 | Parameters
input_type (Optional[Type[Input]]) –
output_type (Optional[Type[Output]]) –
Return type
Runnable[Input, Output]
property InputType: TypeAlias¶
Get the input type for this runnable.
property OutputType: Type[str]¶
Get the input type for this runnable.
property config_specs: List[ConfigurableFieldSpec]¶
List... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html |
92af45e4fe31-0 | langchain_community.llms.chatglm.ChatGLM¶
class langchain_community.llms.chatglm.ChatGLM[source]¶
Bases: LLM
ChatGLM LLM service.
Example
from langchain_community.llms import ChatGLM
endpoint_url = (
"http://127.0.0.1:8000"
)
ChatGLM_llm = ChatGLM(
endpoint_url=endpoint_url
)
Create a new model by parsing and v... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-1 | Keyword arguments to pass to the model.
param tags: Optional[List[str]] = None¶
Tags to add to the run trace.
param temperature: float = 0.1¶
LLM model temperature from 0 to 10.
param top_p: float = 0.7¶
Top P for nucleus sampling from 0 to 1
param verbose: bool [Optional]¶
Whether to print out response text.
param wit... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-2 | 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.
Parameters
inputs (List[Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]]]) –
config (Optional[Union[RunnableConfig, ... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-3 | Asynchronously pass a sequence of prompts to a model and return 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 a... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-4 | 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_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-5 | the runnable did not implement a native async version of invoke.
Subclasses should override this method if they can run asynchronously.
Parameters
input (Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]]) –
config (Optional[RunnableConfig]) –
stop (Optional[List[st... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-6 | from langchain_core.runnables import Runnable
from operator import itemgetter
prompt = (
SystemMessagePromptTemplate.from_template("You are a nice assistant.")
+ "{question}"
)
llm = FakeStreamingListLLM(responses=["foo-lish"])
chain: Runnable = prompt | llm | {"str": StrOutputParser()}
chain_with_assign = chai... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-7 | config (Optional[RunnableConfig]) –
stop (Optional[List[str]]) –
kwargs (Any) –
Return type
AsyncIterator[str]
astream_events(input: Any, config: Optional[RunnableConfig] = None, *, version: Literal['v1', 'v2'], include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tag... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-8 | data: Dict[str, Any]
Below is a table that illustrates some evens that might be emitted by various
chains. Metadata fields have been omitted from the table for brevity.
Chain definitions have been included after the table.
ATTENTION This reference table is for the V2 version of the schema.
event
name
chunk
input
output... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-9 | Here are declarations associated with the events shown above:
format_docs:
def format_docs(docs: List[Document]) -> str:
'''Format the docs.'''
return ", ".join([doc.page_content for doc in docs])
format_docs = RunnableLambda(format_docs)
some_tool:
@tool
def some_tool(x: int, y: str) -> dict:
'''Some_tool.... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-10 | "tags": [],
},
]
Parameters
input (Any) – The input to the runnable.
config (Optional[RunnableConfig]) – The config to use for the runnable.
version (Literal['v1', 'v2']) – The version of the schema to use either v2 or v1.
Users should use v2.
v1 is for backwards compatibility and will be deprecated
in 0.4.0.
No de... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-11 | An async stream of StreamEvents.
Return type
AsyncIterator[StreamEvent]
Notes
async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, diff: bool = True, with_streamed_output_list: bool = True, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: O... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-12 | exclude_tags (Optional[Sequence[str]]) – Exclude logs with these tags.
kwargs (Any) –
Return type
Union[AsyncIterator[RunLogPatch], AsyncIterator[RunLog]]
async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶
Default implementation of a... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-13 | kwargs (Any) –
Return type
List[str]
batch_as_completed(inputs: Sequence[Input], config: Optional[Union[RunnableConfig, Sequence[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → Iterator[Tuple[int, Union[Output, Exception]]]¶
Run invoke in parallel on a list of inputs,
yielding ... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-14 | 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 (Optional[Sequence[str]]) – A list of fields to include in the config schema.
Returns
A pydantic model that can be used to valida... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-15 | Return type
RunnableSerializable[Input, Output]
configurable_fields(**kwargs: Union[ConfigurableField, ConfigurableFieldSingleOption, ConfigurableFieldMultiOption]) → RunnableSerializable[Input, Output]¶
Configure particular runnable fields at runtime.
from langchain_core.runnables import ConfigurableField
from langcha... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-16 | values (Any) –
Return type
Model
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 choose which fields to include, exclude an... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-17 | Parameters
obj (Any) –
Return type
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, meta... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-18 | tags (Optional[Union[List[str], List[List[str]]]]) –
metadata (Optional[Union[Dict[str, Any], List[Dict[str, Any]]]]) –
run_name (Optional[Union[str, List[str]]]) –
run_id (Optional[Union[UUID, List[Optional[UUID]]]]) –
**kwargs –
Returns
An LLMResult, which contains a list of candidate Generations for each inputp... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-19 | functionality, such as logging or streaming, throughout generation.
**kwargs (Any) – 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.
R... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-20 | 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 (str) – The string input to tokenize.
Returns
The integer number of tokens in the text.
Return type
int
get_num_tokens_from_messages(messages: List[BaseMessage]) → int¶
Get the number of t... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-21 | Return type
List[int]
invoke(input: Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → str¶
Transform a single input into an output. Override to implement.
Parameters
input... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-22 | 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/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-23 | Parameters
obj (Any) –
Return type
Model
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
Parameters
b (Union[str, bytes]) –
content_type (unicode) –
encoding (unicode) –
proto (Protocol) –
allow_pi... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-24 | )
chain.invoke("[1, 2, 3]")
# -> {"str": "[1, 2, 3]", "json": [1, 2, 3], "bytes": b"[1, 2, 3]"}
json_and_bytes_chain = chain.pick(["json", "bytes"])
json_and_bytes_chain.invoke("[1, 2, 3]")
# -> {"json": [1, 2, 3], "bytes": b"[1, 2, 3]"}
Parameters
keys (Union[str, List[str]]) –
Return type
RunnableSerializable[Any, A... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-25 | # -> [4, 6, 8]
Parameters
others (Union[Runnable[Any, Other], Callable[[Any], Other]]) –
name (Optional[str]) –
Return type
RunnableSerializable[Input, Other]
predict(text: str, *, stop: Optional[Sequence[str]] = None, **kwargs: Any) → str¶
[Deprecated]
Notes
Deprecated since version langchain-core==0.1.7: Use invoke... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-26 | Parameters
by_alias (bool) –
ref_template (unicode) –
dumps_kwargs (Any) –
Return type
unicode
stream(input: Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → Iterator[... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-27 | Parameters
localns (Any) –
Return type
None
classmethod validate(value: Any) → Model¶
Parameters
value (Any) –
Return type
Model
with_alisteners(*, on_start: Optional[AsyncListener] = None, on_end: Optional[AsyncListener] = None, on_error: Optional[AsyncListener] = None) → Runnable[Input, Output]¶
Bind asynchronous l... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-28 | Example
from typing import Iterator
from langchain_core.runnables import RunnableGenerator
def _generate_immediate_error(input: Iterator) -> Iterator[str]:
raise ValueError()
yield ""
def _generate(input: Iterator) -> Iterator[str]:
yield from "foo bar"
runnable = RunnableGenerator(_generate_immediate_error... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-29 | 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_time, end_time, and any tags or metadata
added to the run.
Example:
from ... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-30 | count = 0
def _lambda(x: int) -> None:
global count
count = count + 1
if x == 1:
raise ValueError("x is 1")
else:
pass
runnable = RunnableLambda(_lambda)
try:
runnable.with_retry(
stop_after_attempt=2,
retry_if_exception_type=(ValueError,),
).invoke(1)
except Val... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
92af45e4fe31-31 | Parameters
input_type (Optional[Type[Input]]) –
output_type (Optional[Type[Output]]) –
Return type
Runnable[Input, Output]
property InputType: TypeAlias¶
Get the input type for this runnable.
property OutputType: Type[str]¶
Get the input type for this runnable.
property config_specs: List[ConfigurableFieldSpec]¶
List... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.chatglm.ChatGLM.html |
1dad1409ce63-0 | langchain_community.llms.beam.Beam¶
class langchain_community.llms.beam.Beam[source]¶
Bases: LLM
Beam API for gpt2 large language model.
To use, you should have the beam-sdk python package installed,
and the environment variable BEAM_CLIENT_ID set with your client id
and BEAM_CLIENT_SECRET set with your client secret. ... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-1 | If None, will use the global cache if it’s set, otherwise no cache.
If instance of BaseCache, will use the provided cache.
Caching is not currently supported for streaming methods of models.
param callback_manager: Optional[BaseCallbackManager] = None¶
[DEPRECATED]
param callbacks: Callbacks = None¶
Callbacks to add to... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-2 | Parameters
prompt (str) –
stop (Optional[List[str]]) –
callbacks (Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]) –
tags (Optional[List[str]]) –
metadata (Optional[Dict[str, Any]]) –
kwargs (Any) –
Return type
str
async abatch(inputs: List[Union[PromptValue, str, Sequence[Union[BaseMessage, List[... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-3 | return_exceptions (bool) –
kwargs (Optional[Any]) –
Return type
AsyncIterator[Tuple[int, Union[Output, Exception]]]
async agenerate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Union[List[BaseCallbackHandler], BaseCallbackManager, None, List[Optional[Union[List[BaseCallbackHandler], BaseCallbackMa... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-4 | to the model provider API call.
tags (Optional[Union[List[str], List[List[str]]]]) –
metadata (Optional[Union[Dict[str, Any], List[Dict[str, Any]]]]) –
run_name (Optional[Union[str, List[str]]]) –
run_id (Optional[Union[UUID, List[Optional[UUID]]]]) –
**kwargs –
Returns
An LLMResult, which contains a list of candi... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-5 | first occurrence of any of these substrings.
callbacks (Union[List[BaseCallbackHandler], BaseCallbackManager, None, List[Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]]]) – Callbacks to pass through. Used for executing additional
functionality, such as logging or streaming, throughout generation.
**kwa... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-6 | Parameters
text (str) –
stop (Optional[Sequence[str]]) –
kwargs (Any) –
Return type
str
async apredict_messages(messages: List[BaseMessage], *, stop: Optional[Sequence[str]] = None, **kwargs: Any) → BaseMessage¶
[Deprecated]
Notes
Deprecated since version langchain-core==0.1.7: Use ainvoke instead.
Parameters
messag... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-7 | print(chain_with_assign.output_schema.schema()) #
{'title': 'RunnableSequenceOutput', 'type': 'object', 'properties':
{'str': {'title': 'Str',
'type': 'string'}, 'hello': {'title': 'Hello', 'type': 'string'}}}
Parameters
kwargs (Union[Runnable[Dict[str, Any], Any], Callable[[Dict[str, Any]], Any], Mapping[str, Union[Ru... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-8 | [Beta] Generate a stream of events.
Use to create an iterator over StreamEvents that provide real-time information
about the progress of the runnable, including StreamEvents from intermediate
results.
A StreamEvent is a dictionary with the following schema:
event: str - Event names are of theformat: on_[runnable_type]_... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-9 | AIMessageChunk(content=”hello world”)
on_llm_start
[model name]
{‘input’: ‘hello’}
on_llm_stream
[model name]
‘Hello’
on_llm_end
[model name]
‘Hello human!’
on_chain_start
format_docs
on_chain_stream
format_docs
“hello world!, goodbye world!”
on_chain_end
format_docs
[Document(…)]
“hello world!, goodbye world!”
on_tool... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-10 | Example:
from langchain_core.runnables import RunnableLambda
async def reverse(s: str) -> str:
return s[::-1]
chain = RunnableLambda(func=reverse)
events = [
event async for event in chain.astream_events("hello", version="v2")
]
# will produce the following events (run_id, and parent_ids
# has been omitted for ... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-11 | exclude_names (Optional[Sequence[str]]) – Exclude events from runnables with matching names.
exclude_types (Optional[Sequence[str]]) – Exclude events from runnables with matching types.
exclude_tags (Optional[Sequence[str]]) – Exclude events from runnables with matching tags.
kwargs (Any) – Additional keyword arguments... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-12 | diff (bool) – Whether to yield diffs between each step, or the current state.
with_streamed_output_list (bool) – Whether to yield the streamed_output list.
include_names (Optional[Sequence[str]]) – Only include logs with these names.
include_types (Optional[Sequence[str]]) – Only include logs with these types.
include_... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-13 | 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.
Parameters
inputs (List[Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]]]) –
config (Optional[Union[RunnableConfig, ... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-14 | # Output is 'One two three four five.'
# With bind.
chain = (
llm.bind(stop=["three"])
| StrOutputParser()
)
chain.invoke("Repeat quoted words exactly: 'One two three four five.'")
# Output is 'One two'
Parameters
kwargs (Any) –
Return type
Runnable[Input, Output]
config_schema(*, include: Optional[Sequence[st... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-15 | print(
model.with_config(
configurable={"llm": "openai"}
).invoke("which organization created you?").content
)
Parameters
which (ConfigurableField) –
default_key (str) –
prefix_keys (bool) –
kwargs (Union[Runnable[Input, Output], Callable[[], Runnable[Input, Output]]]) –
Return type
RunnableSerializ... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-16 | 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: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-17 | Parameters
obj (Any) –
Return type
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, meta... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-18 | tags (Optional[Union[List[str], List[List[str]]]]) –
metadata (Optional[Union[Dict[str, Any], List[Dict[str, Any]]]]) –
run_name (Optional[Union[str, List[str]]]) –
run_id (Optional[Union[UUID, List[Optional[UUID]]]]) –
**kwargs –
Returns
An LLMResult, which contains a list of candidate Generations for each inputp... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-19 | functionality, such as logging or streaming, throughout generation.
**kwargs (Any) – 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.
R... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-20 | 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 (str) – The string input to tokenize.
Returns
The integer number of tokens in the text.
Return type
int
get_num_tokens_from_messages(messages: List[BaseMessage]) → int¶
Get the number of t... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-21 | Return type
List[int]
invoke(input: Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → str¶
Transform a single input into an output. Override to implement.
Parameters
input... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-22 | 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/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-23 | Parameters
obj (Any) –
Return type
Model
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
Parameters
b (Union[str, bytes]) –
content_type (unicode) –
encoding (unicode) –
proto (Protocol) –
allow_pi... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-24 | )
chain.invoke("[1, 2, 3]")
# -> {"str": "[1, 2, 3]", "json": [1, 2, 3], "bytes": b"[1, 2, 3]"}
json_and_bytes_chain = chain.pick(["json", "bytes"])
json_and_bytes_chain.invoke("[1, 2, 3]")
# -> {"json": [1, 2, 3], "bytes": b"[1, 2, 3]"}
Parameters
keys (Union[str, List[str]]) –
Return type
RunnableSerializable[Any, A... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-25 | # -> [4, 6, 8]
Parameters
others (Union[Runnable[Any, Other], Callable[[Any], Other]]) –
name (Optional[str]) –
Return type
RunnableSerializable[Input, Other]
predict(text: str, *, stop: Optional[Sequence[str]] = None, **kwargs: Any) → str¶
[Deprecated]
Notes
Deprecated since version langchain-core==0.1.7: Use invoke... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-26 | ref_template (unicode) –
Return type
DictStrAny
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶
Parameters
by_alias (bool) –
ref_template (unicode) –
dumps_kwargs (Any) –
Return type
unicode
stream(input: Union[PromptValue, str, Sequ... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-27 | kwargs (Optional[Any]) –
Return type
Iterator[Output]
classmethod update_forward_refs(**localns: Any) → None¶
Try to update ForwardRefs on fields based on this Model, globalns and localns.
Parameters
localns (Any) –
Return type
None
classmethod validate(value: Any) → Model¶
Parameters
value (Any) –
Return type
Model... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-28 | kwargs (Any) –
Return type
Runnable[Input, Output]
with_fallbacks(fallbacks: Sequence[Runnable[Input, Output]], *, exceptions_to_handle: Tuple[Type[BaseException], ...] = (<class 'Exception'>,), exception_key: Optional[str] = None) → RunnableWithFallbacksT[Input, Output]¶
Add fallbacks to a runnable, returning a new R... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-29 | Return type
RunnableWithFallbacksT[Input, Output]
with_listeners(*, on_start: Optional[Union[Callable[[Run], None], Callable[[Run, RunnableConfig], None]]] = None, on_end: Optional[Union[Callable[[Run], None], Callable[[Run, RunnableConfig], None]]] = None, on_error: Optional[Union[Callable[[Run], None], Callable[[Run,... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-30 | on_error (Optional[Union[Callable[[Run], None], Callable[[Run, RunnableConfig], None]]]) –
Return type
Runnable[Input, Output]
with_retry(*, retry_if_exception_type: ~typing.Tuple[~typing.Type[BaseException], ...] = (<class 'Exception'>,), wait_exponential_jitter: bool = True, stop_after_attempt: int = 3) → Runnable[I... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
1dad1409ce63-31 | Not implemented on this class.
Parameters
schema (Union[Dict, Type[BaseModel]]) –
kwargs (Any) –
Return type
Runnable[Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]], Union[Dict, BaseModel]]
with_types(*, input_type: Optional[Type[Input]] = None, output_type: Opt... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.beam.Beam.html |
713101b496eb-0 | langchain_community.llms.together.Together¶
class langchain_community.llms.together.Together[source]¶
Bases: LLM
[Deprecated] LLM models from Together.
To use, you’ll need an API key which you can find here:
https://api.together.xyz/settings/api-keys. This can be passed in as init param
together_api_key or set as envir... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.together.Together.html |
713101b496eb-1 | param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run trace.
param model: str [Required]¶
Model name. Available models listed here:
https://docs.together.ai/docs/inference-models
param repetition_penalty: Optional[float] = None¶
A number that controls the diversity of generated text by reducing th... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.together.Together.html |
713101b496eb-2 | 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¶
[Deprecated... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.together.Together.html |
713101b496eb-3 | return_exceptions (bool) –
kwargs (Any) –
Return type
List[str]
async abatch_as_completed(inputs: Sequence[Input], config: Optional[Union[RunnableConfig, Sequence[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → AsyncIterator[Tuple[int, Union[Output, Exception]]]¶
Run ainvoke i... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.together.Together.html |
713101b496eb-4 | Parameters
prompts (List[str]) – List of string prompts.
stop (Optional[List[str]]) – Stop words to use when generating. Model output is cut off at the
first occurrence of any of these substrings.
callbacks (Union[List[BaseCallbackHandler], BaseCallbackManager, None, List[Optional[Union[List[BaseCallbackHandler], BaseC... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.together.Together.html |
713101b496eb-5 | Parameters
prompts (List[PromptValue]) – 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 (Optional[List[str]]) – Stop words to use when generating. Model output is cut off at ... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.together.Together.html |
713101b496eb-6 | kwargs (Any) –
Return type
str
async apredict(text: str, *, stop: Optional[Sequence[str]] = None, **kwargs: Any) → str¶
[Deprecated]
Notes
Deprecated since version langchain-core==0.1.7: Use ainvoke instead.
Parameters
text (str) –
stop (Optional[Sequence[str]]) –
kwargs (Any) –
Return type
str
async apredict_messa... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.together.Together.html |
713101b496eb-7 | chain_with_assign = chain.assign(hello=itemgetter("str") | llm)
print(chain_with_assign.input_schema.schema())
# {'title': 'PromptInput', 'type': 'object', 'properties':
{'question': {'title': 'Question', 'type': 'string'}}}
print(chain_with_assign.output_schema.schema()) #
{'title': 'RunnableSequenceOutput', 'type': '... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.together.Together.html |
713101b496eb-8 | kwargs (Any) –
Return type
AsyncIterator[str]
astream_events(input: Any, config: Optional[RunnableConfig] = None, *, version: Literal['v1', 'v2'], 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_community.llms.together.Together.html |
713101b496eb-9 | Below is a table that illustrates some evens that might be emitted by various
chains. Metadata fields have been omitted from the table for brevity.
Chain definitions have been included after the table.
ATTENTION This reference table is for the V2 version of the schema.
event
name
chunk
input
output
on_chat_model_start
... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.together.Together.html |
713101b496eb-10 | format_docs:
def format_docs(docs: List[Document]) -> str:
'''Format the docs.'''
return ", ".join([doc.page_content for doc in docs])
format_docs = RunnableLambda(format_docs)
some_tool:
@tool
def some_tool(x: int, y: str) -> dict:
'''Some_tool.'''
return {"x": x, "y": y}
prompt:
template = ChatPromptT... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.together.Together.html |
713101b496eb-11 | },
]
Parameters
input (Any) – The input to the runnable.
config (Optional[RunnableConfig]) – The config to use for the runnable.
version (Literal['v1', 'v2']) – The version of the schema to use either v2 or v1.
Users should use v2.
v1 is for backwards compatibility and will be deprecated
in 0.4.0.
No default will be as... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.together.Together.html |
713101b496eb-12 | An async stream of StreamEvents.
Return type
AsyncIterator[StreamEvent]
Notes
async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, diff: bool = True, with_streamed_output_list: bool = True, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: O... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.together.Together.html |
713101b496eb-13 | exclude_tags (Optional[Sequence[str]]) – Exclude logs with these tags.
kwargs (Any) –
Return type
Union[AsyncIterator[RunLogPatch], AsyncIterator[RunLog]]
async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶
Default implementation of a... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.together.Together.html |
713101b496eb-14 | kwargs (Any) –
Return type
List[str]
batch_as_completed(inputs: Sequence[Input], config: Optional[Union[RunnableConfig, Sequence[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → Iterator[Tuple[int, Union[Output, Exception]]]¶
Run invoke in parallel on a list of inputs,
yielding ... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.together.Together.html |
713101b496eb-15 | 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 (Optional[Sequence[str]]) – A list of fields to include in the config schema.
Returns
A pydantic model that can be used to valida... | https://api.python.langchain.com/en/latest/llms/langchain_community.llms.together.Together.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.