ChatSession
Namespace: LLama
The main chat session class.
1 |
|
Inheritance Object → ChatSession
Fields
OutputTransform
The output transform used in this session.
1 |
|
MODEL_STATE_FILENAME
The filename for the serialized model state (KV cache, etc).
1 |
|
EXECUTOR_STATE_FILENAME
The filename for the serialized executor state.
1 |
|
HISTORY_STATE_FILENAME
The filename for the serialized chat history.
1 |
|
INPUT_TRANSFORM_FILENAME
The filename for the serialized input transform pipeline.
1 |
|
OUTPUT_TRANSFORM_FILENAME
The filename for the serialized output transform.
1 |
|
HISTORY_TRANSFORM_FILENAME
The filename for the serialized history transform.
1 |
|
Properties
Executor
The executor for this session.
1 |
|
Property Value
History
The chat history for this session.
1 |
|
Property Value
HistoryTransform
The history transform used in this session.
1 |
|
Property Value
InputTransformPipeline
The input transform pipeline used in this session.
1 |
|
Property Value
Constructors
ChatSession(ILLamaExecutor)
Create a new chat session.
1 |
|
Parameters
executor
ILLamaExecutor
The executor for this session
ChatSession(ILLamaExecutor, ChatHistory)
Create a new chat session with a custom history.
1 |
|
Parameters
executor
ILLamaExecutor
history
ChatHistory
Methods
InitializeSessionFromHistoryAsync(ILLamaExecutor, ChatHistory)
Create a new chat session and preprocess history.
1 |
|
Parameters
executor
ILLamaExecutor
The executor for this session
history
ChatHistory
History for this session
Returns
WithHistoryTransform(IHistoryTransform)
Use a custom history transform.
1 |
|
Parameters
transform
IHistoryTransform
Returns
AddInputTransform(ITextTransform)
Add a text transform to the input transform pipeline.
1 |
|
Parameters
transform
ITextTransform
Returns
WithOutputTransform(ITextStreamTransform)
Use a custom output transform.
1 |
|
Parameters
transform
ITextStreamTransform
Returns
SaveSession(String)
Save a session from a directory.
1 |
|
Parameters
path
String
Exceptions
GetSessionState()
Get the session state.
1 |
|
Returns
SessionState
SessionState object representing session state in-memory
LoadSession(SessionState, Boolean)
Load a session from a session state.
1 |
|
Parameters
state
SessionState
loadTransforms
Boolean
If true loads transforms saved in the session state.
Exceptions
LoadSession(String, Boolean)
Load a session from a directory.
1 |
|
Parameters
path
String
loadTransforms
Boolean
If true loads transforms saved in the session state.
Exceptions
AddMessage(Message)
Add a message to the chat history.
1 |
|
Parameters
message
Message
Returns
AddSystemMessage(String)
Add a system message to the chat history.
1 |
|
Parameters
content
String
Returns
AddAssistantMessage(String)
Add an assistant message to the chat history.
1 |
|
Parameters
content
String
Returns
AddUserMessage(String)
Add a user message to the chat history.
1 |
|
Parameters
content
String
Returns
RemoveLastMessage()
Remove the last message from the chat history.
1 |
|
Returns
AddAndProcessMessage(Message)
Compute KV cache for the message and add it to the chat history.
1 |
|
Parameters
message
Message
Returns
AddAndProcessSystemMessage(String)
Compute KV cache for the system message and add it to the chat history.
1 |
|
Parameters
content
String
Returns
AddAndProcessUserMessage(String)
Compute KV cache for the user message and add it to the chat history.
1 |
|
Parameters
content
String
Returns
AddAndProcessAssistantMessage(String)
Compute KV cache for the assistant message and add it to the chat history.
1 |
|
Parameters
content
String
Returns
ReplaceUserMessage(Message, Message)
Replace a user message with a new message and remove all messages after the new message. This is useful when the user wants to edit a message. And regenerate the response.
1 |
|
Parameters
oldMessage
Message
newMessage
Message
Returns
ChatAsync(Message, Boolean, IInferenceParams, CancellationToken)
Chat with the model.
1 |
|
Parameters
message
Message
applyInputTransformPipeline
Boolean
inferenceParams
IInferenceParams
cancellationToken
CancellationToken
Returns
Exceptions
ChatAsync(Message, IInferenceParams, CancellationToken)
Chat with the model.
1 |
|
Parameters
message
Message
inferenceParams
IInferenceParams
cancellationToken
CancellationToken
Returns
ChatAsync(ChatHistory, Boolean, IInferenceParams, CancellationToken)
Chat with the model.
1 |
|
Parameters
history
ChatHistory
applyInputTransformPipeline
Boolean
inferenceParams
IInferenceParams
cancellationToken
CancellationToken
Returns
Exceptions
ChatAsync(ChatHistory, IInferenceParams, CancellationToken)
Chat with the model.
1 |
|
Parameters
history
ChatHistory
inferenceParams
IInferenceParams
cancellationToken
CancellationToken
Returns
RegenerateAssistantMessageAsync(InferenceParams, CancellationToken)
Regenerate the last assistant message.
1 |
|
Parameters
inferenceParams
InferenceParams
cancellationToken
CancellationToken