mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-08-11 18:32:12 +00:00
Fixed missing image capability validation after changing the model
This commit is contained in:
parent
f1bcfbc2c0
commit
007f4992ea
@ -2410,6 +2410,9 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::
|
|||||||
-- Creates a new version from the current sources and instructions while keeping the current structure and design.
|
-- Creates a new version from the current sources and instructions while keeping the current structure and design.
|
||||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2703645157"] = "Creates a new version from the current sources and instructions while keeping the current structure and design."
|
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2703645157"] = "Creates a new version from the current sources and instructions while keeping the current structure and design."
|
||||||
|
|
||||||
|
-- Images are not supported by the selected provider and model. Select a model with image support, or remove the image sources.
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2720475627"] = "Images are not supported by the selected provider and model. Select a model with image support, or remove the image sources."
|
||||||
|
|
||||||
-- Import as copy
|
-- Import as copy
|
||||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2745663129"] = "Import as copy"
|
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2745663129"] = "Import as copy"
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
using AIStudio.Provider;
|
using AIStudio.Provider;
|
||||||
|
using AIStudio.Settings;
|
||||||
|
using AIStudio.Tools.Rust;
|
||||||
|
|
||||||
using ProviderSettings = AIStudio.Settings.Provider;
|
using ProviderSettings = AIStudio.Settings.Provider;
|
||||||
|
|
||||||
@ -15,6 +17,15 @@ public partial class VisualBriefingAssistant
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
private bool HasSourceMaterial => this.selectedBriefing?.Sources.Any(source => source.Kind is VisualBriefingSourceKind.SOURCE_MATERIAL) == true;
|
private bool HasSourceMaterial => this.selectedBriefing?.Sources.Any(source => source.Kind is VisualBriefingSourceKind.SOURCE_MATERIAL) == true;
|
||||||
|
|
||||||
|
/// <summary>Gets whether any stored source reaches the model as an image.</summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Both source kinds can end up as an image: source preparation converts every visual asset into an
|
||||||
|
/// image attachment, and a source material file is attached as it is, where the attachment type is
|
||||||
|
/// derived from the file extension alone. Checking the extension therefore covers both, and it
|
||||||
|
/// matches the rule the attachment control already applies while a file is being added.
|
||||||
|
/// </remarks>
|
||||||
|
private bool HasImageSources => this.selectedBriefing?.Sources.Any(source => FileTypes.IsAllowedPath(source.Path, FileTypes.IMAGE)) == true;
|
||||||
|
|
||||||
/// <summary>Gets all current field, source, and revision issues shown below the actions.</summary>
|
/// <summary>Gets all current field, source, and revision issues shown below the actions.</summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This is the complete list for the user. The generate buttons disable themselves from the same
|
/// This is the complete list for the user. The generate buttons disable themselves from the same
|
||||||
@ -53,6 +64,12 @@ public partial class VisualBriefingAssistant
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets the issues with the stored sources, which block only the modes that read them.</summary>
|
/// <summary>Gets the issues with the stored sources, which block only the modes that read them.</summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The image check belongs here rather than to the fields, even though it depends on the selected
|
||||||
|
/// model: it only matters for the modes that hand the sources to the model at all. Changing just the
|
||||||
|
/// design reuses the stored evidence and sends no attachments, which is the same distinction the
|
||||||
|
/// build orchestrator makes before it runs source preparation.
|
||||||
|
/// </remarks>
|
||||||
private IReadOnlyList<string> SourceIssues
|
private IReadOnlyList<string> SourceIssues
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -64,6 +81,11 @@ public partial class VisualBriefingAssistant
|
|||||||
if (!this.HasSourceMaterial)
|
if (!this.HasSourceMaterial)
|
||||||
issues.Add(T("Please add at least one source material file."));
|
issues.Add(T("Please add at least one source material file."));
|
||||||
|
|
||||||
|
// A model can be selected long after the images were attached, so the capability that was
|
||||||
|
// checked while attaching them has to be checked again here:
|
||||||
|
if (this.HasImageSources && this.editor.Provider != ProviderSettings.NONE && !this.editor.Provider.SupportsImageInput())
|
||||||
|
issues.Add(T("Images are not supported by the selected provider and model. Select a model with image support, or remove the image sources."));
|
||||||
|
|
||||||
foreach (var source in this.selectedBriefing.Sources)
|
foreach (var source in this.selectedBriefing.Sources)
|
||||||
{
|
{
|
||||||
var fileName = Path.GetFileName(source.Path);
|
var fileName = Path.GetFileName(source.Path);
|
||||||
|
|||||||
@ -2412,6 +2412,9 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::
|
|||||||
-- Creates a new version from the current sources and instructions while keeping the current structure and design.
|
-- Creates a new version from the current sources and instructions while keeping the current structure and design.
|
||||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2703645157"] = "Erstellt eine neue Version aus dem aktuellen Ausgangsmaterial und Anweisungen, wobei die bestehende Struktur und das Design beibehalten werden."
|
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2703645157"] = "Erstellt eine neue Version aus dem aktuellen Ausgangsmaterial und Anweisungen, wobei die bestehende Struktur und das Design beibehalten werden."
|
||||||
|
|
||||||
|
-- Images are not supported by the selected provider and model. Select a model with image support, or remove the image sources.
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2720475627"] = "Bilder werden vom ausgewählten Anbieter und Modell nicht unterstützt. Wählen Sie ein Modell mit Bildunterstützung aus oder entfernen Sie die Bildquellen."
|
||||||
|
|
||||||
-- Import as copy
|
-- Import as copy
|
||||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2745663129"] = "Als Kopie importieren"
|
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2745663129"] = "Als Kopie importieren"
|
||||||
|
|
||||||
|
|||||||
@ -2412,6 +2412,9 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::
|
|||||||
-- Creates a new version from the current sources and instructions while keeping the current structure and design.
|
-- Creates a new version from the current sources and instructions while keeping the current structure and design.
|
||||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2703645157"] = "Creates a new version from the current sources and instructions while keeping the current structure and design."
|
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2703645157"] = "Creates a new version from the current sources and instructions while keeping the current structure and design."
|
||||||
|
|
||||||
|
-- Images are not supported by the selected provider and model. Select a model with image support, or remove the image sources.
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2720475627"] = "Images are not supported by the selected provider and model. Select a model with image support, or remove the image sources."
|
||||||
|
|
||||||
-- Import as copy
|
-- Import as copy
|
||||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2745663129"] = "Import as copy"
|
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::VISUALBRIEFING::VISUALBRIEFINGASSISTANT::T2745663129"] = "Import as copy"
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,23 @@ public static partial class ProviderExtensions
|
|||||||
return provider.CapabilityOverrides?.ApplyTo(automaticCapabilities) ?? automaticCapabilities;
|
return provider.CapabilityOverrides?.ApplyTo(automaticCapabilities) ?? automaticCapabilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get whether the model used by the configured provider accepts images as input.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Two capabilities express image input, one for a single image and one for several. Anything that
|
||||||
|
/// wants to know whether an image may be sent has to accept both, which is why the question is asked
|
||||||
|
/// here instead of at each call site: attaching a file and validating an already attached file must
|
||||||
|
/// never disagree about it.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="provider">The configured provider.</param>
|
||||||
|
/// <returns><c>true</c> when the model accepts image input.</returns>
|
||||||
|
public static bool SupportsImageInput(this Provider provider)
|
||||||
|
{
|
||||||
|
var capabilities = provider.GetModelCapabilities();
|
||||||
|
return capabilities.Contains(Capability.SINGLE_IMAGE_INPUT) || capabilities.Contains(Capability.MULTIPLE_IMAGE_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the capabilities of a model for a specific provider.
|
/// Get the capabilities of a model for a specific provider.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
using AIStudio.Provider;
|
|
||||||
using AIStudio.Settings;
|
using AIStudio.Settings;
|
||||||
using AIStudio.Tools.PluginSystem;
|
using AIStudio.Tools.PluginSystem;
|
||||||
using AIStudio.Tools.Rust;
|
using AIStudio.Tools.Rust;
|
||||||
@ -59,7 +58,6 @@ public static class FileExtensionValidation
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var capabilities = provider?.GetModelCapabilities() ?? new();
|
|
||||||
if (FileTypes.IsAllowedPath(filePath, FileTypes.IMAGE))
|
if (FileTypes.IsAllowedPath(filePath, FileTypes.IMAGE))
|
||||||
{
|
{
|
||||||
switch (useCae)
|
switch (useCae)
|
||||||
@ -76,8 +74,7 @@ public static class FileExtensionValidation
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// In this use case, we can check the provider capabilities:
|
// In this use case, we can check the provider capabilities:
|
||||||
case UseCase.ATTACHING_CONTENT when capabilities.Contains(Capability.SINGLE_IMAGE_INPUT) ||
|
case UseCase.ATTACHING_CONTENT when provider?.SupportsImageInput() is true:
|
||||||
capabilities.Contains(Capability.MULTIPLE_IMAGE_INPUT):
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// We know that images are not supported:
|
// We know that images are not supported:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user