-
-
Notifications
You must be signed in to change notification settings - Fork 7
OpenAI.ChatCompletion.GenerateNext
Andrew Lambert edited this page Jul 14, 2024
·
6 revisions
OpenAI.ChatCompletion.GenerateNext
Function GenerateNext(Role As String, Content As String, Model As OpenAI.Model = Nil) As OpenAI.ChatCompletion
Name | Type | Comment |
---|---|---|
Role | String | One of "user", "assistant", or "system", identifying the speaker of the message. |
Content | String | The message that the speaker is sending to the chat. |
Model | Model | Optional. An AI model to use for the request. If not specified then gpt-3.5-turbo is used. |
A new instance of ChatCompletion
containing the AI's reply to the message.
Pass the user's next chat message to generate the AI assistant's reply to that message. The AI is provided with a complete transcript of the chat so far to give it the necessary context.
This example demonstrates how to use this method to carry on a chat conversation:
OpenAI.APIKey = "YOUR API KEY"
Dim reply As OpenAI.ChatCompletion = OpenAI.ChatCompletion.Create("user", "Hello, I've come here looking for an argument.")
Dim chatresult As String = reply.GetResult() ' assistant: No you haven't!
reply = reply.GenerateNext("user", "Yes I have!")
chatresult = reply.GetResult() ' assistant: Sorry, is this the 5 minute argument, or the whole half hour?
reply = reply.GenerateNext("user", "What?")
chatresult = reply.GetResult() ' assistant: Are you here for the whole half hour?
'etc.
Wiki home | Project page | Bugs | Become a sponsor
Text and code examples are Copyright ©2023-24 Andrew Lambert, offered under the CC BY-SA 3.0 License.