mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-02-05 10:49:07 +00:00
Improved profile and system prompt handling (#241)
This commit is contained in:
parent
caec3bfd2c
commit
38a45955fb
@ -209,16 +209,12 @@ public abstract partial class AssistantBase : ComponentBase, IMessageBusReceiver
|
|||||||
this.chatThread = new()
|
this.chatThread = new()
|
||||||
{
|
{
|
||||||
SelectedProvider = this.providerSettings.Id,
|
SelectedProvider = this.providerSettings.Id,
|
||||||
|
SelectedProfile = this.AllowProfiles ? this.currentProfile.Id : Profile.NO_PROFILE.Id,
|
||||||
|
SystemPrompt = this.SystemPrompt,
|
||||||
WorkspaceId = Guid.Empty,
|
WorkspaceId = Guid.Empty,
|
||||||
ChatId = Guid.NewGuid(),
|
ChatId = Guid.NewGuid(),
|
||||||
Name = string.Empty,
|
Name = $"Assistant - {this.Title}",
|
||||||
Seed = this.RNG.Next(),
|
Seed = this.RNG.Next(),
|
||||||
SystemPrompt = !this.AllowProfiles ? this.SystemPrompt :
|
|
||||||
$"""
|
|
||||||
{this.SystemPrompt}
|
|
||||||
|
|
||||||
{this.currentProfile.ToSystemPrompt()}
|
|
||||||
""",
|
|
||||||
Blocks = [],
|
Blocks = [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -229,16 +225,12 @@ public abstract partial class AssistantBase : ComponentBase, IMessageBusReceiver
|
|||||||
this.chatThread = new()
|
this.chatThread = new()
|
||||||
{
|
{
|
||||||
SelectedProvider = this.providerSettings.Id,
|
SelectedProvider = this.providerSettings.Id,
|
||||||
|
SelectedProfile = this.AllowProfiles ? this.currentProfile.Id : Profile.NO_PROFILE.Id,
|
||||||
|
SystemPrompt = this.SystemPrompt,
|
||||||
WorkspaceId = workspaceId,
|
WorkspaceId = workspaceId,
|
||||||
ChatId = chatId,
|
ChatId = chatId,
|
||||||
Name = name,
|
Name = name,
|
||||||
Seed = this.RNG.Next(),
|
Seed = this.RNG.Next(),
|
||||||
SystemPrompt = !this.AllowProfiles ? this.SystemPrompt :
|
|
||||||
$"""
|
|
||||||
{this.SystemPrompt}
|
|
||||||
|
|
||||||
{this.currentProfile.ToSystemPrompt()}
|
|
||||||
""",
|
|
||||||
Blocks = [],
|
Blocks = [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
using AIStudio.Settings;
|
||||||
|
|
||||||
namespace AIStudio.Chat;
|
namespace AIStudio.Chat;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -20,6 +22,11 @@ public sealed record ChatThread
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string SelectedProvider { get; set; } = string.Empty;
|
public string SelectedProvider { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies the profile selected for the chat thread.
|
||||||
|
/// </summary>
|
||||||
|
public string SelectedProfile { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name of the chat thread. Usually generated by an AI model or manually edited by the user.
|
/// The name of the chat thread. Usually generated by an AI model or manually edited by the user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -39,4 +46,55 @@ public sealed record ChatThread
|
|||||||
/// The content blocks of the chat thread.
|
/// The content blocks of the chat thread.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ContentBlock> Blocks { get; init; } = [];
|
public List<ContentBlock> Blocks { get; init; } = [];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Prepares the system prompt for the chat thread.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The actual system prompt depends on the selected profile. If no profile is selected,
|
||||||
|
/// the system prompt is returned as is. When a profile is selected, the system prompt
|
||||||
|
/// is extended with the profile chosen.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="settingsManager">The settings manager instance to use.</param>
|
||||||
|
/// <param name="chatThread">The chat thread to prepare the system prompt for.</param>
|
||||||
|
/// <param name="logger">The logger instance to use.</param>
|
||||||
|
/// <returns>The prepared system prompt.</returns>
|
||||||
|
public string PrepareSystemPrompt(SettingsManager settingsManager, ChatThread chatThread, ILogger logger)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Prepare the system prompt:
|
||||||
|
//
|
||||||
|
string systemPromptText;
|
||||||
|
var logMessage = $"Using no profile for chat thread '{chatThread.Name}'.";
|
||||||
|
if (string.IsNullOrWhiteSpace(chatThread.SelectedProfile))
|
||||||
|
systemPromptText = chatThread.SystemPrompt;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!Guid.TryParse(chatThread.SelectedProfile, out var profileId))
|
||||||
|
systemPromptText = chatThread.SystemPrompt;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(chatThread.SelectedProfile == Profile.NO_PROFILE.Id || profileId == Guid.Empty)
|
||||||
|
systemPromptText = chatThread.SystemPrompt;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var profile = settingsManager.ConfigurationData.Profiles.FirstOrDefault(x => x.Id == chatThread.SelectedProfile);
|
||||||
|
if(profile == default)
|
||||||
|
systemPromptText = chatThread.SystemPrompt;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logMessage = $"Using profile '{profile.Name}' for chat thread '{chatThread.Name}'.";
|
||||||
|
systemPromptText = $"""
|
||||||
|
{chatThread.SystemPrompt}
|
||||||
|
|
||||||
|
{profile.ToSystemPrompt()}
|
||||||
|
""";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.LogInformation(logMessage);
|
||||||
|
return systemPromptText;
|
||||||
|
}
|
||||||
}
|
}
|
@ -54,7 +54,7 @@ public sealed class ContentText : IContent
|
|||||||
this.InitialRemoteWait = true;
|
this.InitialRemoteWait = true;
|
||||||
|
|
||||||
// Iterate over the responses from the AI:
|
// Iterate over the responses from the AI:
|
||||||
await foreach (var deltaText in provider.StreamChatCompletion(chatModel, chatThread, token))
|
await foreach (var deltaText in provider.StreamChatCompletion(chatModel, chatThread, settings, token))
|
||||||
{
|
{
|
||||||
// When the user cancels the request, we stop the loop:
|
// When the user cancels the request, we stop the loop:
|
||||||
if (token.IsCancellationRequested)
|
if (token.IsCancellationRequested)
|
||||||
|
@ -210,11 +210,7 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
|
|||||||
|
|
||||||
this.ChatThread = this.ChatThread with
|
this.ChatThread = this.ChatThread with
|
||||||
{
|
{
|
||||||
SystemPrompt = $"""
|
SelectedProfile = this.currentProfile.Id,
|
||||||
{SystemPrompts.DEFAULT}
|
|
||||||
|
|
||||||
{this.currentProfile.ToSystemPrompt()}
|
|
||||||
"""
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await this.ChatThreadChanged.InvokeAsync(this.ChatThread);
|
await this.ChatThreadChanged.InvokeAsync(this.ChatThread);
|
||||||
@ -263,15 +259,12 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
|
|||||||
this.ChatThread = new()
|
this.ChatThread = new()
|
||||||
{
|
{
|
||||||
SelectedProvider = this.Provider.Id,
|
SelectedProvider = this.Provider.Id,
|
||||||
|
SelectedProfile = this.currentProfile.Id,
|
||||||
|
SystemPrompt = SystemPrompts.DEFAULT,
|
||||||
WorkspaceId = this.currentWorkspaceId,
|
WorkspaceId = this.currentWorkspaceId,
|
||||||
ChatId = Guid.NewGuid(),
|
ChatId = Guid.NewGuid(),
|
||||||
Name = threadName,
|
Name = threadName,
|
||||||
Seed = this.RNG.Next(),
|
Seed = this.RNG.Next(),
|
||||||
SystemPrompt = $"""
|
|
||||||
{SystemPrompts.DEFAULT}
|
|
||||||
|
|
||||||
{this.currentProfile.ToSystemPrompt()}
|
|
||||||
""",
|
|
||||||
Blocks = [],
|
Blocks = [],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -282,6 +275,10 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
|
|||||||
// Set the thread name if it is empty:
|
// Set the thread name if it is empty:
|
||||||
if (string.IsNullOrWhiteSpace(this.ChatThread.Name))
|
if (string.IsNullOrWhiteSpace(this.ChatThread.Name))
|
||||||
this.ChatThread.Name = threadName;
|
this.ChatThread.Name = threadName;
|
||||||
|
|
||||||
|
// Update provider and profile:
|
||||||
|
this.ChatThread.SelectedProvider = this.Provider.Id;
|
||||||
|
this.ChatThread.SelectedProfile = this.currentProfile.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -443,15 +440,12 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
|
|||||||
this.ChatThread = new()
|
this.ChatThread = new()
|
||||||
{
|
{
|
||||||
SelectedProvider = this.Provider.Id,
|
SelectedProvider = this.Provider.Id,
|
||||||
|
SelectedProfile = this.currentProfile.Id,
|
||||||
|
SystemPrompt = SystemPrompts.DEFAULT,
|
||||||
WorkspaceId = this.currentWorkspaceId,
|
WorkspaceId = this.currentWorkspaceId,
|
||||||
ChatId = Guid.NewGuid(),
|
ChatId = Guid.NewGuid(),
|
||||||
Name = string.Empty,
|
Name = string.Empty,
|
||||||
Seed = this.RNG.Next(),
|
Seed = this.RNG.Next(),
|
||||||
SystemPrompt = $"""
|
|
||||||
{SystemPrompts.DEFAULT}
|
|
||||||
|
|
||||||
{this.currentProfile.ToSystemPrompt()}
|
|
||||||
""",
|
|
||||||
Blocks = [],
|
Blocks = [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -542,6 +536,8 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
|
|||||||
private async Task SelectProviderWhenLoadingChat()
|
private async Task SelectProviderWhenLoadingChat()
|
||||||
{
|
{
|
||||||
var chatProvider = this.ChatThread?.SelectedProvider;
|
var chatProvider = this.ChatThread?.SelectedProvider;
|
||||||
|
var chatProfile = this.ChatThread?.SelectedProfile;
|
||||||
|
|
||||||
switch (this.SettingsManager.ConfigurationData.Chat.LoadingProviderBehavior)
|
switch (this.SettingsManager.ConfigurationData.Chat.LoadingProviderBehavior)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
@ -560,6 +556,14 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
|
|||||||
}
|
}
|
||||||
|
|
||||||
await this.ProviderChanged.InvokeAsync(this.Provider);
|
await this.ProviderChanged.InvokeAsync(this.Provider);
|
||||||
|
|
||||||
|
// Try to select the profile:
|
||||||
|
if (!string.IsNullOrWhiteSpace(chatProfile))
|
||||||
|
{
|
||||||
|
this.currentProfile = this.SettingsManager.ConfigurationData.Profiles.FirstOrDefault(x => x.Id == chatProfile);
|
||||||
|
if(this.currentProfile == default)
|
||||||
|
this.currentProfile = Profile.NO_PROFILE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ToggleWorkspaceOverlay()
|
private async Task ToggleWorkspaceOverlay()
|
||||||
|
@ -4,6 +4,7 @@ using System.Text.Json;
|
|||||||
|
|
||||||
using AIStudio.Chat;
|
using AIStudio.Chat;
|
||||||
using AIStudio.Provider.OpenAI;
|
using AIStudio.Provider.OpenAI;
|
||||||
|
using AIStudio.Settings;
|
||||||
|
|
||||||
namespace AIStudio.Provider.Anthropic;
|
namespace AIStudio.Provider.Anthropic;
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ public sealed class ProviderAnthropic(ILogger logger) : BaseProvider("https://ap
|
|||||||
public override string InstanceName { get; set; } = "Anthropic";
|
public override string InstanceName { get; set; } = "Anthropic";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override async IAsyncEnumerable<string> StreamChatCompletion(Model chatModel, ChatThread chatThread, [EnumeratorCancellation] CancellationToken token = default)
|
public override async IAsyncEnumerable<string> StreamChatCompletion(Model chatModel, ChatThread chatThread, SettingsManager settingsManager, [EnumeratorCancellation] CancellationToken token = default)
|
||||||
{
|
{
|
||||||
// Get the API key:
|
// Get the API key:
|
||||||
var requestedSecret = await RUST_SERVICE.GetAPIKey(this);
|
var requestedSecret = await RUST_SERVICE.GetAPIKey(this);
|
||||||
@ -52,7 +53,7 @@ public sealed class ProviderAnthropic(ILogger logger) : BaseProvider("https://ap
|
|||||||
}
|
}
|
||||||
}).ToList()],
|
}).ToList()],
|
||||||
|
|
||||||
System = chatThread.SystemPrompt,
|
System = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
||||||
MaxTokens = 4_096,
|
MaxTokens = 4_096,
|
||||||
|
|
||||||
// Right now, we only support streaming completions:
|
// Right now, we only support streaming completions:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
using AIStudio.Chat;
|
using AIStudio.Chat;
|
||||||
|
using AIStudio.Settings;
|
||||||
|
|
||||||
using RustService = AIStudio.Tools.RustService;
|
using RustService = AIStudio.Tools.RustService;
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ public abstract class BaseProvider : IProvider, ISecretId
|
|||||||
public abstract string InstanceName { get; set; }
|
public abstract string InstanceName { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public abstract IAsyncEnumerable<string> StreamChatCompletion(Model chatModel, ChatThread chatThread, CancellationToken token = default);
|
public abstract IAsyncEnumerable<string> StreamChatCompletion(Model chatModel, ChatThread chatThread, SettingsManager settingsManager, CancellationToken token = default);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public abstract IAsyncEnumerable<ImageURL> StreamImageCompletion(Model imageModel, string promptPositive, string promptNegative = FilterOperator.String.Empty, ImageURL referenceImageURL = default, CancellationToken token = default);
|
public abstract IAsyncEnumerable<ImageURL> StreamImageCompletion(Model imageModel, string promptPositive, string promptNegative = FilterOperator.String.Empty, ImageURL referenceImageURL = default, CancellationToken token = default);
|
||||||
|
@ -4,6 +4,7 @@ using System.Text;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
using AIStudio.Chat;
|
using AIStudio.Chat;
|
||||||
|
using AIStudio.Settings;
|
||||||
|
|
||||||
namespace AIStudio.Provider.Fireworks;
|
namespace AIStudio.Provider.Fireworks;
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ public class ProviderFireworks(ILogger logger) : BaseProvider("https://api.firew
|
|||||||
public override string InstanceName { get; set; } = "Fireworks.ai";
|
public override string InstanceName { get; set; } = "Fireworks.ai";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override async IAsyncEnumerable<string> StreamChatCompletion(Model chatModel, ChatThread chatThread, [EnumeratorCancellation] CancellationToken token = default)
|
public override async IAsyncEnumerable<string> StreamChatCompletion(Model chatModel, ChatThread chatThread, SettingsManager settingsManager, [EnumeratorCancellation] CancellationToken token = default)
|
||||||
{
|
{
|
||||||
// Get the API key:
|
// Get the API key:
|
||||||
var requestedSecret = await RUST_SERVICE.GetAPIKey(this);
|
var requestedSecret = await RUST_SERVICE.GetAPIKey(this);
|
||||||
@ -34,7 +35,7 @@ public class ProviderFireworks(ILogger logger) : BaseProvider("https://api.firew
|
|||||||
var systemPrompt = new Message
|
var systemPrompt = new Message
|
||||||
{
|
{
|
||||||
Role = "system",
|
Role = "system",
|
||||||
Content = chatThread.SystemPrompt,
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the Fireworks HTTP chat request:
|
// Prepare the Fireworks HTTP chat request:
|
||||||
|
@ -5,6 +5,7 @@ using System.Text.Json;
|
|||||||
|
|
||||||
using AIStudio.Chat;
|
using AIStudio.Chat;
|
||||||
using AIStudio.Provider.OpenAI;
|
using AIStudio.Provider.OpenAI;
|
||||||
|
using AIStudio.Settings;
|
||||||
|
|
||||||
namespace AIStudio.Provider.Google;
|
namespace AIStudio.Provider.Google;
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ public class ProviderGoogle(ILogger logger) : BaseProvider("https://generativela
|
|||||||
public override string InstanceName { get; set; } = "Google Gemini";
|
public override string InstanceName { get; set; } = "Google Gemini";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override async IAsyncEnumerable<string> StreamChatCompletion(Provider.Model chatModel, ChatThread chatThread, [EnumeratorCancellation] CancellationToken token = default)
|
public override async IAsyncEnumerable<string> StreamChatCompletion(Provider.Model chatModel, ChatThread chatThread, SettingsManager settingsManager, [EnumeratorCancellation] CancellationToken token = default)
|
||||||
{
|
{
|
||||||
// Get the API key:
|
// Get the API key:
|
||||||
var requestedSecret = await RUST_SERVICE.GetAPIKey(this);
|
var requestedSecret = await RUST_SERVICE.GetAPIKey(this);
|
||||||
@ -35,7 +36,7 @@ public class ProviderGoogle(ILogger logger) : BaseProvider("https://generativela
|
|||||||
var systemPrompt = new Message
|
var systemPrompt = new Message
|
||||||
{
|
{
|
||||||
Role = "system",
|
Role = "system",
|
||||||
Content = chatThread.SystemPrompt,
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the Google HTTP chat request:
|
// Prepare the Google HTTP chat request:
|
||||||
|
@ -5,6 +5,7 @@ using System.Text.Json;
|
|||||||
|
|
||||||
using AIStudio.Chat;
|
using AIStudio.Chat;
|
||||||
using AIStudio.Provider.OpenAI;
|
using AIStudio.Provider.OpenAI;
|
||||||
|
using AIStudio.Settings;
|
||||||
|
|
||||||
namespace AIStudio.Provider.Groq;
|
namespace AIStudio.Provider.Groq;
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ public class ProviderGroq(ILogger logger) : BaseProvider("https://api.groq.com/o
|
|||||||
public override string InstanceName { get; set; } = "Groq";
|
public override string InstanceName { get; set; } = "Groq";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override async IAsyncEnumerable<string> StreamChatCompletion(Model chatModel, ChatThread chatThread, [EnumeratorCancellation] CancellationToken token = default)
|
public override async IAsyncEnumerable<string> StreamChatCompletion(Model chatModel, ChatThread chatThread, SettingsManager settingsManager, [EnumeratorCancellation] CancellationToken token = default)
|
||||||
{
|
{
|
||||||
// Get the API key:
|
// Get the API key:
|
||||||
var requestedSecret = await RUST_SERVICE.GetAPIKey(this);
|
var requestedSecret = await RUST_SERVICE.GetAPIKey(this);
|
||||||
@ -35,7 +36,7 @@ public class ProviderGroq(ILogger logger) : BaseProvider("https://api.groq.com/o
|
|||||||
var systemPrompt = new Message
|
var systemPrompt = new Message
|
||||||
{
|
{
|
||||||
Role = "system",
|
Role = "system",
|
||||||
Content = chatThread.SystemPrompt,
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the OpenAI HTTP chat request:
|
// Prepare the OpenAI HTTP chat request:
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AIStudio.Chat;
|
using AIStudio.Chat;
|
||||||
|
using AIStudio.Settings;
|
||||||
|
|
||||||
namespace AIStudio.Provider;
|
namespace AIStudio.Provider;
|
||||||
|
|
||||||
@ -23,9 +24,10 @@ public interface IProvider
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="chatModel">The model to use for chat completion.</param>
|
/// <param name="chatModel">The model to use for chat completion.</param>
|
||||||
/// <param name="chatThread">The chat thread to continue.</param>
|
/// <param name="chatThread">The chat thread to continue.</param>
|
||||||
|
/// <param name="settingsManager">The settings manager instance to use.</param>
|
||||||
/// <param name="token">The cancellation token.</param>
|
/// <param name="token">The cancellation token.</param>
|
||||||
/// <returns>The chat completion stream.</returns>
|
/// <returns>The chat completion stream.</returns>
|
||||||
public IAsyncEnumerable<string> StreamChatCompletion(Model chatModel, ChatThread chatThread, CancellationToken token = default);
|
public IAsyncEnumerable<string> StreamChatCompletion(Model chatModel, ChatThread chatThread, SettingsManager settingsManager, CancellationToken token = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts an image completion stream.
|
/// Starts an image completion stream.
|
||||||
|
@ -5,6 +5,7 @@ using System.Text.Json;
|
|||||||
|
|
||||||
using AIStudio.Chat;
|
using AIStudio.Chat;
|
||||||
using AIStudio.Provider.OpenAI;
|
using AIStudio.Provider.OpenAI;
|
||||||
|
using AIStudio.Settings;
|
||||||
|
|
||||||
namespace AIStudio.Provider.Mistral;
|
namespace AIStudio.Provider.Mistral;
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ public sealed class ProviderMistral(ILogger logger) : BaseProvider("https://api.
|
|||||||
public override string InstanceName { get; set; } = "Mistral";
|
public override string InstanceName { get; set; } = "Mistral";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override async IAsyncEnumerable<string> StreamChatCompletion(Provider.Model chatModel, ChatThread chatThread, [EnumeratorCancellation] CancellationToken token = default)
|
public override async IAsyncEnumerable<string> StreamChatCompletion(Provider.Model chatModel, ChatThread chatThread, SettingsManager settingsManager, [EnumeratorCancellation] CancellationToken token = default)
|
||||||
{
|
{
|
||||||
// Get the API key:
|
// Get the API key:
|
||||||
var requestedSecret = await RUST_SERVICE.GetAPIKey(this);
|
var requestedSecret = await RUST_SERVICE.GetAPIKey(this);
|
||||||
@ -33,7 +34,7 @@ public sealed class ProviderMistral(ILogger logger) : BaseProvider("https://api.
|
|||||||
var systemPrompt = new RegularMessage
|
var systemPrompt = new RegularMessage
|
||||||
{
|
{
|
||||||
Role = "system",
|
Role = "system",
|
||||||
Content = chatThread.SystemPrompt,
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the Mistral HTTP chat request:
|
// Prepare the Mistral HTTP chat request:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
using AIStudio.Chat;
|
using AIStudio.Chat;
|
||||||
|
using AIStudio.Settings;
|
||||||
|
|
||||||
namespace AIStudio.Provider;
|
namespace AIStudio.Provider;
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ public class NoProvider : IProvider
|
|||||||
|
|
||||||
public Task<IEnumerable<Model>> GetEmbeddingModels(string? apiKeyProvisional = null, CancellationToken token = default) => Task.FromResult<IEnumerable<Model>>([]);
|
public Task<IEnumerable<Model>> GetEmbeddingModels(string? apiKeyProvisional = null, CancellationToken token = default) => Task.FromResult<IEnumerable<Model>>([]);
|
||||||
|
|
||||||
public async IAsyncEnumerable<string> StreamChatCompletion(Model chatModel, ChatThread chatChatThread, [EnumeratorCancellation] CancellationToken token = default)
|
public async IAsyncEnumerable<string> StreamChatCompletion(Model chatModel, ChatThread chatChatThread, SettingsManager settingsManager, [EnumeratorCancellation] CancellationToken token = default)
|
||||||
{
|
{
|
||||||
await Task.FromResult(0);
|
await Task.FromResult(0);
|
||||||
yield break;
|
yield break;
|
||||||
|
@ -4,6 +4,7 @@ using System.Text;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
using AIStudio.Chat;
|
using AIStudio.Chat;
|
||||||
|
using AIStudio.Settings;
|
||||||
|
|
||||||
namespace AIStudio.Provider.OpenAI;
|
namespace AIStudio.Provider.OpenAI;
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ public sealed class ProviderOpenAI(ILogger logger) : BaseProvider("https://api.o
|
|||||||
public override string InstanceName { get; set; } = "OpenAI";
|
public override string InstanceName { get; set; } = "OpenAI";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override async IAsyncEnumerable<string> StreamChatCompletion(Model chatModel, ChatThread chatThread, [EnumeratorCancellation] CancellationToken token = default)
|
public override async IAsyncEnumerable<string> StreamChatCompletion(Model chatModel, ChatThread chatThread, SettingsManager settingsManager, [EnumeratorCancellation] CancellationToken token = default)
|
||||||
{
|
{
|
||||||
// Get the API key:
|
// Get the API key:
|
||||||
var requestedSecret = await RUST_SERVICE.GetAPIKey(this);
|
var requestedSecret = await RUST_SERVICE.GetAPIKey(this);
|
||||||
@ -62,7 +63,7 @@ public sealed class ProviderOpenAI(ILogger logger) : BaseProvider("https://api.o
|
|||||||
var systemPrompt = new Message
|
var systemPrompt = new Message
|
||||||
{
|
{
|
||||||
Role = systemPromptRole,
|
Role = systemPromptRole,
|
||||||
Content = chatThread.SystemPrompt,
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the OpenAI HTTP chat request:
|
// Prepare the OpenAI HTTP chat request:
|
||||||
|
@ -5,6 +5,7 @@ using System.Text.Json;
|
|||||||
|
|
||||||
using AIStudio.Chat;
|
using AIStudio.Chat;
|
||||||
using AIStudio.Provider.OpenAI;
|
using AIStudio.Provider.OpenAI;
|
||||||
|
using AIStudio.Settings;
|
||||||
|
|
||||||
namespace AIStudio.Provider.SelfHosted;
|
namespace AIStudio.Provider.SelfHosted;
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ public sealed class ProviderSelfHosted(ILogger logger, Host host, string hostnam
|
|||||||
public override string InstanceName { get; set; } = "Self-hosted";
|
public override string InstanceName { get; set; } = "Self-hosted";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override async IAsyncEnumerable<string> StreamChatCompletion(Provider.Model chatModel, ChatThread chatThread, [EnumeratorCancellation] CancellationToken token = default)
|
public override async IAsyncEnumerable<string> StreamChatCompletion(Provider.Model chatModel, ChatThread chatThread, SettingsManager settingsManager, [EnumeratorCancellation] CancellationToken token = default)
|
||||||
{
|
{
|
||||||
// Get the API key:
|
// Get the API key:
|
||||||
var requestedSecret = await RUST_SERVICE.GetAPIKey(this, isTrying: true);
|
var requestedSecret = await RUST_SERVICE.GetAPIKey(this, isTrying: true);
|
||||||
@ -31,7 +32,7 @@ public sealed class ProviderSelfHosted(ILogger logger, Host host, string hostnam
|
|||||||
var systemPrompt = new Message
|
var systemPrompt = new Message
|
||||||
{
|
{
|
||||||
Role = "system",
|
Role = "system",
|
||||||
Content = chatThread.SystemPrompt,
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the OpenAI HTTP chat request:
|
// Prepare the OpenAI HTTP chat request:
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
# v0.9.23, build 198 (2024-12-xx xx:xx UTC)
|
# v0.9.23, build 198 (2024-12-xx xx:xx UTC)
|
||||||
- Added an ERI server coding assistant as a preview feature behind the RAG feature flag. This helps you implement an ERI server to gain access to, e.g., your enterprise data from within AI Studio.
|
- Added an ERI server coding assistant as a preview feature behind the RAG feature flag. This helps you implement an ERI server to gain access to, e.g., your enterprise data from within AI Studio.
|
||||||
|
- Improved profile handling: Every chat remembers the last profile used.
|
||||||
- Improved the chat UI: You can now set the aspect ratio between workspaces and chat as you like.
|
- Improved the chat UI: You can now set the aspect ratio between workspaces and chat as you like.
|
||||||
- Improved provider requests by handling rate limits by retrying requests.
|
- Improved provider requests by handling rate limits by retrying requests.
|
||||||
- Improved the creation of the "the bias of the day" workspace; create that workspace only when the bias of the day feature is used.
|
- Improved the creation of the "the bias of the day" workspace; create that workspace only when the bias of the day feature is used.
|
||||||
- Improved the save operation of settings by using a temporary file to avoid data loss in rare cases.
|
- Improved the save operation of settings by using a temporary file to avoid data loss in rare cases.
|
||||||
|
- Improved the system prompt handling: Injection of profiles into system prompts happens right before sending the data. This way, the original system prompts are not modified.
|
||||||
- Fixed OpenAI `o` (aka omni, aka reasoning) models. The early preview versions (released before 17th December 2024) could not use any system prompts —- we translated the system prompts to be user prompts. Final versions of the OpenAI `o` models can now use system prompts, by they are named `developer` instead of `system`.
|
- Fixed OpenAI `o` (aka omni, aka reasoning) models. The early preview versions (released before 17th December 2024) could not use any system prompts —- we translated the system prompts to be user prompts. Final versions of the OpenAI `o` models can now use system prompts, by they are named `developer` instead of `system`.
|
||||||
- Fixed layout issues when selecting `other` items (e.g., programming languages).
|
- Fixed layout issues when selecting `other` items (e.g., programming languages).
|
||||||
- Fixed a bug about the bias of the day workspace when the workspace component was hidden.
|
- Fixed a bug about the bias of the day workspace when the workspace component was hidden.
|
||||||
|
Loading…
Reference in New Issue
Block a user