Skip to content

Commit 9fde162

Browse files
authored
Merge pull request #106 from iotexproject/feat/github-characters
Feat/GitHub characters
2 parents 779b509 + 3f73f5b commit 9fde162

File tree

1 file changed

+114
-1
lines changed

1 file changed

+114
-1
lines changed

README.md

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ _The autonomous agent framework that doesn't mess around. Build once, deploy eve
66

77
_Originally forked from [ElizaOS](https://github.com/elizaOS/eliza) — credits to the pioneering work that laid the foundation._
88

9-
**See it in action:** [@Bino_AI](https://x.com/Bino_AI)[@Caila_AI](https://x.com/Caila_AI)[@NodeyICN](https://x.com/NodeyICN)
9+
**See it in action:** [@Bino_AI](https://x.com/Bino_AI)[@Caila_AI](https://x.com/Caila_AI)
1010

1111
## 📋 Table of Contents
1212

@@ -15,6 +15,7 @@ _Originally forked from [ElizaOS](https://github.com/elizaOS/eliza) — credits
1515
- [🚀 3-Minute Setup (No, Really)](#-3-minute-setup-no-really)
1616
- [🛠️ For the Brave: Build From Source](#️-for-the-brave-build-from-source)
1717
- [📚 Feed Your Agent Knowledge](#-feed-your-agent-knowledge)
18+
- [🎭 Character Data Sources](#-character-data-sources)
1819

1920
## ✨ What You Get
2021

@@ -147,3 +148,115 @@ Update your `character.json` to point to the knowledge files:
147148
```
148149

149150
Now your agent knows everything you know. Scary? Maybe. Useful? Absolutely.
151+
152+
## 🎭 Character Data Sources
153+
154+
Your agent's personality comes from multiple sources, merged in a specific order. Here's how it works:
155+
156+
### The Loading Hierarchy
157+
158+
When you start an agent, character data is loaded and merged in this order:
159+
160+
1. **Default Character** (`packages/core/src/defaultCharacter.ts`)
161+
- Used when no character JSON path is provided
162+
- Provides a baseline "Eliza" character with default traits
163+
- Includes system prompt, bio, lore, message examples, and style
164+
165+
2. **Character JSON File** (`characters/*.json`)
166+
- Loaded when you specify `--character=characters/my-character.json`
167+
- Defines core character properties: name, model provider, plugins, clients
168+
- Can include initial traits, but these get enriched by subsequent sources
169+
170+
3. **Filesystem Traits** (`characters/agentsTraits/<characterName>/`)
171+
- **Primary source** for character traits (bio, lore, knowledge, templates, etc.)
172+
- Loaded from a directory matching the character's `name` field
173+
- Structure mirrors GitHub repo format (see below)
174+
- If found, traits are merged with the character JSON
175+
176+
4. **Database Traits** (PostgreSQL fallback)
177+
- **Fallback** when filesystem traits directory doesn't exist
178+
- Maintains backwards compatibility with existing deployments
179+
- Traits stored in `characters` table with `is_published = true`
180+
181+
### How It Works (HIW)
182+
183+
The merge process follows this flow:
184+
185+
```text
186+
Start Agent
187+
188+
Load Character JSON (or use default)
189+
190+
Check: Does `characters/agentsTraits/<characterName>/` exist?
191+
├─ YES → Load traits from filesystem → Merge → Done
192+
└─ NO → Check database for traits → Merge → Done
193+
```
194+
195+
**Important:** Filesystem traits take precedence over database traits. If both exist, filesystem wins.
196+
197+
### GitHub Repo Integration
198+
199+
The filesystem traits directory structure matches a GitHub repository format. Here's how to set it up:
200+
201+
#### Repository Structure
202+
203+
Your character traits repo should follow this structure:
204+
205+
```text
206+
your-character-repo/
207+
├── bio.json # Array of biography strings
208+
├── lore.json # Array of lore strings
209+
├── knowledge.json # Array of knowledge paths (strings or objects)
210+
├── messageExamples.json # Nested array of message examples
211+
├── postExamples.json # Array of post example strings
212+
├── topics.json # Array of topic strings
213+
├── adjective.json # Array of adjective strings
214+
├── style.json # Style object with all/chat/post arrays
215+
├── templates.json # Template names mapped to file paths
216+
├── xTargetUsers.txt # One username per line
217+
├── xKnowledgeUsers.txt # One username per line
218+
└── prompts/
219+
├── system.md # System prompt (becomes system_prompt)
220+
├── goals.md # Template (becomes templates.goalsTemplate)
221+
└── *.md # Other templates
222+
```
223+
224+
#### Setting Up the Symlink
225+
226+
1. **Clone your character traits repo:**
227+
228+
```bash
229+
git clone https://github.com/your-org/your-character-repo.git
230+
```
231+
232+
2. **Create a symlink in the project:**
233+
234+
```bash
235+
cd binoSwarm
236+
ln -s ../your-character-repo characters/agentsTraits/your-character-name
237+
```
238+
239+
The directory name must match the `name` field in your character JSON.
240+
241+
#### Template Files
242+
243+
The `templates.json` file maps template names to file paths:
244+
245+
```json
246+
{
247+
"goalsTemplate": "./prompts/goals.md",
248+
"twitterQSPrompt": "./prompts/twitterQS.md",
249+
"memeSystemPrompt": "./prompts/memeSystem.md"
250+
}
251+
```
252+
253+
The loader reads these files and stores their content in `character.templates`.
254+
255+
#### Knowledge Files
256+
257+
`knowledge.json` can contain either:
258+
259+
- Simple strings: `["path/to/file.md"]`
260+
- Objects with paths: `[{"path": "path/to/file.md", "shared": false}]`
261+
262+
Both formats are supported and converted to string arrays during loading.

0 commit comments

Comments
 (0)