-
Notifications
You must be signed in to change notification settings - Fork 37
/
IChatGptCache.cs
45 lines (40 loc) · 2.54 KB
/
IChatGptCache.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using ChatGptNet.Models;
namespace ChatGptNet;
/// <summary>
/// Represents the interface used to define the caching behavior for ChatGPT messages.
/// </summary>
public interface IChatGptCache
{
/// <summary>
/// Saves the list of messages for the given <paramref name="conversationId"/>, using the specified <paramref name="expiration"/>.
/// </summary>
/// <param name="conversationId">The unique identifier of the conversation.</param>
/// <param name="messages">The list of messages.</param>
/// <param name="expiration">The amount of time in which messages must be stored in cache.</param>
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
/// <returns>The <see cref="Task"/> corresponding to the asynchronous operation.</returns>
/// <seealso cref="ChatGptMessage"/>
Task SetAsync(Guid conversationId, IEnumerable<ChatGptMessage> messages, TimeSpan expiration, CancellationToken cancellationToken = default);
/// <summary>
/// Gets the list of messages for the given <paramref name="conversationId"/>.
/// </summary>
/// <param name="conversationId">The unique identifier of the conversation.</param>
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
/// <returns>The message list of the conversation, or <see langword="null"/> if the Conversation Id does not exist.</returns>
/// <seealso cref="ChatGptMessage"/>
Task<IEnumerable<ChatGptMessage>?> GetAsync(Guid conversationId, CancellationToken cancellationToken = default);
/// <summary>
/// Removes from the cache all the message for the given <paramref name="conversationId"/>.
/// </summary>
/// <param name="conversationId">The unique identifier of the conversation.</param>
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
/// <returns>The <see cref="Task"/> corresponding to the asynchronous operation.</returns>
Task RemoveAsync(Guid conversationId, CancellationToken cancellationToken = default);
/// <summary>
/// Gets a value that indicates whether the given conversation exists in the cache.
/// </summary>
/// <param name="conversationId">The unique identifier of the conversation.</param>
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
/// <returns>The <see cref="Task"/> corresponding to the asynchronous operation.</returns>
Task<bool> ExistsAsync(Guid conversationId, CancellationToken cancellationToken = default);
}