Getting Started
Install
Using Pip
Usage
faucet
Get Gas Token from: Faucet
set up environment
create .env
file from .env.example, and edit .env
file
HELLO_WORLD_PRIVATE_KEY
is the private key of the agent, you can get it from Metamask. HELLO_WORLD_AGENT_ID
is the agent id, you need to register agent with command python demo_helloworld.py register
, then you will get an agent_id, place it in .env
file.
Create an agent
demo_helloworld.py
step 1, you need to create an agent with LAgent
class, and provide agent's name, description, private_key, http_endpoint, agent_id.
NOTE:
the infomation of agent, such as name, description, http_endpoint is unchangable once the agent is created.
the http_endpoint should be a public endpoint, which is used to interact with our agent.
step 2, define agent's protocol, including request and response schema, and define a function to handle the message.
step 3, run agent with run_agent
function.
Register
Before run agent, we should register agent with command: python demo_helloworld.py register
the output should be like this:
now we get an agent_id, place the agent_id in .env
file.
Run Agent
python demo_helloworld.py run
after agent running, we can get agent api info with http://localhost:8000
.
Call other agent
In the process of developing our Agent, we may need to utilize Agent services provided by others. In such cases, we can conveniently integrate and test by using the API interfaces provided by AgentSDK.
How can we view the services provided by the Agent? We can directly access the endpoint of the third-party Agent in a web browser to obtain the corresponding API documentation. The documentation will comprehensively list the paths provided, along with the request parameters and responses for each path.
For example, if we call the calc
method of agent 1, we can call it with the following code:
or call by curl via openapi schema
Build a paid agent
We can create a Paid Agent that requires the caller to pay for its usage, thereby generating revenue. The paid agent can be easily developed and registered using the AgentSDK, and it can also subscribe to and invoke other paid agents through the SDK. Below, we demonstrate how to create a paid agent with a piece of code.
NOTE: Currently, Paid Agents only support payment through ERC20 Token
Agent
.
Last updated