Warning
This agent is for demonstration purposes only and is not suitable for production use.
This is an example of a lightweight social agent, with minimal dependencies. Aligned with Sentient's mission, the agent is designed to be easily extensible and it is open to community contributions. Create an issue to ask a question or open a PR to add a feature!
For now the only platforms that are supported by the agent are X (Twitter) and Discord. We're going to continuously work on this agent. If there is a tool or platform that you would like to see supported, please create an issue or, better yet, get coding and open a PR! Telegram support is the next feature in the pipeline. We also plan to add tools to support more sophisticated features, such as data sources and on-chain functionality.
- Supports any OpenAI API compatible LLM endpoint
- Supports X (Twitter)
- Supports Discord
- Telegram is coming soon...
- Data is coming soon...
- Web3 is coming soon...
Note
These instructions are for unix-based systems (i.e. MacOS, Linux). Before you proceed, make sure that you have installed python and pip. If you have not, follow these instructions to do so.
Create the .env file by copying the contents of .env.example. This is where you will store all of your agent's credentials.
cp .env.example .env
Add your Fireworks API key to the .env file (you can also use any other OpenAI compatible inference provider).
In order to interact with the X (Twitter) API, your agent needs developer credentials from the X (Twitter) developer portal here.
From the Dashboard page, click on the gear icon to access the Settings page for your default project.
Set the user authentication settings for your app as follows:
- App permissions: "Read and write"
- Type of App: "Web App, Automated App or Bot"
- Callback URI / Redirect URL: http://localhost:8000
- Website URL: http://example.com
Generate all of the required credentials on the Keys and tokens page. Add them to the .env file.
Before you can build a Discord bot you need to create it in the Discord Developer Portal. Follow the steps in the Creating an App part of this guide and add your token to the .env file.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python3 -m src.agent.agent_tools.model
Expected output:
Connecting to model...
To exit just type 'exit' and press enter.
Query model:
python3 -m src.agent.agent_tools.twitter
Expected output:
Connecting to twitter...
Connected to twitter user <USERNAME> with id <USER_ID>.
python3 -m src.agent.agent_tools.discord
Expected output:
Connecting to discord...
Connected to discord bot <USERNAME> with id <USER_ID>.
python3 -m src.agent
Expected output (if you have added a key user in twitter_config and you have enabled Twitter and Discord in agent_config):
INFO: Agent starting up...
INFO: Twitter client starting up...
INFO: Connected to twitter user <USERNAME> with id <USER_ID>.
INFO: Discord client starting up...
WARNING: PyNaCl is not installed, voice will NOT be supported
INFO: Connected to discord bot <USERNAME> with id <USER_ID>.
You can enable and disable tools in the agent_config module in the agent package. Each tool can be configured using its configuration module that is located in the tool's directory in the agent_tools directory. Each tool also has its own README file that describes its configuration options.
The agent class will automatically discover and initialize tools that are in the agent_tools directory. However, you need to follow these conventions when adding a new tool:
- Each tool must have a corresponding
<TOOL_NAME>_ENABLEDboolean flag in theagent_configmodule. - Each tool must have its own directory within
agent_tools. - Each tool must have a main module that is named
<tool_name>.py.- Within the main module, the main class name must be the capitalized version of the directory name.
- The main class must have an
__init__method that will be called when the tool is initialized.- The
__init__method should take the secrets and the model as arguments. - Each secret should be stored in the
.envfile and named<TOOL_NAME>_<SECRET_NAME>where<SECRET_NAME>is the name of the corresponding argument in the__init__method.
- The
- The main class must have a
runmethod that will be called when the tool is run.
- Each tool must have a configuration module that is named
<tool_name>_config.py.- The configuration module must have a
<Tool_name>Configclass.
- The configuration module must have a
- Each tool must have a README file that describes the configuration options.
- If you install a new package, you must update the
requirements.txtfile:pip freeze > requirements.txt
For example, consider the twitter tool:
- There is a
TWITTER_ENABLEDboolean flag in theagent_configmodule. - There is a twitter directory in
agent_tools. - There is a main module
twitter.py.- There is a
Twitterclass intwitter.py. - The
Twitterclass has an__init__method that takes the secrets and the model as arguments. The secrets are stored in the.envfile and are prefixed withTWITTER_.consumer_keycorresponds to theTWITTER_CONSUMER_KEYenvironment variable.consumer_secretcorresponds to theTWITTER_CONSUMER_SECRETenvironment variable.access_tokencorresponds to theTWITTER_ACCESS_TOKENenvironment variable.access_token_secretcorresponds to theTWITTER_ACCESS_TOKEN_SECRETenvironment variable.bearer_tokencorresponds to theTWITTER_BEARER_TOKENenvironment variable.
- The
Twitterclass has arunmethod that is called to run the tool.
- There is a
- There is a configuration module
twitter_config.py.- There is a
TwitterConfigclass intwitter_config.py.
- There is a
- There is a README file
twitter/README.mdthat describes the configuration options.
