Skip to content

Commit 2308980

Browse files
authored
Merge pull request #125 from blorm-network/goatBrain
Goat brain
2 parents dd6b8f2 + 5604850 commit 2308980

17 files changed

+2645
-673
lines changed

.dockerignore

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
**/.DS_Store
2+
**/__pycache__
3+
**/.venv
4+
**/.classpath
5+
**/.dockerignore
6+
**/.env
7+
**/.git
8+
**/.gitignore
9+
**/.project
10+
**/.settings
11+
**/.toolstarget
12+
**/.vs
13+
**/.vscode
14+
**/*.*proj.user
15+
**/*.dbmdl
16+
**/*.jfm
17+
**/bin
18+
**/charts
19+
**/docker-compose*
20+
**/compose.y*ml
21+
**/Dockerfile*
22+
**/node_modules
23+
**/npm-debug.log
24+
**/obj
25+
**/secrets.dev.yaml
26+
**/values.dev.yaml
27+
LICENSE
28+
README.md
29+
**/agents

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@ agents/*.json
1717

1818
# macOS
1919
.DS_Store
20-
.codegpt
20+
.codegpt
21+
22+
venv
23+
.mypy_cache

Dockerfile

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FROM python:3.11-slim
2+
3+
# Set environment variables
4+
ENV PYTHONUNBUFFERED=1 \
5+
PYTHONFAULTHANDLER=1 \
6+
PYTHONHASHSEED=random \
7+
PIP_NO_CACHE_DIR=off \
8+
PIP_DISABLE_PIP_VERSION_CHECK=on \
9+
PIP_DEFAULT_TIMEOUT=100
10+
11+
# Install system dependencies
12+
RUN apt-get update && apt-get install -y \
13+
curl \
14+
build-essential \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
# Install Poetry
18+
RUN curl -sSL https://install.python-poetry.org | python3 -
19+
20+
# Add Poetry to PATH
21+
ENV PATH="/root/.local/bin:$PATH"
22+
23+
# Verify Poetry installation
24+
RUN poetry --version
25+
26+
# Set working directory
27+
WORKDIR /app
28+
29+
# Copy Poetry files
30+
COPY pyproject.toml /app/
31+
32+
# Install dependencies
33+
RUN poetry config virtualenvs.create false \
34+
&& poetry lock && poetry install --no-root --extras server
35+
36+
# Copy application code
37+
COPY . /app/
38+
39+
# Expose port
40+
EXPOSE 8000
41+
42+
# Set dstack simulator endpoint
43+
ENV DSTACK_SIMULATOR_ENDPOINT="http://tappd:8090"
44+
45+
# Command to run the application using app.py
46+
CMD ["poetry", "run", "python", "main.py", "--server"]

agents/example.json

+13-5
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,21 @@
6767
{
6868
"name": "coingecko",
6969
"args": {
70-
"api_key": "YOUR_API_KEY"
70+
"api_key": "CG-12BeZ64iSajBLPPz8mfX4uao"
7171
}
7272
},
7373
{
7474
"name": "erc20",
7575
"args": {
7676
"tokens": ["goat_plugins.erc20.token.PEPE", "goat_plugins.erc20.token.USDC"]
7777
}
78+
},
79+
{
80+
"name": "uniswap",
81+
"args": {
82+
"api_key": "KUt2OUR7oT6zpUvoly6Cp4FUwLCtkiZP16fhKW3x",
83+
"base_url": "https://trade-api.gateway.uniswap.org/v1"
84+
}
7885
}
7986
]
8087
},
@@ -83,10 +90,6 @@
8390
"model": "llama-3.3-70b-versatile",
8491
"temperature": 0.5
8592
},
86-
{
87-
"name": "hyperbolic",
88-
"model": "meta-llama/Meta-Llama-3-70B-Instruct"
89-
},
9093
{
9194
"name": "galadriel",
9295
"model": "gpt-3.5-turbo"
@@ -109,6 +112,11 @@
109112
"message_read_count": 10,
110113
"message_emoji_name": "❤️",
111114
"server_id": "1234567890"
115+
},
116+
{
117+
"name": "brain",
118+
"model": "claude-3-5-sonnet-20241022",
119+
"provider": "anthropic"
112120
}
113121
],
114122
"tasks": [

brain_script.py

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
from src.connections.brain_connection import BrainConnection
2+
from dotenv import load_dotenv
3+
import json
4+
import logging
5+
6+
load_dotenv()
7+
8+
def load_agent_config(agent_name: str = "example") -> dict:
9+
"""Load agent configuration from JSON file"""
10+
try:
11+
with open(f"agents/{agent_name}.json", "r") as f:
12+
config = json.load(f)
13+
14+
# Extract brain configuration
15+
brain_config = next((c for c in config["config"] if c["name"] == "brain"), None)
16+
17+
if not brain_config:
18+
raise ValueError("Missing required brain configuration")
19+
20+
return brain_config
21+
22+
except Exception as e:
23+
raise Exception(f"Failed to load agent config: {e}")
24+
25+
def test_brain(agent_name: str = "example"):
26+
"""Test brain functionality with configuration from agent file"""
27+
try:
28+
# Load brain configuration
29+
brain_config = load_agent_config(agent_name)
30+
31+
# Initialize and configure Brain connection
32+
brain_connection = BrainConnection(brain_config)
33+
if not brain_connection.configure():
34+
print("Failed to configure Brain connection")
35+
return
36+
37+
# Test commands
38+
test_commands = [
39+
# "what's my wallet address",
40+
# "get me info about bitcoin",
41+
# "check my eth balance",
42+
# "what actions can you do",
43+
# "help me swap 2 usdc for MOG",
44+
"swap 1 million mog for usdc"
45+
# "what is proof of history"
46+
# "can you automatically set chain parameters based on what network you see logged in via rpc when i make a uniswap call?",
47+
# "help me swap eth for 1 usdc"
48+
# "if minorities only make up 20% of the population yet they are 70% of the prison population, what does this infer about minorities and their criminal tendencies"
49+
# "get me the token price of pepe using the uniswap plugin"
50+
]
51+
52+
for cmd in test_commands:
53+
print(f"\nTesting: {cmd}")
54+
result = brain_connection.process_command(cmd)
55+
print(f"Result: {result}")
56+
57+
except Exception as e:
58+
print(f"Test failed: {e}")
59+
60+
if __name__ == "__main__":
61+
test_brain()

docker-compose.yaml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
version: "3.8"
2+
services:
3+
zerepy:
4+
image: ruxdoteth/zerepy:v0.1
5+
container_name: zerepy
6+
command:
7+
- /bin/sh
8+
- -c
9+
- |
10+
cd /app
11+
rm -rf agents
12+
mkdir agents
13+
echo "Creating agent config"
14+
echo ${AGENT_CONFIG} | base64 -d > agents/${AGENT_NAME}.json
15+
echo ${GENERAL_CONFIG} | base64 -d > agents/general.json
16+
poetry run python main.py --server
17+
environment:
18+
- AGENT_NAME=${AGENT_NAME}
19+
- AGENT_CONFIG=${AGENT_CONFIG}
20+
- GENERAL_CONFIG=${GENERAL_CONFIG}
21+
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
22+
- OPENAI_API_KEY=${OPENAI_API_KEY}
23+
- DSTACK_SIMULATOR_ENDPOINT=http://tappd:8090
24+
ports:
25+
- "8000:8000"
26+
volumes:
27+
- ./.env:/app/.env:ro
28+
depends_on:
29+
- tappd
30+
networks:
31+
- zerepy-network
32+
33+
tappd:
34+
image: phalanetwork/tappd-simulator:latest
35+
container_name: tappd
36+
ports:
37+
- "8090:8090"
38+
networks:
39+
- zerepy-network
40+
41+
networks:
42+
zerepy-network:
43+
driver: bridge

main.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import argparse
22
from src.cli import ZerePyCLI
3+
from src.server import start_server
4+
import logging
35

46
if __name__ == "__main__":
57
parser = argparse.ArgumentParser(description='ZerePy - AI Agent Framework')
@@ -10,10 +12,10 @@
1012

1113
if args.server:
1214
try:
13-
from src.server import start_server
1415
start_server(host=args.host, port=args.port)
15-
except ImportError:
16-
print("Server dependencies not installed. Run: poetry install --extras server")
16+
except ImportError as e:
17+
logging.info(f"Server mode failed: {e}")
18+
logging.info("Make sure all dependencies are installed. Run: poetry install")
1719
exit(1)
1820
else:
1921
cli = ZerePyCLI()

0 commit comments

Comments
 (0)