mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-09-02 22:02:56 +00:00
Some checks are pending
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 / 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 / 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
Co-authored-by: Thorsten Sommer <mail@tsommer.org>
68 lines
2.2 KiB
C#
68 lines
2.2 KiB
C#
using System.Text.Json.Serialization;
|
|
|
|
using AIStudio.Provider;
|
|
|
|
namespace AIStudio.Chat;
|
|
|
|
/// <summary>
|
|
/// The interface for any content in the chat.
|
|
/// </summary>
|
|
[JsonDerivedType(typeof(ContentText), typeDiscriminator: "text")]
|
|
[JsonDerivedType(typeof(ContentImage), typeDiscriminator: "image")]
|
|
public interface IContent
|
|
{
|
|
/// <summary>
|
|
/// Do we need to wait for the remote, i.e., the AI, to process the related request?
|
|
/// Does not indicate that the stream is finished; it only indicates that we are
|
|
/// waiting for the first response, i.e., wait for the remote to pick up the request.
|
|
/// </summary>
|
|
[JsonIgnore]
|
|
public bool InitialRemoteWait { get; set; }
|
|
|
|
/// <summary>
|
|
/// Indicates whether the content is streaming right now. False, if the content is
|
|
/// either static or the stream has finished.
|
|
/// </summary>
|
|
[JsonIgnore]
|
|
public bool IsStreaming { get; set; }
|
|
|
|
/// <summary>
|
|
/// An action that is called when the content was changed during streaming.
|
|
/// </summary>
|
|
[JsonIgnore]
|
|
public Func<Task> StreamingEvent { get; set; }
|
|
|
|
/// <summary>
|
|
/// An action that is called when the streaming is done.
|
|
/// </summary>
|
|
[JsonIgnore]
|
|
public Func<Task> StreamingDone { get; set; }
|
|
|
|
/// <summary>
|
|
/// The provided sources, if any.
|
|
/// </summary>
|
|
[JsonIgnore]
|
|
public List<Source> Sources { get; set; }
|
|
|
|
/// <summary>
|
|
/// Uses the provider to create the content.
|
|
/// </summary>
|
|
public Task<ChatThread> CreateFromProviderAsync(IProvider provider, Model chatModel, IContent? lastPrompt, ChatThread? chatChatThread, CancellationToken token = default);
|
|
|
|
/// <summary>
|
|
/// Creates a deep copy
|
|
/// </summary>
|
|
/// <returns>The copy</returns>
|
|
public IContent DeepClone();
|
|
|
|
/// <summary>
|
|
/// Returns the corresponding ERI content type.
|
|
/// </summary>
|
|
public Tools.ERIClient.DataModel.ContentType ToERIContentType => this switch
|
|
{
|
|
ContentText => Tools.ERIClient.DataModel.ContentType.TEXT,
|
|
ContentImage => Tools.ERIClient.DataModel.ContentType.IMAGE,
|
|
|
|
_ => Tools.ERIClient.DataModel.ContentType.UNKNOWN,
|
|
};
|
|
} |