LLM Module¶
pipelines.pipelines.nodes.llm.chatglm ¶
ChatGLMBot ¶
Source code in pipelines/pipelines/nodes/llm/chatglm.py
__init__ ¶
__init__(model_name_or_path='THUDM/chatglm-6b-v1.1', batch_size: int = 2, max_seq_length: int = 2048, tgt_length: int = 2048, **kwargs)
Initialize the ChatGLMBot instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_size |
int
|
batch_size for chatglm prediction. |
2
|
max_seq_length |
int
|
max_seq_length for the processing input. |
2048
|
tgt_length |
int
|
tgt_length for models output |
2048
|
Source code in pipelines/pipelines/nodes/llm/chatglm.py
run ¶
Using the chatbot to generate the answers
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query |
The user's input/query to be sent to the chatGLM. |
required | |
stream |
Whether to use streaming mode when making the request. Currently not in use. Defaults to False. |
False
|
Source code in pipelines/pipelines/nodes/llm/chatglm.py
pipelines.pipelines.nodes.llm.ernie_bot ¶
ErnieBot ¶
The ErnieBot class is a subclass of the BaseComponent class, which is designed to interface with the Ernie Bot API for generating AI chatbot responses. It handles the interaction with the API using the provided api_key, secret_key . It allows you to make a request with a given query and optional conversation history, receiving a response from the chatbot and extending the conversation history accordingly.
Source code in pipelines/pipelines/nodes/llm/ernie_bot.py
__init__ ¶
Initialize the ErnieBot instance with the provided api_key and secret_key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key |
api_key for applying token to request wenxin api. |
None
|
|
secret_key |
secret_key for applying token to request wenxin api. |
None
|
Source code in pipelines/pipelines/nodes/llm/ernie_bot.py
run ¶
Send a request to the Ernie Bot API with the given query and optional conversation history. Returns the chatbot response and updates the conversation history accordingly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query |
The user's input/query to be sent to the Ernie Bot API. |
required | |
history |
A list of dictionaries representing the conversation history, |
None
|
|
stream |
Whether to use streaming mode when making the request. Currently not in use. Defaults to False. |
False
|
Source code in pipelines/pipelines/nodes/llm/ernie_bot.py
pipelines.pipelines.nodes.llm.history ¶
TruncatedConversationHistory ¶
This class represents a component that truncates conversation history to a specified maximum length.
Source code in pipelines/pipelines/nodes/llm/history.py
__init__ ¶
Initializes the TruncatedConversationHistory class with the specified maximum length.
run ¶
Truncates the conversation history to the maximum allowed length, then returns the modified history along with the query.