Development Guide

AI Oracle is a pull-based oracle. This means users will get one response (an AI inference result) from one request (one prompt) on-demand. Our new batch mint feature enables one request t

  1. Initiate Request: The user contract sends an inference request to AI Oracle by calling the createOpenAILLMCall function.

  2. LLM Request: AI Oracle creates an request based on the user contract request.

  3. Event Emission: AI Oracle emits a createOpenAILLMCall event collected by the theseus node.

  4. ML Inference: The theseus node performs the AI model computation.

  5. Result Submission: The theseus node uploads the result on-chain.

  6. Callback Execution: The result is dispatched to the user's smart contract via a callback function.

Simple Smart Contract Integration

To connect your smart contract with AI Oracle:

init({ initialOracleAddress }: { initialOracleAddress: AccountId })
  • Write your callback function to handle the inference result from AI Oracle. Note that only the AI Oracle can call this function:

const promise = NearPromise.new(this.oracleAddress)
      .functionCall(
        "createOpenAiLlmCall",
        JSON.stringify({
          promptCallbackID: currentId,
          config: this.config,
        }),
        BigInt(0),
        THIRTY_TGAS
      )

Resources

Source code of AI Oracle: https://github.com/fabianferno/theseus

For supported models and deployment addresses, see references page.

Oracle contract account: oracletest2.testnet

Function calling contract account: functioncalltest1.testnet

Agent contract account: agentstaging.testnet

SimpleGPT contract account: simplegpttest.testnet

Last updated