-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 93d4206
Showing
9 changed files
with
1,691 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Deploy Agents to Production | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download latest AVCTL release binary | ||
run: | | ||
LATEST_RELEASE_URL=$(curl -s https://api.github.com/repos/fetchai/avctl/releases/latest \ | ||
| grep browser_download_url \ | ||
| grep avctl_Linux_x86_64.tar.gz \ | ||
| cut -d '"' -f 4) | ||
curl -L -o avctl_Linux_x86_64.tar.gz $LATEST_RELEASE_URL | ||
|
||
- name: Extract binary and install | ||
run: | | ||
tar -xvf avctl_Linux_x86_64.tar.gz | ||
chmod +x avctl | ||
mv avctl /usr/local/bin/avctl | ||
- name: Authenticate with Agentverse | ||
run: avctl auth token ${{ secrets.AGENTVERSE_API_KEY }} | ||
|
||
- name: Deploy all agents | ||
run: ./scripts/deploy-agent.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
.idea | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# avctl-github-ci-example | ||
|
||
AVCTL gives you the luxury of being able to deploy your agents to the [cloud]() with simple command line instructions. We've tried created this repository as a template for you to integrate AVCTL and Github Actions to have a simple workflow of development and deployment. | ||
|
||
This repo contains two parts, deployment scripts and the agent itself. | ||
|
||
### Development | ||
|
||
It is recommended you fork this repo to build from, and this page instructions assumes you have. | ||
|
||
In our agent folder, we have a very simple Alice agent. We've initalised a poetry file too. Poetry is used to build the agent in the deployment section, we see it as beneficial too for containing our package versions. If you're unfamiliar with poetry and agent installation, check out the [docs](https://fetch.ai/docs). | ||
|
||
For more advanced agent examples, check out templates on [agentverse.ai](https://agentverse.ai) | ||
|
||
### Deployment | ||
|
||
You will need to go to agentverse.ai and create an API key and create this as an action secret in github. | ||
|
||
Our action is set to run on pushes to main, this works for simplicity but it is recommended you update the workflow to only run on merges into a branch like `release/production`, one which has appropriate branch protection rules. | ||
|
||
If you make a change to your agent and push, you'll see the workflow run. | ||
|
||
|
||
### Agent private keys & addresses | ||
|
||
Agents identified by addresses derived from private keys. When building and deploying agents on agentverse, agentverse will create your private key and address for you. To learn more about agent addresses and seeds, please visit the [fetch.ai/docs](https://fetch.ai/docs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[agent] | ||
address = "agent1qfx5mmewjs4x9ysyxemsaxv6empds4mmpx4sav84yagmhed5yczdwtqkcxu" | ||
include = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# ALICE from terminator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Import necessary classes from the uAgents library | ||
from uagents import Agent, Context | ||
|
||
# Create an agent named alice | ||
agent = Agent( | ||
name="alice from the future", | ||
port=8001, | ||
seed="eubrpq3ibrfpiebrpivqepirvpierbvpiberpb" | ||
) | ||
|
||
|
||
# Function to be called when the agent is started | ||
@agent.on_event("startup") | ||
async def introduce_agent(ctx: Context): | ||
# Print a greeting message with the agent's name and its address | ||
print(f"Hello, I'm agent {agent.name} and my address is {agent.address}.") | ||
|
||
|
||
# Run the agent only when the script is executed directly | ||
if __name__ == "__main__": | ||
agent.run() |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[tool.poetry] | ||
name = "agent" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["None"] | ||
readme = "README.md" | ||
|
||
[tool.poetry.dependencies] | ||
python = "3.11" | ||
uagents = "^0.17.1" | ||
|
||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Define the function | ||
get_agent_address() { | ||
local file=".avctl/config.toml " | ||
|
||
# Check if the file exists | ||
if [ -f "$file" ]; then | ||
# Extract the address value | ||
agent_address=$(grep 'address =' "$file" | sed -E 's/.*= "(.*)"/\1/') | ||
|
||
# Check if the address is not empty | ||
if [ -n "$agent_address" ]; then | ||
echo $agent_address | ||
else | ||
echo "" | ||
fi | ||
else | ||
echo "" | ||
fi | ||
} | ||
|
||
# Define the specific directory to work on | ||
defined_directory="agent/" | ||
|
||
# Change to the specified agent directory | ||
cd "$defined_directory" | ||
|
||
# Create a .staging.avctl folder for new agents if it doesn't exist | ||
avctl hosting init | ||
|
||
# get the agent address if it exists | ||
agent_address=$(get_agent_address) | ||
|
||
# Get the agent's name from the README.md top line header | ||
agent_name=$(head -n 1 README.md | sed -e 's/#//g' | xargs) | ||
|
||
|
||
# If the address exists... | ||
if [ -n "$agent_address" ]; then | ||
avctl hosting get agent -a "$agent_address" | ||
response=$(avctl hosting get agent -a "$agent_address")\ | ||
|
||
# Check if the agent is already in existence, if it isn't, deploy as new, else sync. | ||
if [ $? -eq 0 ]; then | ||
avctl hosting stop -a "$agent_address" | ||
avctl hosting sync -a "$agent_address" | ||
else | ||
avctl hosting deploy -n "$agent_name" --no-dependency-check || true | ||
fi | ||
# Agent doesn't exist, so let's deploy | ||
else | ||
avctl hosting deploy -n "$agent_name" --no-dependency-check || true | ||
fi |