AI721
Make AI agent indexable and verifiable on the blockchain.
Version: 0.2
Last Updated: 2024-06-15
Introduction
What is AI721
AI721 introduces a standard that extends the AI capabilities of ERC721. It's used to index AI agent on chain, describe the AI personality and copabilities of your AI agent, and verify if a specific personality belongs to a particular AI agent. This makes your AI agent become digital asset on the blockchain.
AI721 will not make any break changes on ERC721. It can be merged with ERC721, or deployed as an independent contract and associated with an existing ERC721 contract.
Yes, AI721 is essentially NFT(non-fungible token) with AI capabilities.
We call it AI-NFT for short.
Why we need AI721
LLMs enable everyone to create AI personalities with any prompt. You can create any kinds of characters with different personalities with some tools like character.ai. However, it's centralized, non-transparent, and unable to achieve consensus.
If we want to describe AI personalities in a decentralized environment , and access it without relying on any centralized 3rd parties, we need to define a standard to implement this process, ensuring that anyone can obtain the same AI personality through the same protocol.
AI721 is the key to make it happen.
How it works
In the AI721 protocol, the AI Personality of an AI-NFT is defined by these core components below:
LLM: The large language model that can comprehend and generate human language text. It provides basic AI capabilities for your AI-NFT.
Trait model: A collection-level function that inputs the AI-NFT's traits and outputs a set of prompt, defining the independent personality that is only related to its traits, as an initial state.
Memory: The memories, or knowledge that form the final AI personality, manifested through promps in conversation with the AI agent.
Public Memory: A predefined and public memory that anyone can use to form an AI personality.
Private Memory: A user-level private memory that shared with your AI agent, can be only read by the NFT owner.
Workflow: A workflow is defined as a structured sequence of operations that organizes tasks into manageable steps. Compatible with the data structure of the workflow on dify.ai.
How to describe AI Agent on chain?
AI Metadata Standard
AI721 defines a new kind of JSON metadata to describe an AI personality. The metadata standard includes three important parameters to index the AI personality. This metadata is different from the one for ERC721, and can be stored on-chain or off-chain.
Parameter | Format | Description |
---|---|---|
| URI | The uri to access LLM that is stored in off-chain storages. Check URI Format Supported. |
| string/URI | The prompt template that generates the final prompt from the traits and other storyline of AI-NFT, by using placeholders of the form |
| URI | (Optional) The uri to access the list of public memories needed to form an AI agent. The application layer can choose from these memories to create specific AI agents, like a virtual lawyer, math teacher, or virtual girlfriend/boyfriend. Check URI Format Supportedand Memory Structure. |
| URI | (Optional) The uri to access the workflow file that describes the action chain of an AI agent. |
Trait Model Example
A typical traits array from the metadata of a certain NFT is like:
We need to convert it to:
Then the trait_model
could be like:
We use Jinja2 as the templating engine for trait model.{{Base}}, {{Eyes}}, {{Mouth}}
are all placeholders in the template that will be replaced with traits.Base
, traits.Eyes
and traits.Mouth
of a specific AI-NFT.
On the application side, after you retrieve trait_model
, you can render the final prompt by filling in specific traits data with Jinja2.
Memory Structure
A single memory is described as a JSON file.
Parameter | Type | Description |
---|---|---|
| string | The name of this memory |
| string | (Optional) The description of this memory |
| string | (Optional) The logo url or the memory |
| string | The serialized form of this memory. |
Workflow Structure
A workflow is a configuration described as a JSON file.
| string | The engine that can run the workflow given by |
| number | (Optional) The engine version. |
| object | The DSL to describe the workflow of the AI agent. |
Based on this design, AI721 can support various current and future AI agent workflow protocols, and use the corresponding engines to run AI agent services.
URI Format Supported
Format | Description |
---|---|
llm://{model} | Access a given LLM by calling APIs hosted by a party. This is only applicable for For examples:
*The name must follow the naming conventions used in the API parameters provided by major model manufacturers. The application layer can determine how to access these models' API endpoints, for example, by registering a developer account at openai.com. |
ipfs://{cid} | The resources stored in IPFS/Filecoin. e.g. |
ar://{cid} | The resources stored in Arweave. e.g. |
http(s)://{domain}/{path} | An typical http(s) url to locate resources. |
... More formats from DePIN partners |
How to design a workflow
Check the section.
How to access the AI agents described by AI721?
Call
tokenURI
by tokenId of an AI721 contract, and pull the AI metadata of the NFT.Retrieve the LLM by
llm
and run as a service;Retrieve the trait model by
trait_model
. Input the traits set of the NFT to the model to obtain a set of prompt, and then integrate these prompt into the LLM you get in the previous step;(Optional) Retrieve one of the public memories from the
public_memories
, and integrate it into the LLM you get in the previous step. This allows you to quickly create a predefined AI personality.(Optional) Retrieve
workflow
and load it locally for the application layer to trigger at any time. If the workflow involves external LLMs, you can either replace them with the dedicated LLM from Step 4th or continue using the external LLM interface described by the DSL.
After these steps, you'll get your AI agent ready to use, with a pre-defined personality.
Implementing token URI of AI metadata
As what you have done for ERC721, you MUST implement tokenURI
and return a URI where we can find the metadata.
Best Practice
We recommend the application layer to firstly access AI metadata embedded in ERC721 contract to query AI personalities. If not found, then use AILinker to query.
Example
Last updated