Agentverse: allowed imports

Agentverse: allowed imports


In the Agentverse ↗️ (opens in a new tab) code editor, you have the freedom to import and utilize a selected set of modules to create your code, while maintaining security and control. These pre-approved modules offer a diverse range of functionalities, allowing you to build complex agents.

The modules available on the Agentverse are:

Allowed imports


Build fast and lightweight AI Agents for decentralized scenarios using the uagents Framework. Checkout the AI Agents ↗ documentation and the uagents package ↗️ (opens in a new tab) for more information.

  • Available classes: Model, Context, Protocol.


    from uagents import Context, Model
    class Message(Model):
        text: str
    async def print_message(ctx: Context):
        msg = Message(text=f"Hello there my wallet address is {ctx.wallet}.")


Simply interact with JSON data structures. This package provides functionality for encoding and decoding JSON (JavaScript Object Notation) data.

  • Available functions: dumps, loads.


    import json
    some_json =  '{ "agent":"Alice", "age":"1 day"}'
    # JSON to python dictionary
    python_dict = json.loads(some_json)
    # python dictionary to JSON:
    some_json_2 = json.dumps(python_dict)
    # the result is a JSON string equal to some_json:


This package allows you to interact with HTTP requests and responses.

  • Available functions: get, post, put, patch, delete.


    import requests
    response = requests.get('')
    if response.status_code == 200:
    elif response.status_code == 404:
        print('Not Found.')


A Python library for interacting with Cosmos-based blockchains. Checkout the CosmPy ↗️ documentation and the CosmPy package ↗️ (opens in a new tab)for more information.

  • Full access to all functions and features.


    from cosmpy import aerial
    # Define network configuration, faucet and ledger
    network = aerial.client.NetworkConfig.fetchai_stable_testnet()
    faucet_api = aerial.faucet.FaucetApi(network)
    ledger = aerial.client.LedgerClient(network)
    MINIMUM_BALANCE = 100000000000000000
    async def get_tokens(ctx: Context):
        agent_balance = ledger.query_bank_balance(ctx.wallet)
        if agent_balance < MINIMUM_BALANCE:
            print("Providing wealth to agent...")


A library allowing you to handle date and time operations with ease.

  • Full access to all functions and features.


    import datetime
    today =
    print(f"Today is: {today.year}:{today.month}:{}")


A library to create enumerations with symbolic names and unique values.

  • Full access to all functions and features.


    from enum import Enum
    class Agent(Enum):
        alice = 1
        bob = 2
        carl = 3


A package to ensure data validation and settings management. It simplifies the process of defining and validating data models by providing a way to declare and enforce data types, constraints, and validation rules on Python data structures.

  • Full access to all functions and features.


    from pydantic import BaseModel
    data = {
        "name": "alice",
        "age": 21
    class User(BaseModel):
        name: str
        age: int
    user = User(**data)


A library that provides access to various mathematical functions and constants for performing mathematical operations.

  • Full access to all functions and features.


    import math
    # Basic mathematical operations
    print(math.sqrt(25))  # Output: 5.0
    print(math.pow(2, 3))  # Output: 8.0
    # Trigonometric functions
    print(math.cos(0))  # Output: 1.0
    # Logarithmic and exponential functions
    print(math.log(10))  # Output: 2.302585092994046


This provides functions for working with time-related functions, including time measurement, manipulation, and conversions. It allows Python programs to handle time expressions, perform time-related calculations, and work with time values in different formats.

  • Full access to all functions and features.


    import time
    current_time = time.strftime("%H:%M:%S")  # Get the current time in HH:MM:SS format
    print("Current time is:", current_time)


It stands for "Universally Unique Identifier". It is a Python library used for generating universally unique identifiers based on various algorithms. These identifiers are unique across space and time, making them highly suitable for various purposes where uniqueness is essential, such as database keys, identifiers in distributed systems, and more.

  • Full access to all functions and features.


    import uuid
    # Generating a version 4 (random) UUID
    unique_id = uuid.uuid4()


Integrate AI Agents with the AI Engine to perform a wide variety tasks, including in booking services, make reservations, and provide answers to different queries. Checkout the AI Engine ↗️ documentation and the AI Engine package ↗️ (opens in a new tab) for further information.

  • Full access to all functions and features.


    from uagents import Context, Model, Protocol
    from ai_engine import UAgentResponse, UAgentResponseType
    simples = Protocol(name="simples", version="v1.1")
    class Request(Model):
        message: str
    @simples.on_message(model=Request, replies={UAgentResponse})
    async def handle_message(ctx: Context, sender: str, msg: Request):
        await ctx.send(sender, UAgentResponse(message="0", type=UAgentResponseType.FINAL))


This package is used for generating random numbers, managing random selections, and handling random data. It provides various functions for generating random values, shuffling sequences, and making random selections.

  • Full access to all functions and features.


    # Generate a random integer within a specified range
    random_integer = random.randint(1, 10)
    print(random_integer)  # Output: (any integer between 1 and 10)
    # Shuffle a list
    my_list = [1, 2, 3, 4, 5]
    print(my_list)  # Output: [3, 1, 4, 5, 2] (shuffled list)
    # Select a random item from a list
    my_item = random.choice(my_list)
    print(my_item)  # Output: (any element from the list)

Multi-file Support

The Agentverse Code Editor enhances your agent development experience with multi-file support, enabling you to tackle complex projects with ease. Leverage this feature to:

  • Interact between files: simply import functions, classes, and variables from one file to another.
  • Modular development: divide your projects into manageable components for streamlined creation.
  • Code reuse: utilize modules across various sections of your project for efficient development.
  • Enhanced organization: maintain a structured and organized codebase for easier maintenance.

If you want to create new files you just need to click on + New File on Agentverse ↗️ (opens in a new tab) inside your managed agent.

You can create a Python message file with the following Model class:

from uagents import Model
class Sentence(Model):
    text: str

Then, you can just import the Sentence data model to your file and make use of it:

from uagents import Context
from message import Sentence
async def print_message(ctx: Context):
    msg = Sentence(text=f"Hello there my wallet address is {ctx.wallet}.")

Explore the Agentverse guides ↗️ and Agentverse concepts ↗️ for additional guides and documentation resources!

Was this page helpful?