Skip to content

ChatSession

Namespace: LLama

The main chat session class.

public class ChatSession

Inheritance ObjectChatSession

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

ILLamaExecutor

History

The chat history for this session.

public ChatHistory History { get; }

Property Value

ChatHistory

HistoryTransform

The history transform used in this session.

public IHistoryTransform HistoryTransform { get; set; }

Property Value

IHistoryTransform

InputTransformPipeline

The input transform pipeline used in this session.

public List<ITextTransform> InputTransformPipeline { get; set; }

Property Value

List<ITextTransform>

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

ChatSession

AddInputTransform(ITextTransform)

Add a text transform to the input transform pipeline.

public ChatSession AddInputTransform(ITextTransform transform)

Parameters

transform ITextTransform

Returns

ChatSession

WithOutputTransform(ITextStreamTransform)

Use a custom output transform.

public ChatSession WithOutputTransform(ITextStreamTransform transform)

Parameters

transform ITextStreamTransform

Returns

ChatSession

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

IEnumerable<String>

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

IEnumerable<String>

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

IAsyncEnumerable<String>

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

Returns

IAsyncEnumerable<String>