You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

llama.sessionstate.md 4.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. # SessionState
  2. Namespace: LLama
  3. The state of a chat session in-memory.
  4. ```csharp
  5. public class SessionState : System.IEquatable`1[[LLama.SessionState, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]
  6. ```
  7. Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [SessionState](./llama.sessionstate.md)<br>
  8. Implements [IEquatable&lt;SessionState&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1)
  9. ## Properties
  10. ### **ExecutorState**
  11. Saved executor state for the session in JSON format.
  12. ```csharp
  13. public ExecutorBaseState ExecutorState { get; set; }
  14. ```
  15. #### Property Value
  16. [ExecutorBaseState](./llama.statefulexecutorbase.executorbasestate.md)<br>
  17. ### **ContextState**
  18. Saved context state (KV cache) for the session.
  19. ```csharp
  20. public State ContextState { get; set; }
  21. ```
  22. #### Property Value
  23. [State](./llama.llamacontext.state.md)<br>
  24. ### **InputTransformPipeline**
  25. The input transform pipeline used in this session.
  26. ```csharp
  27. public ITextTransform[] InputTransformPipeline { get; set; }
  28. ```
  29. #### Property Value
  30. [ITextTransform[]](./llama.abstractions.itexttransform.md)<br>
  31. ### **OutputTransform**
  32. The output transform used in this session.
  33. ```csharp
  34. public ITextStreamTransform OutputTransform { get; set; }
  35. ```
  36. #### Property Value
  37. [ITextStreamTransform](./llama.abstractions.itextstreamtransform.md)<br>
  38. ### **HistoryTransform**
  39. The history transform used in this session.
  40. ```csharp
  41. public IHistoryTransform HistoryTransform { get; set; }
  42. ```
  43. #### Property Value
  44. [IHistoryTransform](./llama.abstractions.ihistorytransform.md)<br>
  45. ### **History**
  46. The the chat history messages for this session.
  47. ```csharp
  48. public Message[] History { get; set; }
  49. ```
  50. #### Property Value
  51. [Message[]](./llama.common.chathistory.message.md)<br>
  52. ## Constructors
  53. ### **SessionState(State, ExecutorBaseState, ChatHistory, List&lt;ITextTransform&gt;, ITextStreamTransform, IHistoryTransform)**
  54. Create a new session state.
  55. ```csharp
  56. public SessionState(State contextState, ExecutorBaseState executorState, ChatHistory history, List<ITextTransform> inputTransformPipeline, ITextStreamTransform outputTransform, IHistoryTransform historyTransform)
  57. ```
  58. #### Parameters
  59. `contextState` [State](./llama.llamacontext.state.md)<br>
  60. `executorState` [ExecutorBaseState](./llama.statefulexecutorbase.executorbasestate.md)<br>
  61. `history` [ChatHistory](./llama.common.chathistory.md)<br>
  62. `inputTransformPipeline` [List&lt;ITextTransform&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)<br>
  63. `outputTransform` [ITextStreamTransform](./llama.abstractions.itextstreamtransform.md)<br>
  64. `historyTransform` [IHistoryTransform](./llama.abstractions.ihistorytransform.md)<br>
  65. ## Methods
  66. ### **Save(String)**
  67. Save the session state to folder.
  68. ```csharp
  69. public void Save(string path)
  70. ```
  71. #### Parameters
  72. `path` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  73. ### **Load(String)**
  74. Load the session state from folder.
  75. ```csharp
  76. public static SessionState Load(string path)
  77. ```
  78. #### Parameters
  79. `path` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  80. #### Returns
  81. [SessionState](./llama.sessionstate.md)<br>
  82. #### Exceptions
  83. [ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)<br>
  84. Throws when session state is incorrect
  85. ### **ToString()**
  86. ```csharp
  87. public string ToString()
  88. ```
  89. #### Returns
  90. [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
  91. ### **PrintMembers(StringBuilder)**
  92. ```csharp
  93. protected bool PrintMembers(StringBuilder builder)
  94. ```
  95. #### Parameters
  96. `builder` [StringBuilder](https://docs.microsoft.com/en-us/dotnet/api/system.text.stringbuilder)<br>
  97. #### Returns
  98. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  99. ### **GetHashCode()**
  100. ```csharp
  101. public int GetHashCode()
  102. ```
  103. #### Returns
  104. [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)<br>
  105. ### **Equals(Object)**
  106. ```csharp
  107. public bool Equals(object obj)
  108. ```
  109. #### Parameters
  110. `obj` [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object)<br>
  111. #### Returns
  112. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  113. ### **Equals(SessionState)**
  114. ```csharp
  115. public bool Equals(SessionState other)
  116. ```
  117. #### Parameters
  118. `other` [SessionState](./llama.sessionstate.md)<br>
  119. #### Returns
  120. [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)<br>
  121. ### **&lt;Clone&gt;$()**
  122. ```csharp
  123. public SessionState <Clone>$()
  124. ```
  125. #### Returns
  126. [SessionState](./llama.sessionstate.md)<br>