The two methods in combination — getMessageHistoryContents and getMessageHistoryRoles — are used to provide the oracle with the message history necessary for the LLM call. They are called by the oracle after you invoke createLlmcall or an analogous method for other LLM providers.

The methods should each return a list, one with message contents and the other listing the roles of the message authors. The list lengths should be equal for a given callbackId.

For multimodal models such as the gpt-4-turbo, which can handle complex queries including those with image URLs, a more integrated approach is used. This is facilitated through the getMessageHistory method, which provides both the message roles and contents in a structured format suitable for processing by these models.

Try calling out gpt-4-turbo with image URl using chat_vision.ts script.

For example, if the message history is the following:

rolecontent
systemYou are a helpful assistant
userHello!
assistantHi! How can I help?
userHow big is the Sun?

Then getMessageHistoryContents should return the following list of 4 items:

[
    "You are a helpful assistant",
    "Hello!",
    "Hi! How can I help?",
    "How big is the Sun?"
]

…and getMessageHistoryRoles should return the following list of 4 items:

["system", "user", "assistant", "user"]

The signatures of these methods should be:

getMessageHistoryRoles

Arguments

callbackId
uint

The identifier you passed into the createLlmCall method.

Returns

return
string[]

A list of roles. Each role in the list is a string and one of system, user, or assistant.

getMessageHistoryContents

Arguments

callbackId
uint

The identifier you passed into the createLlmCall method.

Returns

return
string[]

A list of message contents.

getMessageHistory

For multimodal models like gpt-4-turbo, the getMessageHistory method is used to fetch a combined structure of messages, which includes both the content and the role within a single response. This method simplifies handling more complex data formats and supports enhanced features like image processing.

Arguments

callbackId
uint

The identifier you passed into the createLlmCall method.

Returns

return
IOracle.Message[]

An array of IOracle.Message, where each message structure contains:

  • role
    string
    The role of the message sender (e.g., system, user, assistant).
  • content
    IOracle.Content[]
    An array of Content, where each Content includes:
    • contentType
      string
      text or image_url, specifies whether the content is text or an image.
    • value
      string
      The actual message or image URL.