mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-09-18 16:00:22 +00:00
Improved provider logging (#551)
Some checks are pending
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Read metadata (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Some checks are pending
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Read metadata (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
This commit is contained in:
parent
70e64f2d14
commit
6a37ce6d25
@ -125,6 +125,6 @@ public abstract class AgentBase(ILogger<AgentBase> logger, SettingsManager setti
|
|||||||
// Use the selected provider to get the AI response.
|
// Use the selected provider to get the AI response.
|
||||||
// By awaiting this line, we wait for the entire
|
// By awaiting this line, we wait for the entire
|
||||||
// content to be streamed.
|
// content to be streamed.
|
||||||
await aiText.CreateFromProviderAsync(this.ProviderSettings.CreateProvider(this.Logger), this.ProviderSettings.Model, lastUserPrompt, thread);
|
await aiText.CreateFromProviderAsync(this.ProviderSettings.CreateProvider(), this.ProviderSettings.Model, lastUserPrompt, thread);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -270,7 +270,7 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
|||||||
// Use the selected provider to get the AI response.
|
// Use the selected provider to get the AI response.
|
||||||
// By awaiting this line, we wait for the entire
|
// By awaiting this line, we wait for the entire
|
||||||
// content to be streamed.
|
// content to be streamed.
|
||||||
this.chatThread = await aiText.CreateFromProviderAsync(this.providerSettings.CreateProvider(this.Logger), this.providerSettings.Model, this.lastUserPrompt, this.chatThread, this.cancellationTokenSource!.Token);
|
this.chatThread = await aiText.CreateFromProviderAsync(this.providerSettings.CreateProvider(), this.providerSettings.Model, this.lastUserPrompt, this.chatThread, this.cancellationTokenSource!.Token);
|
||||||
|
|
||||||
this.isProcessing = false;
|
this.isProcessing = false;
|
||||||
this.StateHasChanged();
|
this.StateHasChanged();
|
||||||
|
@ -10,6 +10,8 @@ namespace AIStudio.Chat;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed record ChatThread
|
public sealed record ChatThread
|
||||||
{
|
{
|
||||||
|
private static readonly ILogger<ChatThread> LOGGER = Program.LOGGER_FACTORY.CreateLogger<ChatThread>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The unique identifier of the chat thread.
|
/// The unique identifier of the chat thread.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -82,9 +84,8 @@ public sealed record ChatThread
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="settingsManager">The settings manager instance to use.</param>
|
/// <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="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>
|
/// <returns>The prepared system prompt.</returns>
|
||||||
public string PrepareSystemPrompt(SettingsManager settingsManager, ChatThread chatThread, ILogger logger)
|
public string PrepareSystemPrompt(SettingsManager settingsManager, ChatThread chatThread)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Use the information from the chat template, if provided. Otherwise, use the default system prompt
|
// Use the information from the chat template, if provided. Otherwise, use the default system prompt
|
||||||
@ -121,7 +122,7 @@ public sealed record ChatThread
|
|||||||
// default system prompt:
|
// default system prompt:
|
||||||
chatThread = chatThread with { SystemPrompt = systemPromptTextWithChatTemplate };
|
chatThread = chatThread with { SystemPrompt = systemPromptTextWithChatTemplate };
|
||||||
|
|
||||||
logger.LogInformation(logMessage);
|
LOGGER.LogInformation(logMessage);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add augmented data, if available:
|
// Add augmented data, if available:
|
||||||
@ -139,9 +140,9 @@ public sealed record ChatThread
|
|||||||
};
|
};
|
||||||
|
|
||||||
if(isAugmentedDataAvailable)
|
if(isAugmentedDataAvailable)
|
||||||
logger.LogInformation("Augmented data is available for the chat thread.");
|
LOGGER.LogInformation("Augmented data is available for the chat thread.");
|
||||||
else
|
else
|
||||||
logger.LogInformation("No augmented data is available for the chat thread.");
|
LOGGER.LogInformation("No augmented data is available for the chat thread.");
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -177,7 +178,7 @@ public sealed record ChatThread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.LogInformation(logMessage);
|
LOGGER.LogInformation(logMessage);
|
||||||
return systemPromptText;
|
return systemPromptText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,7 +528,7 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
|
|||||||
// Use the selected provider to get the AI response.
|
// Use the selected provider to get the AI response.
|
||||||
// By awaiting this line, we wait for the entire
|
// By awaiting this line, we wait for the entire
|
||||||
// content to be streamed.
|
// content to be streamed.
|
||||||
this.ChatThread = await aiText.CreateFromProviderAsync(this.Provider.CreateProvider(this.Logger), this.Provider.Model, lastUserPrompt, this.ChatThread, this.cancellationTokenSource.Token);
|
this.ChatThread = await aiText.CreateFromProviderAsync(this.Provider.CreateProvider(), this.Provider.Model, lastUserPrompt, this.ChatThread, this.cancellationTokenSource.Token);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cancellationTokenSource = null;
|
this.cancellationTokenSource = null;
|
||||||
|
@ -69,9 +69,6 @@ public partial class EmbeddingProviderDialog : MSGComponentBase, ISecretId
|
|||||||
[Parameter]
|
[Parameter]
|
||||||
public bool IsEditing { get; init; }
|
public bool IsEditing { get; init; }
|
||||||
|
|
||||||
[Inject]
|
|
||||||
private ILogger<ProviderDialog> Logger { get; init; } = null!;
|
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
private RustService RustService { get; init; } = null!;
|
private RustService RustService { get; init; } = null!;
|
||||||
|
|
||||||
@ -244,7 +241,7 @@ public partial class EmbeddingProviderDialog : MSGComponentBase, ISecretId
|
|||||||
private async Task ReloadModels()
|
private async Task ReloadModels()
|
||||||
{
|
{
|
||||||
var currentEmbeddingProviderSettings = this.CreateEmbeddingProviderSettings();
|
var currentEmbeddingProviderSettings = this.CreateEmbeddingProviderSettings();
|
||||||
var provider = currentEmbeddingProviderSettings.CreateProvider(this.Logger);
|
var provider = currentEmbeddingProviderSettings.CreateProvider();
|
||||||
if(provider is NoProvider)
|
if(provider is NoProvider)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public partial class PandocDialog : MSGComponentBase
|
|||||||
[CascadingParameter]
|
[CascadingParameter]
|
||||||
private IMudDialogInstance MudDialog { get; set; } = null!;
|
private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||||
|
|
||||||
private static readonly ILogger LOG = Program.LOGGER_FACTORY.CreateLogger("PandocDialog");
|
private static readonly ILogger LOG = Program.LOGGER_FACTORY.CreateLogger(nameof(PandocDialog));
|
||||||
private static readonly string LICENCE_URI = "https://raw.githubusercontent.com/jgm/pandoc/refs/heads/main/COPYING.md";
|
private static readonly string LICENCE_URI = "https://raw.githubusercontent.com/jgm/pandoc/refs/heads/main/COPYING.md";
|
||||||
private static string LATEST_PANDOC_VERSION = string.Empty;
|
private static string LATEST_PANDOC_VERSION = string.Empty;
|
||||||
|
|
||||||
|
@ -78,9 +78,6 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
|
|||||||
[Parameter]
|
[Parameter]
|
||||||
public bool IsEditing { get; init; }
|
public bool IsEditing { get; init; }
|
||||||
|
|
||||||
[Inject]
|
|
||||||
private ILogger<ProviderDialog> Logger { get; init; } = null!;
|
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
private RustService RustService { get; init; } = null!;
|
private RustService RustService { get; init; } = null!;
|
||||||
|
|
||||||
@ -253,7 +250,7 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
|
|||||||
private async Task ReloadModels()
|
private async Task ReloadModels()
|
||||||
{
|
{
|
||||||
var currentProviderSettings = this.CreateProviderSettings();
|
var currentProviderSettings = this.CreateProviderSettings();
|
||||||
var provider = currentProviderSettings.CreateProvider(this.Logger);
|
var provider = currentProviderSettings.CreateProvider();
|
||||||
if(provider is NoProvider)
|
if(provider is NoProvider)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ using AIStudio.Chat;
|
|||||||
using AIStudio.Components;
|
using AIStudio.Components;
|
||||||
using AIStudio.Provider;
|
using AIStudio.Provider;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Components;
|
|
||||||
using Microsoft.AspNetCore.Components.Web;
|
using Microsoft.AspNetCore.Components.Web;
|
||||||
|
|
||||||
using Timer = System.Timers.Timer;
|
using Timer = System.Timers.Timer;
|
||||||
@ -11,9 +10,6 @@ namespace AIStudio.Pages;
|
|||||||
|
|
||||||
public partial class Writer : MSGComponentBase
|
public partial class Writer : MSGComponentBase
|
||||||
{
|
{
|
||||||
[Inject]
|
|
||||||
private ILogger<Chat> Logger { get; init; } = null!;
|
|
||||||
|
|
||||||
private static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
|
private static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
|
||||||
private readonly Timer typeTimer = new(TimeSpan.FromMilliseconds(1_500));
|
private readonly Timer typeTimer = new(TimeSpan.FromMilliseconds(1_500));
|
||||||
|
|
||||||
@ -121,7 +117,7 @@ public partial class Writer : MSGComponentBase
|
|||||||
this.isStreaming = true;
|
this.isStreaming = true;
|
||||||
this.StateHasChanged();
|
this.StateHasChanged();
|
||||||
|
|
||||||
this.chatThread = await aiText.CreateFromProviderAsync(this.providerSettings.CreateProvider(this.Logger), this.providerSettings.Model, lastUserPrompt, this.chatThread);
|
this.chatThread = await aiText.CreateFromProviderAsync(this.providerSettings.CreateProvider(), this.providerSettings.Model, lastUserPrompt, this.chatThread);
|
||||||
this.suggestion = aiText.Text;
|
this.suggestion = aiText.Text;
|
||||||
|
|
||||||
this.isStreaming = false;
|
this.isStreaming = false;
|
||||||
|
@ -9,8 +9,9 @@ using AIStudio.Settings;
|
|||||||
|
|
||||||
namespace AIStudio.Provider.AlibabaCloud;
|
namespace AIStudio.Provider.AlibabaCloud;
|
||||||
|
|
||||||
public sealed class ProviderAlibabaCloud(ILogger logger) : BaseProvider("https://dashscope-intl.aliyuncs.com/compatible-mode/v1/", logger)
|
public sealed class ProviderAlibabaCloud() : BaseProvider("https://dashscope-intl.aliyuncs.com/compatible-mode/v1/", LOGGER)
|
||||||
{
|
{
|
||||||
|
private static readonly ILogger<ProviderAlibabaCloud> LOGGER = Program.LOGGER_FACTORY.CreateLogger<ProviderAlibabaCloud>();
|
||||||
|
|
||||||
#region Implementation of IProvider
|
#region Implementation of IProvider
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ public sealed class ProviderAlibabaCloud(ILogger logger) : BaseProvider("https:/
|
|||||||
var systemPrompt = new Message
|
var systemPrompt = new Message
|
||||||
{
|
{
|
||||||
Role = "system",
|
Role = "system",
|
||||||
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the AlibabaCloud HTTP chat request:
|
// Prepare the AlibabaCloud HTTP chat request:
|
||||||
|
@ -9,8 +9,10 @@ using AIStudio.Settings;
|
|||||||
|
|
||||||
namespace AIStudio.Provider.Anthropic;
|
namespace AIStudio.Provider.Anthropic;
|
||||||
|
|
||||||
public sealed class ProviderAnthropic(ILogger logger) : BaseProvider("https://api.anthropic.com/v1/", logger)
|
public sealed class ProviderAnthropic() : BaseProvider("https://api.anthropic.com/v1/", LOGGER)
|
||||||
{
|
{
|
||||||
|
private static readonly ILogger<ProviderAnthropic> LOGGER = Program.LOGGER_FACTORY.CreateLogger<ProviderAnthropic>();
|
||||||
|
|
||||||
#region Implementation of IProvider
|
#region Implementation of IProvider
|
||||||
|
|
||||||
public override string Id => LLMProviders.ANTHROPIC.ToName();
|
public override string Id => LLMProviders.ANTHROPIC.ToName();
|
||||||
@ -49,7 +51,7 @@ public sealed class ProviderAnthropic(ILogger logger) : BaseProvider("https://ap
|
|||||||
}
|
}
|
||||||
}).ToList()],
|
}).ToList()],
|
||||||
|
|
||||||
System = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
System = chatThread.PrepareSystemPrompt(settingsManager, chatThread),
|
||||||
MaxTokens = 4_096,
|
MaxTokens = 4_096,
|
||||||
|
|
||||||
// Right now, we only support streaming completions:
|
// Right now, we only support streaming completions:
|
||||||
|
@ -25,7 +25,7 @@ public abstract class BaseProvider : IProvider, ISecretId
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The logger to use.
|
/// The logger to use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly ILogger logger;
|
private readonly ILogger logger;
|
||||||
|
|
||||||
static BaseProvider()
|
static BaseProvider()
|
||||||
{
|
{
|
||||||
@ -47,10 +47,10 @@ public abstract class BaseProvider : IProvider, ISecretId
|
|||||||
/// Constructor for the base provider.
|
/// Constructor for the base provider.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="url">The base URL for the provider.</param>
|
/// <param name="url">The base URL for the provider.</param>
|
||||||
/// <param name="loggerService">The logger service to use.</param>
|
/// <param name="logger">The logger to use.</param>
|
||||||
protected BaseProvider(string url, ILogger loggerService)
|
protected BaseProvider(string url, ILogger logger)
|
||||||
{
|
{
|
||||||
this.logger = loggerService;
|
this.logger = logger;
|
||||||
|
|
||||||
// Set the base URL:
|
// Set the base URL:
|
||||||
this.httpClient.BaseAddress = new(url);
|
this.httpClient.BaseAddress = new(url);
|
||||||
|
@ -9,8 +9,10 @@ using AIStudio.Settings;
|
|||||||
|
|
||||||
namespace AIStudio.Provider.DeepSeek;
|
namespace AIStudio.Provider.DeepSeek;
|
||||||
|
|
||||||
public sealed class ProviderDeepSeek(ILogger logger) : BaseProvider("https://api.deepseek.com/", logger)
|
public sealed class ProviderDeepSeek() : BaseProvider("https://api.deepseek.com/", LOGGER)
|
||||||
{
|
{
|
||||||
|
private static readonly ILogger<ProviderDeepSeek> LOGGER = Program.LOGGER_FACTORY.CreateLogger<ProviderDeepSeek>();
|
||||||
|
|
||||||
#region Implementation of IProvider
|
#region Implementation of IProvider
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -31,7 +33,7 @@ public sealed class ProviderDeepSeek(ILogger logger) : BaseProvider("https://api
|
|||||||
var systemPrompt = new Message
|
var systemPrompt = new Message
|
||||||
{
|
{
|
||||||
Role = "system",
|
Role = "system",
|
||||||
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the DeepSeek HTTP chat request:
|
// Prepare the DeepSeek HTTP chat request:
|
||||||
|
@ -9,8 +9,10 @@ using AIStudio.Settings;
|
|||||||
|
|
||||||
namespace AIStudio.Provider.Fireworks;
|
namespace AIStudio.Provider.Fireworks;
|
||||||
|
|
||||||
public class ProviderFireworks(ILogger logger) : BaseProvider("https://api.fireworks.ai/inference/v1/", logger)
|
public class ProviderFireworks() : BaseProvider("https://api.fireworks.ai/inference/v1/", LOGGER)
|
||||||
{
|
{
|
||||||
|
private static readonly ILogger<ProviderFireworks> LOGGER = Program.LOGGER_FACTORY.CreateLogger<ProviderFireworks>();
|
||||||
|
|
||||||
#region Implementation of IProvider
|
#region Implementation of IProvider
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -31,7 +33,7 @@ public class ProviderFireworks(ILogger logger) : BaseProvider("https://api.firew
|
|||||||
var systemPrompt = new Message
|
var systemPrompt = new Message
|
||||||
{
|
{
|
||||||
Role = "system",
|
Role = "system",
|
||||||
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the Fireworks HTTP chat request:
|
// Prepare the Fireworks HTTP chat request:
|
||||||
|
@ -9,8 +9,10 @@ using AIStudio.Settings;
|
|||||||
|
|
||||||
namespace AIStudio.Provider.GWDG;
|
namespace AIStudio.Provider.GWDG;
|
||||||
|
|
||||||
public sealed class ProviderGWDG(ILogger logger) : BaseProvider("https://chat-ai.academiccloud.de/v1/", logger)
|
public sealed class ProviderGWDG() : BaseProvider("https://chat-ai.academiccloud.de/v1/", LOGGER)
|
||||||
{
|
{
|
||||||
|
private static readonly ILogger<ProviderGWDG> LOGGER = Program.LOGGER_FACTORY.CreateLogger<ProviderGWDG>();
|
||||||
|
|
||||||
#region Implementation of IProvider
|
#region Implementation of IProvider
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -31,7 +33,7 @@ public sealed class ProviderGWDG(ILogger logger) : BaseProvider("https://chat-ai
|
|||||||
var systemPrompt = new Message
|
var systemPrompt = new Message
|
||||||
{
|
{
|
||||||
Role = "system",
|
Role = "system",
|
||||||
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the GWDG HTTP chat request:
|
// Prepare the GWDG HTTP chat request:
|
||||||
|
@ -9,8 +9,10 @@ using AIStudio.Settings;
|
|||||||
|
|
||||||
namespace AIStudio.Provider.Google;
|
namespace AIStudio.Provider.Google;
|
||||||
|
|
||||||
public class ProviderGoogle(ILogger logger) : BaseProvider("https://generativelanguage.googleapis.com/v1beta/", logger)
|
public class ProviderGoogle() : BaseProvider("https://generativelanguage.googleapis.com/v1beta/", LOGGER)
|
||||||
{
|
{
|
||||||
|
private static readonly ILogger<ProviderGoogle> LOGGER = Program.LOGGER_FACTORY.CreateLogger<ProviderGoogle>();
|
||||||
|
|
||||||
#region Implementation of IProvider
|
#region Implementation of IProvider
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -31,7 +33,7 @@ public class ProviderGoogle(ILogger logger) : BaseProvider("https://generativela
|
|||||||
var systemPrompt = new Message
|
var systemPrompt = new Message
|
||||||
{
|
{
|
||||||
Role = "system",
|
Role = "system",
|
||||||
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the Google HTTP chat request:
|
// Prepare the Google HTTP chat request:
|
||||||
|
@ -9,8 +9,10 @@ using AIStudio.Settings;
|
|||||||
|
|
||||||
namespace AIStudio.Provider.Groq;
|
namespace AIStudio.Provider.Groq;
|
||||||
|
|
||||||
public class ProviderGroq(ILogger logger) : BaseProvider("https://api.groq.com/openai/v1/", logger)
|
public class ProviderGroq() : BaseProvider("https://api.groq.com/openai/v1/", LOGGER)
|
||||||
{
|
{
|
||||||
|
private static readonly ILogger<ProviderGroq> LOGGER = Program.LOGGER_FACTORY.CreateLogger<ProviderGroq>();
|
||||||
|
|
||||||
#region Implementation of IProvider
|
#region Implementation of IProvider
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -31,7 +33,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.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the OpenAI HTTP chat request:
|
// Prepare the OpenAI HTTP chat request:
|
||||||
|
@ -9,8 +9,10 @@ using AIStudio.Settings;
|
|||||||
|
|
||||||
namespace AIStudio.Provider.Helmholtz;
|
namespace AIStudio.Provider.Helmholtz;
|
||||||
|
|
||||||
public sealed class ProviderHelmholtz(ILogger logger) : BaseProvider("https://api.helmholtz-blablador.fz-juelich.de/v1/", logger)
|
public sealed class ProviderHelmholtz() : BaseProvider("https://api.helmholtz-blablador.fz-juelich.de/v1/", LOGGER)
|
||||||
{
|
{
|
||||||
|
private static readonly ILogger<ProviderHelmholtz> LOGGER = Program.LOGGER_FACTORY.CreateLogger<ProviderHelmholtz>();
|
||||||
|
|
||||||
#region Implementation of IProvider
|
#region Implementation of IProvider
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -31,7 +33,7 @@ public sealed class ProviderHelmholtz(ILogger logger) : BaseProvider("https://ap
|
|||||||
var systemPrompt = new Message
|
var systemPrompt = new Message
|
||||||
{
|
{
|
||||||
Role = "system",
|
Role = "system",
|
||||||
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the Helmholtz HTTP chat request:
|
// Prepare the Helmholtz HTTP chat request:
|
||||||
|
@ -11,9 +11,11 @@ namespace AIStudio.Provider.HuggingFace;
|
|||||||
|
|
||||||
public sealed class ProviderHuggingFace : BaseProvider
|
public sealed class ProviderHuggingFace : BaseProvider
|
||||||
{
|
{
|
||||||
public ProviderHuggingFace(ILogger logger, HFInferenceProvider hfProvider, Model model) : base($"https://router.huggingface.co/{hfProvider.Endpoints(model)}", logger)
|
private static readonly ILogger<ProviderHuggingFace> LOGGER = Program.LOGGER_FACTORY.CreateLogger<ProviderHuggingFace>();
|
||||||
|
|
||||||
|
public ProviderHuggingFace(HFInferenceProvider hfProvider, Model model) : base($"https://router.huggingface.co/{hfProvider.Endpoints(model)}", LOGGER)
|
||||||
{
|
{
|
||||||
logger.LogInformation($"We use the inferende provider '{hfProvider}'. Thus we use the base URL 'https://router.huggingface.co/{hfProvider.Endpoints(model)}'.");
|
LOGGER.LogInformation($"We use the inferende provider '{hfProvider}'. Thus we use the base URL 'https://router.huggingface.co/{hfProvider.Endpoints(model)}'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Implementation of IProvider
|
#region Implementation of IProvider
|
||||||
@ -36,7 +38,7 @@ public sealed class ProviderHuggingFace : BaseProvider
|
|||||||
var systemPrompt = new Message
|
var systemPrompt = new Message
|
||||||
{
|
{
|
||||||
Role = "system",
|
Role = "system",
|
||||||
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the HuggingFace HTTP chat request:
|
// Prepare the HuggingFace HTTP chat request:
|
||||||
|
@ -21,6 +21,8 @@ namespace AIStudio.Provider;
|
|||||||
|
|
||||||
public static class LLMProvidersExtensions
|
public static class LLMProvidersExtensions
|
||||||
{
|
{
|
||||||
|
private static readonly ILogger LOGGER = Program.LOGGER_FACTORY.CreateLogger(nameof(LLMProvidersExtensions));
|
||||||
|
|
||||||
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(LLMProvidersExtensions).Namespace, nameof(LLMProvidersExtensions));
|
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(LLMProvidersExtensions).Namespace, nameof(LLMProvidersExtensions));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -139,54 +141,52 @@ public static class LLMProvidersExtensions
|
|||||||
/// Creates a new provider instance based on the provider value.
|
/// Creates a new provider instance based on the provider value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="providerSettings">The provider settings.</param>
|
/// <param name="providerSettings">The provider settings.</param>
|
||||||
/// <param name="logger">The logger to use.</param>
|
|
||||||
/// <returns>The provider instance.</returns>
|
/// <returns>The provider instance.</returns>
|
||||||
public static IProvider CreateProvider(this AIStudio.Settings.Provider providerSettings, ILogger logger)
|
public static IProvider CreateProvider(this AIStudio.Settings.Provider providerSettings)
|
||||||
{
|
{
|
||||||
return providerSettings.UsedLLMProvider.CreateProvider(providerSettings.InstanceName, providerSettings.Host, providerSettings.Hostname, providerSettings.Model, providerSettings.HFInferenceProvider ,logger);
|
return providerSettings.UsedLLMProvider.CreateProvider(providerSettings.InstanceName, providerSettings.Host, providerSettings.Hostname, providerSettings.Model, providerSettings.HFInferenceProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new provider instance based on the embedding provider value.
|
/// Creates a new provider instance based on the embedding provider value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="embeddingProviderSettings">The embedding provider settings.</param>
|
/// <param name="embeddingProviderSettings">The embedding provider settings.</param>
|
||||||
/// <param name="logger">The logger to use.</param>
|
|
||||||
/// <returns>The provider instance.</returns>
|
/// <returns>The provider instance.</returns>
|
||||||
public static IProvider CreateProvider(this EmbeddingProvider embeddingProviderSettings, ILogger logger)
|
public static IProvider CreateProvider(this EmbeddingProvider embeddingProviderSettings)
|
||||||
{
|
{
|
||||||
return embeddingProviderSettings.UsedLLMProvider.CreateProvider(embeddingProviderSettings.Name, embeddingProviderSettings.Host, embeddingProviderSettings.Hostname, embeddingProviderSettings.Model, HFInferenceProvider.NONE,logger);
|
return embeddingProviderSettings.UsedLLMProvider.CreateProvider(embeddingProviderSettings.Name, embeddingProviderSettings.Host, embeddingProviderSettings.Hostname, embeddingProviderSettings.Model, HFInferenceProvider.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IProvider CreateProvider(this LLMProviders provider, string instanceName, Host host, string hostname, Model model, HFInferenceProvider inferenceProvider , ILogger logger)
|
private static IProvider CreateProvider(this LLMProviders provider, string instanceName, Host host, string hostname, Model model, HFInferenceProvider inferenceProvider)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return provider switch
|
return provider switch
|
||||||
{
|
{
|
||||||
LLMProviders.OPEN_AI => new ProviderOpenAI(logger) { InstanceName = instanceName },
|
LLMProviders.OPEN_AI => new ProviderOpenAI { InstanceName = instanceName },
|
||||||
LLMProviders.ANTHROPIC => new ProviderAnthropic(logger) { InstanceName = instanceName },
|
LLMProviders.ANTHROPIC => new ProviderAnthropic { InstanceName = instanceName },
|
||||||
LLMProviders.MISTRAL => new ProviderMistral(logger) { InstanceName = instanceName },
|
LLMProviders.MISTRAL => new ProviderMistral { InstanceName = instanceName },
|
||||||
LLMProviders.GOOGLE => new ProviderGoogle(logger) { InstanceName = instanceName },
|
LLMProviders.GOOGLE => new ProviderGoogle { InstanceName = instanceName },
|
||||||
LLMProviders.X => new ProviderX(logger) { InstanceName = instanceName },
|
LLMProviders.X => new ProviderX { InstanceName = instanceName },
|
||||||
LLMProviders.DEEP_SEEK => new ProviderDeepSeek(logger) { InstanceName = instanceName },
|
LLMProviders.DEEP_SEEK => new ProviderDeepSeek { InstanceName = instanceName },
|
||||||
LLMProviders.ALIBABA_CLOUD => new ProviderAlibabaCloud(logger) { InstanceName = instanceName },
|
LLMProviders.ALIBABA_CLOUD => new ProviderAlibabaCloud { InstanceName = instanceName },
|
||||||
LLMProviders.PERPLEXITY => new ProviderPerplexity(logger) { InstanceName = instanceName },
|
LLMProviders.PERPLEXITY => new ProviderPerplexity { InstanceName = instanceName },
|
||||||
|
|
||||||
LLMProviders.GROQ => new ProviderGroq(logger) { InstanceName = instanceName },
|
LLMProviders.GROQ => new ProviderGroq { InstanceName = instanceName },
|
||||||
LLMProviders.FIREWORKS => new ProviderFireworks(logger) { InstanceName = instanceName },
|
LLMProviders.FIREWORKS => new ProviderFireworks { InstanceName = instanceName },
|
||||||
LLMProviders.HUGGINGFACE => new ProviderHuggingFace(logger, inferenceProvider, model) { InstanceName = instanceName },
|
LLMProviders.HUGGINGFACE => new ProviderHuggingFace(inferenceProvider, model) { InstanceName = instanceName },
|
||||||
|
|
||||||
LLMProviders.SELF_HOSTED => new ProviderSelfHosted(logger, host, hostname) { InstanceName = instanceName },
|
LLMProviders.SELF_HOSTED => new ProviderSelfHosted(host, hostname) { InstanceName = instanceName },
|
||||||
|
|
||||||
LLMProviders.HELMHOLTZ => new ProviderHelmholtz(logger) { InstanceName = instanceName },
|
LLMProviders.HELMHOLTZ => new ProviderHelmholtz { InstanceName = instanceName },
|
||||||
LLMProviders.GWDG => new ProviderGWDG(logger) { InstanceName = instanceName },
|
LLMProviders.GWDG => new ProviderGWDG { InstanceName = instanceName },
|
||||||
|
|
||||||
_ => new NoProvider(),
|
_ => new NoProvider(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
logger.LogError($"Failed to create provider: {e.Message}");
|
LOGGER.LogError($"Failed to create provider: {e.Message}");
|
||||||
return new NoProvider();
|
return new NoProvider();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,10 @@ using AIStudio.Settings;
|
|||||||
|
|
||||||
namespace AIStudio.Provider.Mistral;
|
namespace AIStudio.Provider.Mistral;
|
||||||
|
|
||||||
public sealed class ProviderMistral(ILogger logger) : BaseProvider("https://api.mistral.ai/v1/", logger)
|
public sealed class ProviderMistral() : BaseProvider("https://api.mistral.ai/v1/", LOGGER)
|
||||||
{
|
{
|
||||||
|
private static readonly ILogger<ProviderMistral> LOGGER = Program.LOGGER_FACTORY.CreateLogger<ProviderMistral>();
|
||||||
|
|
||||||
#region Implementation of IProvider
|
#region Implementation of IProvider
|
||||||
|
|
||||||
public override string Id => LLMProviders.MISTRAL.ToName();
|
public override string Id => LLMProviders.MISTRAL.ToName();
|
||||||
@ -29,7 +31,7 @@ public sealed class ProviderMistral(ILogger logger) : BaseProvider("https://api.
|
|||||||
var systemPrompt = new RegularMessage
|
var systemPrompt = new RegularMessage
|
||||||
{
|
{
|
||||||
Role = "system",
|
Role = "system",
|
||||||
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the Mistral HTTP chat request:
|
// Prepare the Mistral HTTP chat request:
|
||||||
|
@ -11,8 +11,10 @@ namespace AIStudio.Provider.OpenAI;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The OpenAI provider.
|
/// The OpenAI provider.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class ProviderOpenAI(ILogger logger) : BaseProvider("https://api.openai.com/v1/", logger)
|
public sealed class ProviderOpenAI() : BaseProvider("https://api.openai.com/v1/", LOGGER)
|
||||||
{
|
{
|
||||||
|
private static readonly ILogger<ProviderOpenAI> LOGGER = Program.LOGGER_FACTORY.CreateLogger<ProviderOpenAI>();
|
||||||
|
|
||||||
#region Implementation of IProvider
|
#region Implementation of IProvider
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -65,13 +67,13 @@ public sealed class ProviderOpenAI(ILogger logger) : BaseProvider("https://api.o
|
|||||||
// Prepare the request path based on the API we are using:
|
// Prepare the request path based on the API we are using:
|
||||||
var requestPath = usingResponsesAPI ? "responses" : "chat/completions";
|
var requestPath = usingResponsesAPI ? "responses" : "chat/completions";
|
||||||
|
|
||||||
this.logger.LogInformation("Using the system prompt role '{SystemPromptRole}' and the '{RequestPath}' API for model '{ChatModelId}'.", systemPromptRole, requestPath, chatModel.Id);
|
LOGGER.LogInformation("Using the system prompt role '{SystemPromptRole}' and the '{RequestPath}' API for model '{ChatModelId}'.", systemPromptRole, requestPath, chatModel.Id);
|
||||||
|
|
||||||
// Prepare the system prompt:
|
// Prepare the system prompt:
|
||||||
var systemPrompt = new Message
|
var systemPrompt = new Message
|
||||||
{
|
{
|
||||||
Role = systemPromptRole,
|
Role = systemPromptRole,
|
||||||
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread),
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -9,8 +9,10 @@ using AIStudio.Settings;
|
|||||||
|
|
||||||
namespace AIStudio.Provider.Perplexity;
|
namespace AIStudio.Provider.Perplexity;
|
||||||
|
|
||||||
public sealed class ProviderPerplexity(ILogger logger) : BaseProvider("https://api.perplexity.ai/", logger)
|
public sealed class ProviderPerplexity() : BaseProvider("https://api.perplexity.ai/", LOGGER)
|
||||||
{
|
{
|
||||||
|
private static readonly ILogger<ProviderPerplexity> LOGGER = Program.LOGGER_FACTORY.CreateLogger<ProviderPerplexity>();
|
||||||
|
|
||||||
private static readonly Model[] KNOWN_MODELS =
|
private static readonly Model[] KNOWN_MODELS =
|
||||||
[
|
[
|
||||||
new("sonar", "Sonar"),
|
new("sonar", "Sonar"),
|
||||||
@ -40,7 +42,7 @@ public sealed class ProviderPerplexity(ILogger logger) : BaseProvider("https://a
|
|||||||
var systemPrompt = new Message
|
var systemPrompt = new Message
|
||||||
{
|
{
|
||||||
Role = "system",
|
Role = "system",
|
||||||
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the Perplexity HTTP chat request:
|
// Prepare the Perplexity HTTP chat request:
|
||||||
|
@ -9,8 +9,10 @@ using AIStudio.Settings;
|
|||||||
|
|
||||||
namespace AIStudio.Provider.SelfHosted;
|
namespace AIStudio.Provider.SelfHosted;
|
||||||
|
|
||||||
public sealed class ProviderSelfHosted(ILogger logger, Host host, string hostname) : BaseProvider($"{hostname}{host.BaseURL()}", logger)
|
public sealed class ProviderSelfHosted(Host host, string hostname) : BaseProvider($"{hostname}{host.BaseURL()}", LOGGER)
|
||||||
{
|
{
|
||||||
|
private static readonly ILogger<ProviderSelfHosted> LOGGER = Program.LOGGER_FACTORY.CreateLogger<ProviderSelfHosted>();
|
||||||
|
|
||||||
#region Implementation of IProvider
|
#region Implementation of IProvider
|
||||||
|
|
||||||
public override string Id => LLMProviders.SELF_HOSTED.ToName();
|
public override string Id => LLMProviders.SELF_HOSTED.ToName();
|
||||||
@ -27,7 +29,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.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the OpenAI HTTP chat request:
|
// Prepare the OpenAI HTTP chat request:
|
||||||
@ -108,7 +110,7 @@ public sealed class ProviderSelfHosted(ILogger logger, Host host, string hostnam
|
|||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
this.logger.LogError($"Failed to load text models from self-hosted provider: {e.Message}");
|
LOGGER.LogError($"Failed to load text models from self-hosted provider: {e.Message}");
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,7 +137,7 @@ public sealed class ProviderSelfHosted(ILogger logger, Host host, string hostnam
|
|||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
this.logger.LogError($"Failed to load text models from self-hosted provider: {e.Message}");
|
LOGGER.LogError($"Failed to load text models from self-hosted provider: {e.Message}");
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,10 @@ using AIStudio.Settings;
|
|||||||
|
|
||||||
namespace AIStudio.Provider.X;
|
namespace AIStudio.Provider.X;
|
||||||
|
|
||||||
public sealed class ProviderX(ILogger logger) : BaseProvider("https://api.x.ai/v1/", logger)
|
public sealed class ProviderX() : BaseProvider("https://api.x.ai/v1/", LOGGER)
|
||||||
{
|
{
|
||||||
|
private static readonly ILogger<ProviderX> LOGGER = Program.LOGGER_FACTORY.CreateLogger<ProviderX>();
|
||||||
|
|
||||||
#region Implementation of IProvider
|
#region Implementation of IProvider
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -31,7 +33,7 @@ public sealed class ProviderX(ILogger logger) : BaseProvider("https://api.x.ai/v
|
|||||||
var systemPrompt = new Message
|
var systemPrompt = new Message
|
||||||
{
|
{
|
||||||
Role = "system",
|
Role = "system",
|
||||||
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread, this.logger),
|
Content = chatThread.PrepareSystemPrompt(settingsManager, chatThread),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare the xAI HTTP chat request:
|
// Prepare the xAI HTTP chat request:
|
||||||
|
@ -22,7 +22,7 @@ public static partial class Pandoc
|
|||||||
private const string DOWNLOAD_URL = "https://github.com/jgm/pandoc/releases/download";
|
private const string DOWNLOAD_URL = "https://github.com/jgm/pandoc/releases/download";
|
||||||
private const string LATEST_URL = "https://github.com/jgm/pandoc/releases/latest";
|
private const string LATEST_URL = "https://github.com/jgm/pandoc/releases/latest";
|
||||||
|
|
||||||
private static readonly ILogger LOG = Program.LOGGER_FACTORY.CreateLogger("Pandoc");
|
private static readonly ILogger LOG = Program.LOGGER_FACTORY.CreateLogger(nameof(Pandoc));
|
||||||
private static readonly Version MINIMUM_REQUIRED_VERSION = new (3, 7, 0, 2);
|
private static readonly Version MINIMUM_REQUIRED_VERSION = new (3, 7, 0, 2);
|
||||||
private static readonly Version FALLBACK_VERSION = new (3, 7, 0, 2);
|
private static readonly Version FALLBACK_VERSION = new (3, 7, 0, 2);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user