Skip to content

Commit

Permalink
Merge main - resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Xm0onh committed Jan 3, 2025
2 parents e185102 + 463d60a commit 2a18b2f
Show file tree
Hide file tree
Showing 11 changed files with 364 additions and 259 deletions.
4 changes: 3 additions & 1 deletion auto-agents-framework/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
character.ts
characters/
!characters/character.example.ts
.cookies/
107 changes: 85 additions & 22 deletions auto-agents-framework/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,95 @@ Auto-Agents-Framework is an experimental framework for building AI agents that c
## Getting Started

1. Install dependencies:
`yarn install`
`yarn install
`

2. Copy the environment file and configure your credentials:
`cp .env.sample .env`

3. Create your agent character by copying the example:
`cp src/agents/workflows/kol/characters/character.example.ts src/agents/workflows/kol/characters/character.ts`
3. Configure your `.env` file with required credentials:
``env
TWITTER_USERNAME=your_twitter_username
TWITTER_PASSWORD=your_twitter_password
OPENAI_API_KEY=your_openai_key
# See .env.sample for other configuration options
``

4. Configure your character:
## Character System

```
// character.ts
const name = 'Your Agent Name';
const username = 'twitter_handle';
const walletAddress = '0x...'; // Your Autonomys Network wallet
const description = 'Your agent's personality description...';
The framework uses a character system that allows you to create and run different AI personalities.

### Creating Characters

// Configure additional personality traits, expertise, rules, etc.
1. Characters are stored in `src/agents/workflows/kol/characters/`
2. Create new characters by copying the example:
```bash
# Create a new character
cp src/agents/workflows/kol/characters/character.example.ts src/agents/workflows/kol/characters/my-character.ts
```

## Character Configuration
### Character Configuration

Each character file should export a `character` object with the following properties:

```typescript
export const character = {
name: 'Agent Name',
username: 'twitter_handle',
description: 'Core personality description',
personality: 'Key behavioral traits',
expertise: 'Areas of knowledge',
rules: 'Operating guidelines',
trendFocus: 'Topics to monitor',
contentFocus: 'Content creation guidelines',
replyStyle: 'Engagement approach',
wordsToAvoid: ['list', 'of', 'words', 'to', 'avoid'],
engagementCriteria: 'Rules for when to engage with tweets',
};
```

### Running with Different Characters

Run the agent with a specific character:
``bash

# Use default character (character.ts)

yarn dev

# Use a specific character (omit .ts extension)

The character configuration defines your agent's personality and behavior. Key sections include:
```
yarn dev argumint
yarn dev techie
```

- `description`: Core personality and background
- `personality`: Key behavioral traits
- `expertise`: Areas of knowledge
- `rules`: Operating guidelines
- `trendFocus`: Topics to monitor
- `contentFocus`: Content creation guidelines
- `replyStyle`: Engagement approach
- `wordsToAvoid`: Restricted vocabulary
### Example Characters

1. Default Rational Agent (`character.ts`):

```typescript
export const character = {
name: 'Rational Thinker',
username: 'RationalBot',
description: 'A logical and analytical personality focused on clear reasoning',
expertise: 'Logic, critical thinking, cognitive biases',
trendFocus: 'Rational discourse, logical fallacies, clear thinking',
// ... other configuration
};
```

2. Tech Enthusiast (`techie.ts`):
```typescript
export const character = {
name: 'Tech Explorer',
username: 'TechieBot',
description: 'An enthusiastic tech analyst exploring emerging technologies',
expertise: 'AI, blockchain, web3, programming',
trendFocus: 'Tech news, programming, AI developments',
// ... other configuration
};
```

## Autonomys Network Integration

Expand Down Expand Up @@ -79,7 +135,14 @@ The KOL workflow enables agents to:
## Running the Agent

Start the agent with:
`yarn dev`

```bash
# Use default character
yarn dev

# Use a specific character (without .ts extension)
yarn dev argumint
```

Monitor the agent's activity in the console and configured log files.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WorkflowConfig } from '../types.js';
import { createLogger } from '../../../../utils/logger.js';
import { State } from '../workflow.js';
import { trendParser, trendPrompt } from '../prompts.js';
import { trendParser } from '../prompts.js';

const logger = createLogger('analyze-timeline-trend-node');

Expand All @@ -15,7 +15,7 @@ export const createAnalyzeTrendNode =
}));
logger.info('Tweets:', { tweets: tweets.length });

const trendAnalysis = await trendPrompt
const trendAnalysis = await config.prompts.trendPrompt
.pipe(config.llms.analyze)
.pipe(trendParser)
.invoke({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WorkflowConfig } from '../types.js';
import { createLogger } from '../../../../utils/logger.js';
import { State } from '../workflow.js';
import { engagementParser, engagementPrompt } from '../prompts.js';
import { engagementParser } from '../prompts.js';
import { Tweet } from '../../../../services/twitter/types.js';

const logger = createLogger('engagement-node');
Expand All @@ -12,7 +12,7 @@ const getEngagementDecision = async (tweet: Tweet, config: WorkflowConfig) => {
? tweet.thread.map(t => ({ text: t.text, username: t.username }))
: 'No thread';

const formattedPrompt = await engagementPrompt.format({
const formattedPrompt = await config.prompts.engagementPrompt.format({
tweet: JSON.stringify({ text: tweet.text, username: tweet.username }),
thread: thread,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { EngagementDecision, WorkflowConfig } from '../types.js';
import { createLogger } from '../../../../utils/logger.js';
import { State } from '../workflow.js';
import { invokePostTweetTool } from '../../../tools/postTweetTool.js';
import { tweetPrompt, trendTweetParser, responsePrompt, responseParser } from '../prompts.js';
import { trendTweetParser, responseParser } from '../prompts.js';
import { AIMessage } from '@langchain/core/messages';
import { summarySchema } from '../schemas.js';
import { z } from 'zod';
Expand All @@ -18,12 +18,15 @@ const postResponse = async (
? decision.tweet.thread.map(t => ({ text: t.text, username: t.username }))
: 'No thread';
const decisionInfo = { tweet: decision.tweet.text, reason: decision.decision.reason };
const response = await responsePrompt.pipe(config.llms.generation).pipe(responseParser).invoke({
decision: decisionInfo,
thread,
patterns: summary.patterns,
commonWords: summary.commonWords,
});
const response = await config.prompts.responsePrompt
.pipe(config.llms.generation)
.pipe(responseParser)
.invoke({
decision: decisionInfo,
thread,
patterns: summary.patterns,
commonWords: summary.commonWords,
});
//TODO: After sending the tweet, we need to get the latest tweet, ensure it is the same as we sent and return it
//This has not been working as expected, so we need to investigate this later
const tweet = await invokePostTweetTool(config.toolNode, response.content, decision.tweet.id);
Expand Down Expand Up @@ -76,7 +79,7 @@ export const createGenerateTweetNode =

// Generate a top level tweet
//TODO: add a check to see if it has been long enough since the last tweet
const generatedTweet = await tweetPrompt
const generatedTweet = await config.prompts.tweetPrompt
.pipe(config.llms.generation)
.pipe(trendTweetParser)
.invoke({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { WorkflowConfig } from '../types.js';
import { createLogger } from '../../../../utils/logger.js';
import { State } from '../workflow.js';
import { summaryParser, summaryPrompt } from '../prompts.js';
import { summaryParser } from '../prompts.js';

const logger = createLogger('summary-node');

export const createSummaryNode = (config: WorkflowConfig) => async (state: typeof State.State) => {
logger.info('Summary Node - Summarizing previous replies');
const myRecentReplies = Array.from(state.myRecentReplies.values()).map(reply => reply.text);

const summary = await summaryPrompt
const summary = await config.prompts.summaryPrompt
.pipe(config.llms.analyze)
.pipe(summaryParser)
.invoke({
Expand Down
Loading

0 comments on commit 2a18b2f

Please sign in to comment.