Message history
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:
role | content |
---|---|
system | You are a helpful assistant |
user | Hello! |
assistant | Hi! How can I help? |
user | How 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
The identifier you passed into the createLlmCall
method.
Returns
A list of roles. Each role in the list is a string and one of system
, user
, or assistant
.
getMessageHistoryContents
Arguments
The identifier you passed into the createLlmCall
method.
Returns
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
The identifier you passed into the createLlmCall
method.
Returns
An array of IOracle.Message, where each message structure contains:
-
rolestringThe role of the message sender (e.g., system, user, assistant).
-
contentIOracle.Content[]An array of Content, where each Content includes:
-
contentTypestring
text
orimage_url
, specifies whether the content is text or an image. -
valuestringThe actual message or image URL.
-