# ChatSession Namespace: LLama The main chat session class. ```csharp public class ChatSession ``` Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ChatSession](./llama.chatsession.md) ## Fields ### **OutputTransform** The output transform used in this session. ```csharp public ITextStreamTransform OutputTransform; ``` ## Properties ### **Executor** The executor for this session. ```csharp public ILLamaExecutor Executor { get; } ``` #### Property Value [ILLamaExecutor](./llama.abstractions.illamaexecutor.md)
### **History** The chat history for this session. ```csharp public ChatHistory History { get; } ``` #### Property Value [ChatHistory](./llama.common.chathistory.md)
### **HistoryTransform** The history transform used in this session. ```csharp public IHistoryTransform HistoryTransform { get; set; } ``` #### Property Value [IHistoryTransform](./llama.abstractions.ihistorytransform.md)
### **InputTransformPipeline** The input transform pipeline used in this session. ```csharp public List InputTransformPipeline { get; set; } ``` #### Property Value [List<ITextTransform>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
## Constructors ### **ChatSession(ILLamaExecutor)** ```csharp public ChatSession(ILLamaExecutor executor) ``` #### Parameters `executor` [ILLamaExecutor](./llama.abstractions.illamaexecutor.md)
The executor for this session ## Methods ### **WithHistoryTransform(IHistoryTransform)** Use a custom history transform. ```csharp public ChatSession WithHistoryTransform(IHistoryTransform transform) ``` #### Parameters `transform` [IHistoryTransform](./llama.abstractions.ihistorytransform.md)
#### Returns [ChatSession](./llama.chatsession.md)
### **AddInputTransform(ITextTransform)** Add a text transform to the input transform pipeline. ```csharp public ChatSession AddInputTransform(ITextTransform transform) ``` #### Parameters `transform` [ITextTransform](./llama.abstractions.itexttransform.md)
#### Returns [ChatSession](./llama.chatsession.md)
### **WithOutputTransform(ITextStreamTransform)** Use a custom output transform. ```csharp public ChatSession WithOutputTransform(ITextStreamTransform transform) ``` #### Parameters `transform` [ITextStreamTransform](./llama.abstractions.itextstreamtransform.md)
#### Returns [ChatSession](./llama.chatsession.md)
### **SaveSession(String)** ```csharp public void SaveSession(string path) ``` #### Parameters `path` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
The directory name to save the session. If the directory does not exist, a new directory will be created. ### **LoadSession(String)** ```csharp public void LoadSession(string path) ``` #### Parameters `path` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
The directory name to load the session. ### **Chat(ChatHistory, IInferenceParams, CancellationToken)** Get the response from the LLama model with chat histories. ```csharp public IEnumerable Chat(ChatHistory history, IInferenceParams inferenceParams, CancellationToken cancellationToken) ``` #### Parameters `history` [ChatHistory](./llama.common.chathistory.md)
`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns [IEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
### **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. ```csharp public IEnumerable Chat(string prompt, IInferenceParams inferenceParams, CancellationToken cancellationToken) ``` #### Parameters `prompt` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns [IEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
### **ChatAsync(ChatHistory, IInferenceParams, CancellationToken)** Get the response from the LLama model with chat histories. ```csharp public IAsyncEnumerable ChatAsync(ChatHistory history, IInferenceParams inferenceParams, CancellationToken cancellationToken) ``` #### Parameters `history` [ChatHistory](./llama.common.chathistory.md)
`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns [IAsyncEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
### **ChatAsync(String, IInferenceParams, CancellationToken)** Get the response from the LLama model with chat histories asynchronously. ```csharp public IAsyncEnumerable ChatAsync(string prompt, IInferenceParams inferenceParams, CancellationToken cancellationToken) ``` #### Parameters `prompt` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns [IAsyncEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)