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