BotSharp/src/Infrastructure/BotSharp.Abstraction/Files/IBotSharpFileService.cs

79 lines
3.6 KiB
C#
Raw Normal View History

2024-05-06 06:51:59 +00:00
namespace BotSharp.Abstraction.Files;
2023-11-09 21:11:36 +00:00
2024-05-06 06:51:59 +00:00
public interface IBotSharpFileService
2023-11-09 21:11:36 +00:00
{
2024-07-18 20:17:40 +00:00
#region Conversation
2024-07-17 19:28:29 +00:00
/// <summary>
/// Get the files that have been uploaded in the chat.
/// If includeScreenShot is true, it will take the screenshots of non-image files, such as pdf, and return the screenshots instead of the original file.
/// </summary>
/// <param name="conversationId"></param>
/// <param name="source"></param>
/// <param name="conversations"></param>
/// <param name="contentTypes"></param>
/// <param name="includeScreenShot"></param>
/// <param name="offset"></param>
/// <returns></returns>
Task<IEnumerable<MessageFileModel>> GetChatFiles(string conversationId, string source,
2024-07-16 22:09:54 +00:00
IEnumerable<RoleDialogModel> conversations, IEnumerable<string> contentTypes,
bool includeScreenShot = false, int? offset = null);
2024-07-17 19:28:29 +00:00
2024-07-18 20:17:40 +00:00
/// <summary>
/// Get the files that have been uploaded in the chat. No screenshot images are included.
/// </summary>
/// <param name="conversationId"></param>
/// <param name="messageIds"></param>
/// <param name="source"></param>
/// <param name="imageOnly"></param>
/// <returns></returns>
2024-06-06 19:57:41 +00:00
IEnumerable<MessageFileModel> GetMessageFiles(string conversationId, IEnumerable<string> messageIds, string source, bool imageOnly = false);
string GetMessageFile(string conversationId, string messageId, string source, string index, string fileName);
2024-07-08 22:37:22 +00:00
IEnumerable<MessageFileModel> GetMessagesWithFile(string conversationId, IEnumerable<string> messageIds);
2024-06-06 19:57:41 +00:00
bool SaveMessageFiles(string conversationId, string messageId, string source, List<BotSharpFile> files);
2024-05-22 04:33:31 +00:00
2024-05-06 22:31:52 +00:00
/// <summary>
/// Delete files under messages
/// </summary>
/// <param name="conversationId">Conversation Id</param>
/// <param name="messageIds">Files in these messages will be deleted</param>
/// <param name="targetMessageId">The starting message to delete</param>
/// <param name="newMessageId">If not null, delete messages while input a new message; otherwise, delete messages only</param>
/// <returns></returns>
bool DeleteMessageFiles(string conversationId, IEnumerable<string> messageIds, string targetMessageId, string? newMessageId = null);
bool DeleteConversationFiles(IEnumerable<string> conversationIds);
2024-07-18 20:17:40 +00:00
#endregion
#region Image
2024-07-18 22:07:14 +00:00
Task<RoleDialogModel> GenerateImage(string? provider, string? model, string text);
2024-07-19 17:01:07 +00:00
Task<RoleDialogModel> VaryImage(string? provider, string? model, BotSharpFile image);
Task<RoleDialogModel> EditImage(string? provider, string? model, string text, BotSharpFile image);
Task<RoleDialogModel> EditImage(string? provider, string? model, string text, BotSharpFile image, BotSharpFile mask);
2024-07-18 20:17:40 +00:00
#endregion
#region Pdf
2024-07-01 19:31:48 +00:00
/// <summary>
/// Take screenshots of pdf pages and get response from llm
/// </summary>
/// <param name="prompt"></param>
/// <param name="files">Pdf files</param>
/// <returns></returns>
2024-07-18 22:07:14 +00:00
Task<string> ReadPdf(string? provider, string? model, string? modelId, string prompt, List<BotSharpFile> files);
2024-07-18 20:17:40 +00:00
#endregion
#region User
string GetUserAvatar();
bool SaveUserAvatar(BotSharpFile file);
#endregion
2024-07-01 19:31:48 +00:00
2024-07-18 20:17:40 +00:00
#region Common
2024-05-14 16:51:39 +00:00
/// <summary>
/// Get file bytes and content type from data, e.g., "data:image/png;base64,aaaaaaaaa"
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
(string, byte[]) GetFileInfoFromData(string data);
2024-07-18 20:17:40 +00:00
string GetDirectory(string conversationId);
2024-06-26 03:38:01 +00:00
string GetFileContentType(string filePath);
2024-07-18 20:17:40 +00:00
#endregion
2023-11-09 21:11:36 +00:00
}