Skip to content

OpenAI.ImageRecognition.GenerateNext

Andrew Lambert edited this page Jul 14, 2024 · 4 revisions

OpenAI.ImageRecognition.GenerateNext

Method signature

 Function GenerateNext(Role As String, Content As String, Model As OpenAI.Model = Nil) As OpenAI.ImageRecognition
 Function GenerateNext(Role As String, Content As String, Images() As Picture, MaxTokens As Integer = 300, Model As OpenAI.Model = Nil) As OpenAI.ImageRecognition
 Function GenerateNext(Role As String, Content As String, Image As Picture, MaxTokens As Integer = 300, Model As OpenAI.Model = Nil) As OpenAI.ImageRecognition
 Function GenerateNext(Role As String, Content As String, ImageURLs() As String, MaxTokens As Integer = 300, Model As OpenAI.Model = Nil) As OpenAI.ImageRecognition
 Function GenerateNext(Role As String, Content As String, ImageURL As String, MaxTokens As Integer = 300, Model As OpenAI.Model = Nil) As OpenAI.ImageRecognition
 Function GenerateNext(Role As String, Content As String, Images() As FolderItem, MaxTokens As Integer = 300, Model As OpenAI.Model = Nil) As OpenAI.ImageRecognition
 Function GenerateNext(Role As String, Content As String, Image As FolderItem, MaxTokens As Integer = 300, Model As OpenAI.Model = Nil) As OpenAI.ImageRecognition

Parameters

GenerateNext(String, String, OpenAI.Model)

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-4-vision-preview is used.

GenerateNext(String, String, Picture(), Integer, OpenAI.Model)

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.
Images Picture array Two or more images to be interpreted according to the Content.
Model Model Optional. An AI model to use for the request. If not specified then gpt-4-vision-preview is used.

GenerateNext(String, String, Picture, Integer, OpenAI.Model)

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.
Images Picture An image to be interpreted according to the Content.
Model Model Optional. An AI model to use for the request. If not specified then gpt-4-vision-preview is used.

GenerateNext(String, String, String(), Integer, OpenAI.Model)

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.
ImageURLs String array Two or more images to be interpreted according to the Content.
Model Model Optional. An AI model to use for the request. If not specified then gpt-4-vision-preview is used.

GenerateNext(String, String, String, Integer, OpenAI.Model)

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.
ImageURL String An image to be interpreted according to the Content.
Model Model Optional. An AI model to use for the request. If not specified then gpt-4-vision-preview is used.

GenerateNext(String, String, FolderItem(), Integer, OpenAI.Model)

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.
Images FolderItem array Two or more images to be interpreted according to the Content.
Model Model Optional. An AI model to use for the request. If not specified then gpt-4-vision-preview is used.

GenerateNext(String, String, FolderItem, Integer, OpenAI.Model)

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.
Image FolderItem An image to be interpreted according to the Content.
Model Model Optional. An AI model to use for the request. If not specified then gpt-4-vision-preview is used.

Return value

A new instance of ImageRecognition containing the AI's reply to the message.

Remarks

Pass the user's next image recognition 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.

Example

This example demonstrates how to use this method to carry on a chat conversation:

  OpenAI.APIKey = "YOUR API KEY"
  Dim url1 As String = "https://upload.wikimedia.org/wikipedia/commons/9/99/Aerial_view_of_the_White_House.jpg"
  Dim url2 As String = "https://upload.wikimedia.org/wikipedia/commons/b/bd/Taj_Mahal%2C_Agra%2C_India_edit3.jpg"
  
  Dim response As OpenAI.ImageRecognition = OpenAI.ImageRecognition.Create("What is this a photo of?", url1)
  Dim answer As String = response.GetResult() ' This is an aerial photo of the the White House in Washington, DC.
  
  response = response.GenerateNext("user", "What direction is the camera facing?")
  answer = response.GetResult() ' The camera is facing northward.
  
  response = response.GenerateNext("user",  "Is this a picture of the same building?", url2)
  answer = response.GetResult() ' No, this is a photo of the Taj Mahal located in Agra, India.

  ' etc.
Clone this wiki locally