Class WMLLM
LLM model class. Contains all properties needed to create and interface with an LLM
Implements
Inherited Members
Namespace: Quantellia.WMServer.Asset.LLM
Assembly: WMServer.dll
Syntax
public class WMLLM : WMAssetBase, IWMAsset, IDbEntity, IWMEntity, IDocumentedEntity, INamedEntity, IWMAssetDirectoryMember, IWMPrincipalOwned, IHasEncryptedValues
Constructors
WMLLM()
Default constructor
Declaration
public WMLLM()
WMLLM(string)
Constructor that initializes the ID
Declaration
public WMLLM(string id)
Parameters
Type | Name | Description |
---|---|---|
string | id |
Properties
APIKey
The API Key granting the user access to this LLM.
Declaration
public string APIKey { get; set; }
Property Value
Type | Description |
---|---|
string |
EncryptionPlaceholder
Standard string to replace encrypted values with when not returning plain-text values.
Declaration
[NotMapped]
public string EncryptionPlaceholder { get; set; }
Property Value
Type | Description |
---|---|
string |
LLM
The LLM provider
Declaration
public ILLM LLM { get; set; }
Property Value
Type | Description |
---|---|
ILLM |
LLMType
The type of LLM in use (i.e. ChatGPT, Gemini, etc...)
Declaration
public string LLMType { get; set; }
Property Value
Type | Description |
---|---|
string |
MaxRecords
The maximum number of records to return in VectorDB queries.
Declaration
public int MaxRecords { get; set; }
Property Value
Type | Description |
---|---|
int |
MaxTokens
The MaxTokens parameter of the model.
Declaration
public int? MaxTokens { get; set; }
Property Value
Type | Description |
---|---|
int? |
ModelName
The name of the model in use.
Declaration
public string? ModelName { get; set; }
Property Value
Type | Description |
---|---|
string |
Overlap
The maximum number of messages to include when calculating the context vector for RAG
Declaration
public int Overlap { get; set; }
Property Value
Type | Description |
---|---|
int |
Prompt
The system prompt determining the behavior of this LLM.
Declaration
public string Prompt { get; set; }
Property Value
Type | Description |
---|---|
string |
Temperature
The temperature parameter of the model.
Declaration
public float? Temperature { get; set; }
Property Value
Type | Description |
---|---|
float? |
Threshold
The minimum similarity required for RAG to be used.
Declaration
public float Threshold { get; set; }
Property Value
Type | Description |
---|---|
float |
Tools
The Tools used by the model. Note, Tools refers to a method with a description made available to the model. If a Tool "GetTimeZone()" has description "Returns the timezone of the user" and the LLM determines that it needs the user's timezone to answer a question, it will request the execution of "GetTimeZone()", and format its answer based on the return value.
Declaration
public string? Tools { get; set; }
Property Value
Type | Description |
---|---|
string |
VectorDB
Responsible for document indexing
Declaration
public IVectorDB VectorDB { get; set; }
Property Value
Type | Description |
---|---|
IVectorDB |
VectorIndexType
The type of VectorIndex in use. (i.e. WMNativeVectorIndex, PineconeVectorIndex, etc...)
Declaration
public string VectorIndexType { get; set; }
Property Value
Type | Description |
---|---|
string |
WindowSize
The maximum characters to include in each window when calculating embeddings.
Declaration
public int WindowSize { get; set; }
Property Value
Type | Description |
---|---|
int |
Methods
EndConversation(WMPrincipal, string, WMAppDbContext)
Ends the conversation with the given ID
Declaration
public static Task EndConversation(WMPrincipal principal, string ConversationID, WMAppDbContext context)
Parameters
Type | Name | Description |
---|---|---|
WMPrincipal | principal | |
string | ConversationID | The ID of the conversation to end |
WMAppDbContext | context |
Returns
Type | Description |
---|---|
Task |
Insert(WMPrincipal, string, string, WMAppDbContext)
Inserts the text from a WMDocument to the vectorDB.
Declaration
public Task Insert(WMPrincipal principal, string documentIndexDir, string documentDir, WMAppDbContext context)
Parameters
Type | Name | Description |
---|---|---|
WMPrincipal | principal | |
string | documentIndexDir | The Dir or ID of the vector DB. |
string | documentDir | The ID/Dir of the document to insert. |
WMAppDbContext | context |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
Exception |
Query(WMPrincipal, string, string, WMAppDbContext)
Converts a message to an embedding, and searches the LLM's vectorDB for similar text.
Declaration
public static Task<IEnumerable<string>> Query(WMPrincipal principal, string dir, string message, WMAppDbContext context)
Parameters
Type | Name | Description |
---|---|---|
WMPrincipal | principal | |
string | dir | The directory or ID of the LLM to query under. |
string | message | The message to query |
WMAppDbContext | context |
Returns
Type | Description |
---|---|
Task<IEnumerable<string>> |
Remove(WMPrincipal, string, string, WMAppDbContext)
Inserts the text from a WMDocument from the vectorDB.
Declaration
public Task Remove(WMPrincipal principal, string documentIndexDir, string documentDir, WMAppDbContext context)
Parameters
Type | Name | Description |
---|---|---|
WMPrincipal | principal | |
string | documentIndexDir | The Dir or ID of the vector DB. |
string | documentDir | The ID/Dir of the document to remove. |
WMAppDbContext | context |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
Exception |
StreamConversation(WMPrincipal, ConversationArgs, WMAppDbContext)
Creates or continues a conversation with the LLM provider. Streams the responses directly to the receiver as they arrive.
Declaration
public static IAsyncEnumerable<ILLMConversation.Response> StreamConversation(WMPrincipal principal, ConversationArgs args, WMAppDbContext context)
Parameters
Type | Name | Description |
---|---|---|
WMPrincipal | principal | |
ConversationArgs | args | The arguments of the conversation |
WMAppDbContext | context |
Returns
Type | Description |
---|---|
IAsyncEnumerable<ILLMConversation.Response> |
StreamConversationAtOnce(WMPrincipal, ConversationArgs, WMAppDbContext)
A version of StreamConversation(WMPrincipal, ConversationArgs, WMAppDbContext)> that streams and consolidates the entire message before returning the result.
Declaration
public static Task<ILLMConversation.Response> StreamConversationAtOnce(WMPrincipal principal, ConversationArgs args, WMAppDbContext context)
Parameters
Type | Name | Description |
---|---|---|
WMPrincipal | principal | |
ConversationArgs | args | The arguments of the conversation |
WMAppDbContext | context |
Returns
Type | Description |
---|---|
Task<ILLMConversation.Response> |