Agents API Reference
Overview
UOMI provides a set of high-level API functions that wrap the low-level WebAssembly calls, making it easy to develop agents without dealing with memory management and unsafe code. These functions are designed to be safe, efficient, and easy to use.
Core Functions
Logging
log(message: &str)
Logs a message to the console for debugging purposes.
pub fn log(message: &str)Example:
fn process_data() {
log("Starting data processing...");
// Process data
log("Data processing completed");
}Input/Output Operations
read_input() -> Vec<u8>
Reads the input data provided to the agent.
Example:
save_output(data: &[u8])
Saves the agent's output data.
Example:
File Operations
get_input_file_service() -> Vec<u8>
Retrieves the content of an input file.
Example:
get_cid_file_service(cid: Vec<u8>) -> Vec<u8>
Retrieves a file from IPFS using its CID.
Example:
AI Model Integration
prepare_request(body: &str) -> Vec<u8>
Prepares a request body for AI model interaction.
call_ai_service(model: i32, content: Vec<u8>) -> Vec<u8>
Calls an AI model with the prepared request. Model can be found on the Models page
Example:
Common Usage Patterns
Complete Agent Example
File Processing Example
Performance Tips
Minimize AI Calls
Use efficient prompts
Optimize Data Handling
Process data in appropriate chunks
Avoid unnecessary copies
Use efficient data structures
Smart Logging
Remove logs for production agent
Avoid logging sensitive data
Security Considerations
Remember that these functions are part of the protected API and should not be modified. They provide a safe interface to interact with the UOMI blockchain and AI capabilities.
Last updated

