mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-16 14:53:48 +00:00
Added embedding information
This commit is contained in:
6 files changed
+373
No files matched your search
@@ -146,6 +146,57 @@
|
||||
}
|
||||
</MudSelect>
|
||||
|
||||
<MudText Typo="Typo.h4" Class="mt-6 mb-3">
|
||||
Embedding settings
|
||||
</MudText>
|
||||
|
||||
<MudText Typo="Typo.body1" Class="mb-2">
|
||||
You will likely use one or more embedding methods to encode the meaning of your data into a typically high-dimensional vector
|
||||
space. In this case, you will use a vector database to store and search these vectors (called embeddings). However, you don't
|
||||
have to use embedding methods. When your retrieval method works without any embedding, you can ignore this section. An example: You
|
||||
store files on a file server, and your retrieval method works exclusively with file names in the file system, so you don't
|
||||
need embeddings.
|
||||
</MudText>
|
||||
|
||||
<MudText Typo="Typo.body1" Class="mb-3">
|
||||
You can specify more than one embedding method. This can be useful when you want to use different embeddings for different queries
|
||||
or data types. For example, one embedding for texts, another for images, and a third for videos, etc.
|
||||
</MudText>
|
||||
|
||||
<MudTable Items="@this.embeddings" Hover="@true" Class="border-dashed border rounded-lg">
|
||||
<ColGroup>
|
||||
<col/>
|
||||
<col style="width: 34em;"/>
|
||||
<col style="width: 34em;"/>
|
||||
</ColGroup>
|
||||
<HeaderContent>
|
||||
<MudTh>Name</MudTh>
|
||||
<MudTh>Type</MudTh>
|
||||
<MudTh Style="text-align: left;">Actions</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd>@context.EmbeddingName</MudTd>
|
||||
<MudTd>@context.EmbeddingType</MudTd>
|
||||
<MudTd Style="text-align: left;">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Edit" Class="ma-2" OnClick="() => this.EditEmbedding(context)">
|
||||
Edit
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.Delete" Class="ma-2" OnClick="() => this.DeleteEmbedding(context)">
|
||||
Delete
|
||||
</MudButton>
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
|
||||
@if(this.embeddings.Count == 0)
|
||||
{
|
||||
<MudText Typo="Typo.h6" Class="mt-3">No embeddings configured yet.</MudText>
|
||||
}
|
||||
|
||||
<MudButton Variant="Variant.Filled" Color="@Color.Primary" StartIcon="@Icons.Material.Filled.AddRoad" Class="mt-3 mb-6" OnClick="@this.AddEmbedding">
|
||||
Add Embedding
|
||||
</MudButton>
|
||||
|
||||
<MudText Typo="Typo.h4" Class="mt-6 mb-1">
|
||||
Data retrieval settings
|
||||
</MudText>
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using AIStudio.Chat;
|
||||
using AIStudio.Dialogs;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
using DialogOptions = AIStudio.Dialogs.DialogOptions;
|
||||
|
||||
namespace AIStudio.Assistants.ERI;
|
||||
|
||||
public partial class AssistantERI : AssistantBaseCore
|
||||
@@ -9,6 +12,9 @@ public partial class AssistantERI : AssistantBaseCore
|
||||
[Inject]
|
||||
private HttpClient HttpClient { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
private IDialogService DialogService { get; init; } = null!;
|
||||
|
||||
public override Tools.Components Component => Tools.Components.ERI_ASSISTANT;
|
||||
|
||||
protected override string Title => "ERI Server";
|
||||
@@ -56,6 +62,7 @@ public partial class AssistantERI : AssistantBaseCore
|
||||
this.authDescription = string.Empty;
|
||||
this.selectedOperatingSystem = OperatingSystem.NONE;
|
||||
this.allowedLLMProviders = AllowedLLMProviders.NONE;
|
||||
this.embeddings = new();
|
||||
this.retrievalDescription = string.Empty;
|
||||
this.additionalLibraries = string.Empty;
|
||||
}
|
||||
@@ -83,6 +90,7 @@ public partial class AssistantERI : AssistantBaseCore
|
||||
this.authDescription = this.SettingsManager.ConfigurationData.ERI.PreselectedAuthDescription;
|
||||
this.selectedOperatingSystem = this.SettingsManager.ConfigurationData.ERI.PreselectedOperatingSystem;
|
||||
this.allowedLLMProviders = this.SettingsManager.ConfigurationData.ERI.PreselectedAllowedLLMProviders;
|
||||
this.embeddings = this.SettingsManager.ConfigurationData.ERI.EmbeddingInfos;
|
||||
this.retrievalDescription = this.SettingsManager.ConfigurationData.ERI.PreselectedRetrievalDescription;
|
||||
this.additionalLibraries = this.SettingsManager.ConfigurationData.ERI.PreselectedAdditionalLibraries;
|
||||
return true;
|
||||
@@ -115,6 +123,7 @@ public partial class AssistantERI : AssistantBaseCore
|
||||
this.SettingsManager.ConfigurationData.ERI.PreselectedAuthDescription = this.authDescription;
|
||||
this.SettingsManager.ConfigurationData.ERI.PreselectedOperatingSystem = this.selectedOperatingSystem;
|
||||
this.SettingsManager.ConfigurationData.ERI.PreselectedAllowedLLMProviders = this.allowedLLMProviders;
|
||||
this.SettingsManager.ConfigurationData.ERI.EmbeddingInfos = this.embeddings;
|
||||
this.SettingsManager.ConfigurationData.ERI.PreselectedRetrievalDescription = this.retrievalDescription;
|
||||
this.SettingsManager.ConfigurationData.ERI.PreselectedAdditionalLibraries = this.additionalLibraries;
|
||||
await this.SettingsManager.StoreSettings();
|
||||
@@ -135,6 +144,7 @@ public partial class AssistantERI : AssistantBaseCore
|
||||
private string authDescription = string.Empty;
|
||||
private OperatingSystem selectedOperatingSystem = OperatingSystem.NONE;
|
||||
private AllowedLLMProviders allowedLLMProviders = AllowedLLMProviders.NONE;
|
||||
private List<EmbeddingInfo> embeddings = new();
|
||||
private string retrievalDescription = string.Empty;
|
||||
private string additionalLibraries = string.Empty;
|
||||
|
||||
@@ -389,6 +399,62 @@ public partial class AssistantERI : AssistantBaseCore
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task AddEmbedding()
|
||||
{
|
||||
var dialogParameters = new DialogParameters<EmbeddingMethodDialog>
|
||||
{
|
||||
{ x => x.IsEditing, false },
|
||||
};
|
||||
|
||||
var dialogReference = await this.DialogService.ShowAsync<EmbeddingMethodDialog>("Add Embedding", dialogParameters, DialogOptions.FULLSCREEN);
|
||||
var dialogResult = await dialogReference.Result;
|
||||
if (dialogResult is null || dialogResult.Canceled)
|
||||
return;
|
||||
|
||||
var addedEmbedding = (EmbeddingInfo)dialogResult.Data!;
|
||||
this.embeddings.Add(addedEmbedding);
|
||||
await this.AutoSave();
|
||||
}
|
||||
|
||||
private async Task EditEmbedding(EmbeddingInfo embeddingInfo)
|
||||
{
|
||||
var dialogParameters = new DialogParameters<EmbeddingMethodDialog>
|
||||
{
|
||||
{ x => x.DataEmbeddingName, embeddingInfo.EmbeddingName },
|
||||
{ x => x.DataEmbeddingType, embeddingInfo.EmbeddingType },
|
||||
{ x => x.DataDescription, embeddingInfo.Description },
|
||||
{ x => x.DataUsedWhen, embeddingInfo.UsedWhen },
|
||||
{ x => x.DataLink, embeddingInfo.Link },
|
||||
{ x => x.IsEditing, true },
|
||||
};
|
||||
|
||||
var dialogReference = await this.DialogService.ShowAsync<EmbeddingMethodDialog>("Edit Embedding", dialogParameters, DialogOptions.FULLSCREEN);
|
||||
var dialogResult = await dialogReference.Result;
|
||||
if (dialogResult is null || dialogResult.Canceled)
|
||||
return;
|
||||
|
||||
var editedEmbedding = (EmbeddingInfo)dialogResult.Data!;
|
||||
|
||||
this.embeddings[this.embeddings.IndexOf(embeddingInfo)] = editedEmbedding;
|
||||
await this.AutoSave();
|
||||
}
|
||||
|
||||
private async Task DeleteEmbedding(EmbeddingInfo embeddingInfo)
|
||||
{
|
||||
var dialogParameters = new DialogParameters
|
||||
{
|
||||
{ "Message", $"Are you sure you want to delete the embedding '{embeddingInfo.EmbeddingName}'?" },
|
||||
};
|
||||
|
||||
var dialogReference = await this.DialogService.ShowAsync<ConfirmDialog>("Delete Embedding", dialogParameters, DialogOptions.FULLSCREEN);
|
||||
var dialogResult = await dialogReference.Result;
|
||||
if (dialogResult is null || dialogResult.Canceled)
|
||||
return;
|
||||
|
||||
this.embeddings.Remove(embeddingInfo);
|
||||
await this.AutoSave();
|
||||
}
|
||||
|
||||
private async Task GenerateServer()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace AIStudio.Assistants.ERI;
|
||||
|
||||
/// <summary>
|
||||
/// Represents information about the used embedding for a data source.
|
||||
/// </summary>
|
||||
/// <param name="EmbeddingType">What kind of embedding is used. For example, "Transformer Embedding," "Contextual Word
|
||||
/// Embedding," "Graph Embedding," etc.</param>
|
||||
/// <param name="EmbeddingName">Name the embedding used. This can be a library, a framework, or the name of the used
|
||||
/// algorithm.</param>
|
||||
/// <param name="Description">A short description of the embedding. Describe what the embedding is doing.</param>
|
||||
/// <param name="UsedWhen">Describe when the embedding is used. For example, when the user prompt contains certain
|
||||
/// keywords, or anytime?</param>
|
||||
/// <param name="Link">A link to the embedding's documentation or the source code. Might be null.</param>
|
||||
public readonly record struct EmbeddingInfo(
|
||||
string EmbeddingType,
|
||||
string EmbeddingName,
|
||||
string Description,
|
||||
string UsedWhen,
|
||||
string? Link);
|
||||
Reference in new issue
Block a user