-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
361 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace ChatGptNet; | ||
|
||
/// <inheritdoc/> | ||
public class ChatGptBuilder : IChatGptBuilder | ||
{ | ||
/// <inheritdoc/> | ||
public IServiceCollection Services { get; } | ||
|
||
/// <inheritdoc/> | ||
public IHttpClientBuilder HttpClientBuilder { get; } | ||
|
||
internal ChatGptBuilder(IServiceCollection services, IHttpClientBuilder httpClientBuilder) | ||
{ | ||
Services = services; | ||
HttpClientBuilder = httpClientBuilder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using ChatGptNet.Models; | ||
using Microsoft.Extensions.Caching.Memory; | ||
|
||
namespace ChatGptNet; | ||
|
||
internal class ChatGptMemoryCache : IChatGptCache | ||
{ | ||
private readonly IMemoryCache cache; | ||
|
||
public ChatGptMemoryCache(IMemoryCache cache) | ||
{ | ||
this.cache = cache; | ||
} | ||
|
||
public Task SetAsync(Guid conversationId, IEnumerable<ChatGptMessage> messages, TimeSpan expiration) | ||
{ | ||
cache.Set(conversationId, messages, expiration); | ||
return Task.CompletedTask; | ||
} | ||
|
||
public Task<List<ChatGptMessage>?> GetAsync(Guid conversationId) | ||
{ | ||
var messages = cache.Get<List<ChatGptMessage>?>(conversationId); | ||
return Task.FromResult(messages); | ||
} | ||
|
||
public Task RemoveAsync(Guid conversationId) | ||
{ | ||
cache.Remove(conversationId); | ||
return Task.CompletedTask; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.