OpenAI-API-dotnet
OpenAI-API-dotnet copied to clipboard
Pass an Id or Name to continue the same conversation
Scenario 100 people are using your app and all hitting the api. After displaying a result you want to give an opportunity to allow the user carry on the conversation. I see another ChatGPT api has a way to pass in a 'conversation name';
var response = await bot.Ask("What is the weather like today?", "conversation name");
I can't see a way to pass a unique identifier to let ChatGPT know which conversation is being continued. Digging into the chat response I see an Id and Response that is returned from ChatGPT. Can we pass these back to ChatGPT a minute later to let them know the same conversation is being continued?
I may be miles off the mark here, but any ideas appreciated!
As far as I know, the API requires sending the entire conversation every time. It doesn't allow referencing a previously created chat.
A bit hacky, but as a workaround I've just been storing multiple conversation instances with a key for each in memory. Seems to work for demo purposes.
Just be sure to remove any instances that have not been used for a while.
Is this still not possible? I would also like to continue the conversation without having to reupload the entire history.
This is a wrapper around the OpenAI API. This is not for the consumer ChatGPT interface. The way the API works is you upload the entire chat for each API call. There’s no concept of saving a conversation server-side and referencing it when sending additional messages. I have included a Conversation
class as a convenience which handles this for you in memory, but it’s not meant for long-term storage. For that you’ll need to use your own database storage.
It’s possible the new OpenAI assistants API works differently, however that is not supported by this library. The new official library available as v2 beta does support it.