createGroqLlmCall

This is a function that calls an open-source LLM hosted by Groq. You can configure almost any parameter that can be configured in the Create chat completion Groq endpoint.

Arguments

promptCallbackId
uint

Identifier which will be passed into the callback.

config
GroqRequest

An object that contains all configuration parameters for the LLM call. See below for details on the GroqRequest object.

Returns

counter
uint

An internal counter of the oracle, which is incremented on every call.

GroqRequest object

The GroqRequest object (see source in ChatOracle.sol) has the following fields:

model
string

The model to be used, options are llama-3.1-70b-versatile, llama-3.1-8b-instant, llama3-8b-8192, llama3-70b-8192, mixtral-8x7b-32768, or gemma-7b-it. See Groq docs for more info on the models.

frequencyPenalty
int8

Penalty for frequency, int -20 to 20, mapped to float -2.0 to 2.0. Values greater than 20 result in null.

logitBias
string

JSON string specifying logit bias, or an empty string for none.

maxTokens
uint32

Maximum number of tokens to generate, with 0 indicating null.

presencePenalty
int8

Penalty for presence, int -20 to 20, mapped to float -2.0 to 2.0. Values greater than 20 result in null.

responseFormat
string

JSON string indicating the format of the response, or an empty string for default format.

seed
uint

Seed for random number generation, with 0 indicating null.

stop
string

Stop sequence(s) for generation, or an empty string to indicate none.

temperature
uint

Temperature for generation, 0 to 20, with values greater than 20 indicating null.

topP
uint

Top p sampling parameter, 0 to 100 percentage, with values greater than 100 indicating null.

user
string

User identifier or context.

onOracleGroqLlmResponse

Called when the result of an LLM call, created with createGroqLlmCall, is available.

Arguments

callbackId
uint

The identifier you passed into the createGroqLlmCall method.

response
GroqResponse

The result of the LLM call. See below for details on the GroqResponse object.

errorMessage
string

An error message. Contains an empty string if there was no error, and a description of the error otherwise.

GroqResponse object

The GroqResponse object (see source in ChatOracle.sol) has the following fields, most of which map directly to the fields in the Groq API response:

id
string

Unique identifier for the completion, generated by Groq.

content
string

The content associated with the completion.

created
uint64

Timestamp of creation.

model
string

The model name used for the completion.

systemFingerprint
string

System identifier that generated the completion.

object
string

Type of the object, always chat.completion.

completionTokens
uint32

Number of tokens in the completion.

promptTokens
uint32

Number of tokens in the prompt.

totalTokens
uint32

Total number of tokens, sum of prompt and completion tokens.