🀺Creating a new function for the general agent

General agent is an autonomous agent that is able to reason and learn from a general prompt ("Act as an autonomous agent with a goal to learn, survive and evolve") and execute transactions on-chain in order to "survive", which we define as having a xDAI balance greater than zero on the Gnosis Chain.

The agent has access to a bunch of functions, allowing it to e.g. place bets on prediction markets, retrieve its balance, search for existing markets where it can place bets, among others.

These functions are what gives the general agent "super-powers" and can in the future allow it to perform transactions on-chain that lead to a positive financial outcome.

We are always interested in expanding the set of functions available to the general agent. To create a new one, follow the steps below:

  1. Create a new function as part of the agent_functions file.

For example, this new function could be:

from microchain import Function

class ExponentiationFunction(Function):

    @property
    def description(self) -> str:
        return f"Use this function to exponentiate one number by another."

    @property
    def example_args(self) -> list[float]:
        return [1.0, 2.0]

    def __call__(self, a: float, b: float) -> str:
        return a**b
  1. Register it by editing the LEARNING_FUNCTIONS variable

  • Locate the LEARNING_FUNCTIONS list in the same file or another configuration file where functions are registered.

  • Add the ExponentiationFunction to the LEARNING_FUNCTIONS list. You can also check out the github repository here.

  1. Execute the agent with the command below

Last updated