5.7 KiB
ChatSession
Namespace: LLama
The main chat session class.
public class ChatSession
Inheritance Object → ChatSession
Fields
OutputTransform
The output transform used in this session.
public ITextStreamTransform OutputTransform;
Properties
Executor
The executor for this session.
public ILLamaExecutor Executor { get; }
Property Value
History
The chat history for this session.
public ChatHistory History { get; }
Property Value
HistoryTransform
The history transform used in this session.
public IHistoryTransform HistoryTransform { get; set; }
Property Value
InputTransformPipeline
The input transform pipeline used in this session.
public List<ITextTransform> InputTransformPipeline { get; set; }
Property Value
Constructors
ChatSession(ILLamaExecutor)
public ChatSession(ILLamaExecutor executor)
Parameters
executor
ILLamaExecutor
The executor for this session
Methods
WithHistoryTransform(IHistoryTransform)
Use a custom history transform.
public ChatSession WithHistoryTransform(IHistoryTransform transform)
Parameters
transform
IHistoryTransform
Returns
AddInputTransform(ITextTransform)
Add a text transform to the input transform pipeline.
public ChatSession AddInputTransform(ITextTransform transform)
Parameters
transform
ITextTransform
Returns
WithOutputTransform(ITextStreamTransform)
Use a custom output transform.
public ChatSession WithOutputTransform(ITextStreamTransform transform)
Parameters
transform
ITextStreamTransform
Returns
SaveSession(String)
public void SaveSession(string path)
Parameters
path
String
The directory name to save the session. If the directory does not exist, a new directory will be created.
LoadSession(String)
public void LoadSession(string path)
Parameters
path
String
The directory name to load the session.
Chat(ChatHistory, IInferenceParams, CancellationToken)
Get the response from the LLama model with chat histories.
public IEnumerable<string> Chat(ChatHistory history, IInferenceParams inferenceParams, CancellationToken cancellationToken)
Parameters
history
ChatHistory
inferenceParams
IInferenceParams
cancellationToken
CancellationToken
Returns
Chat(String, IInferenceParams, CancellationToken)
Get the response from the LLama model. Note that prompt could not only be the preset words, but also the question you want to ask.
public IEnumerable<string> Chat(string prompt, IInferenceParams inferenceParams, CancellationToken cancellationToken)
Parameters
prompt
String
inferenceParams
IInferenceParams
cancellationToken
CancellationToken
Returns
ChatAsync(ChatHistory, IInferenceParams, CancellationToken)
Get the response from the LLama model with chat histories.
public IAsyncEnumerable<string> ChatAsync(ChatHistory history, IInferenceParams inferenceParams, CancellationToken cancellationToken)
Parameters
history
ChatHistory
inferenceParams
IInferenceParams
cancellationToken
CancellationToken
Returns
ChatAsync(String, IInferenceParams, CancellationToken)
Get the response from the LLama model with chat histories asynchronously.
public IAsyncEnumerable<string> ChatAsync(string prompt, IInferenceParams inferenceParams, CancellationToken cancellationToken)
Parameters
prompt
String
inferenceParams
IInferenceParams
cancellationToken
CancellationToken