![]() ![]() Response = await _chatService.GetNextMessageResponse(_prompt) Var chatService = await chatGpt.ContinueOrStartNewTopic() Public YourService(ChatGPTFactory chatGptFactory)ĬhatGPT chatGpt = await _chatGptFactory.Create(userId) Private readonly ChatGPTFactory _chatGptFactory Inject ChatGPTFactory to your service and use it to create ChatGPT instance:.Instead of options.UseSqlite("Data Source=chats.db") use your own db and connection string. ![]() Options => options.UseSqlite("Data Source=chats.db")) Add ChatGPT integration with EF to your DI container:ī(.Set the OpenAI API key or even host (optional) in your project user secrets, or the appsettings.json file (not safe):Īlso, you can specify OpenAI API key as environment variable ASPNETCORE_OpenAICredentials:ApiKey. ![]() If you don't want to use EF Core, you can install the package and implement your own storage for chat history, using IChatHistoryStorage interface. NET project with DI and persistence (EF Core) supporting is to install the NuGet package : Install-Package The easiest way to use ChatGPT service in your.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |