IConnectorGenerativeIA.cs•2.88 kB
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
namespace Api.DigitalPages.Interfaces.Connector
{
public interface IConnectorGenerativeIA : ISystemContextRequired
{
/// <summary>
/// Responde uma pergunta efetuada pelo usuário
/// </summary>
/// <param name="question">Pergunta do usuário</param>
/// <param name="restrictContext">Indicador se deve restringir o contexto da resposta</param>
/// <returns></returns>
IAsyncEnumerable<string> Answer(string question, string responseMimeType = "text/plain");
IAsyncEnumerable<string> Answer(List<IAContent> contents, string responseMimeType = "text/plain");
/// <summary>
/// Traduz um conteúdo.
/// </summary>
/// <param name="content"></param>
/// <returns></returns>
IAsyncEnumerable<string> Translate(string content);
/// <summary>
/// Gera uma imagem com base em uma descrição.
/// </summary>
/// <param name="description"></param>
/// <returns></returns>
Task<Stream> Image(string description);
/// <summary>
/// Registra um cache de conteúdo para ser utilizado posteriormente pela IA
/// </summary>
/// <param name="contents"></param>
/// <param name="expireAt"></param>
/// <returns></returns>
Task<IACacheReference> RegisterCache(List<IAContent> contents, string key, DateTime expireAt);
/// <summary>
/// Remove conteudo cacheado.
/// </summary>
/// <param name="cacheId"></param>
/// <returns></returns>
Task<bool> UnregisterCache(string cacheId);
}
public interface IAContent
{
IARole Role { get; set; }
}
public interface IIACacheContent : IAContent
{
public string CacheId { get; set; }
}
public interface IIATextContent : IAContent
{
public string Content { get; set; }
}
public interface IIAStreamContent : IAContent
{
public Stream Content { get; set; }
public string MimeType { get; set; }
}
public enum IARole
{
System,
User
}
public class IATextContent : IIATextContent
{
public string Content { get; set; }
public IARole Role { get; set; }
}
public class IAStreamContent : IIAStreamContent
{
public Stream Content { get; set; }
public string MimeType { get; set; }
public IARole Role { get; set; }
}
public class IACacheContent : IIACacheContent
{
public string CacheId { get; set; }
public IARole Role { get; set; }
}
public class IACacheReference
{
public string Id { get; set; }
public DateTime ExpireAt { get; set; }
}
}