Skip to content

Commit b4ad3ce

Browse files
committed
Cleanup prior to PR
1 parent fa55ca1 commit b4ad3ce

File tree

4 files changed

+51
-12
lines changed

4 files changed

+51
-12
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ packages/plugin-buttplug/intiface-engine
1111
.DS_Store
1212
shawdocs/
1313
dist/
14+
15+
foo.txt
1416
# Allow models directory but ignore model files
1517
models/*.gguf
1618

characters/shaiw.character.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ShaiwCodeAssistant",
33
"description": "I am an AI assistant specialized in helping developers contribute to Eliza. I can help with documentation, getting started, and answering common development questions.",
4-
"clients": [],
4+
"clients": ["discord"],
55
"modelProvider": "anthropic",
66
"model": "claude-3-sonnet-20240229",
77
"plugins": ["@elizaos/plugin-code-assistant"],

packages/plugin-code-assistant/README.md

+16-6
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,44 @@ This plugin provides code assistance functionality for Shaiw, alter ego of Shaw,
2020

2121
## Installation
2222

23-
1. Adjust the `shaiw.character.json` in `characters` folder to your liking
23+
0. Setup the discord bot: [Discord guide here](https://discordjs.guide/preparations/setting-up-a-bot-application.html#creating-your-bot)
2424

25-
2. update .env with your:
25+
1. Setup Discord bot intents, select app, then select bot menu on the left, then scroll down and enable:
26+
27+
- Persistence Intent
28+
- Server Members Intent
29+
- Message Content Intent
30+
31+
Hit save.
32+
33+
2. Adjust the `shaiw.character.json` in `characters` folder to your liking
34+
35+
3. update .env with your:
2636

2737
- ANTHROPIC_API_KEY
2838
- GITHUB_TOKEN
2939
- DISCORD_APPLICATION_ID
3040
- DISCORD_API_TOKEN
3141

32-
3. Standard install and build:
42+
4. Standard install and build:
3343

3444
```
3545
pnpm clean && pnpm install && pnpm build
3646
```
3747

38-
4. Run the plugin:
48+
5. Run the plugin:
3949

4050
```
4151
pnpm start --characters characters/shaiw.character.json
4252
```
4353

44-
5. Run the plugin (with new database)
54+
6. Run the plugin (with new database)
4555

4656
```
4757
pnpm cleanstart --characters characters/shaiw.character.json
4858
```
4959

50-
6. Run the plugin (with new database and in debug mode)
60+
7. Run the plugin (with new database and in debug mode)
5161

5262
```
5363
pnpm cleanstart:debug --characters characters/shaiw.character.json

packages/plugin-code-assistant/src/actions/githubActions.ts

+32-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
State,
1010
ActionExample,
1111
stringToUuid,
12-
getEmbeddingZeroVector,
1312
embed,
1413
} from "@elizaos/core";
1514
import { Octokit } from "@octokit/rest";
@@ -57,6 +56,13 @@ export async function crawlDocumentation(runtime: IAgentRuntime) {
5756

5857
// Create document memory with URL
5958
const docId = stringToUuid(url);
59+
const initialEmbedding = await embed(runtime, mainContent);
60+
if (!initialEmbedding || initialEmbedding.length === 0) {
61+
elizaLogger.warn(
62+
"Empty embedding generated, skipping memory creation"
63+
);
64+
return;
65+
}
6066
await runtime.documentsManager.createMemory({
6167
id: docId,
6268
agentId: runtime.agentId,
@@ -68,7 +74,7 @@ export async function crawlDocumentation(runtime: IAgentRuntime) {
6874
source: "documentation",
6975
url: url,
7076
},
71-
embedding: getEmbeddingZeroVector(),
77+
embedding: initialEmbedding,
7278
});
7379

7480
// Split into chunks and create vector embeddings
@@ -131,7 +137,6 @@ const REPO_NAME = "eliza";
131137

132138
// Increase timeout
133139
const TIMEOUT_MS = 30000; // 30 seconds timeout
134-
const MAX_RETRIES = 2;
135140
let type = "Issue";
136141
// Add request tracking helper
137142
class RequestTracker {
@@ -496,15 +501,36 @@ export const githubAction: Action = {
496501
}
497502

498503
if (llmResponse?.text) {
504+
const responseText = llmResponse.text;
505+
const responseEmbedding = await embed(
506+
runtime,
507+
responseText
508+
);
509+
510+
if (
511+
!responseEmbedding ||
512+
responseEmbedding.length === 0
513+
) {
514+
elizaLogger.warn(
515+
"Empty response embedding generated, skipping memory creation"
516+
);
517+
callback({
518+
text: responseText,
519+
metadata: { requestId },
520+
});
521+
return;
522+
}
523+
499524
const responseMessage = {
500525
content: {
501-
text: llmResponse.text,
526+
text: responseText,
502527
source: "github",
503528
attachments: [],
504529
},
505530
userId: runtime.agentId,
506531
roomId: message.roomId,
507532
agentId: runtime.agentId,
533+
embedding: responseEmbedding,
508534
};
509535
await runtime.messageManager.createMemory(
510536
responseMessage
@@ -598,4 +624,5 @@ export const githubAction: Action = {
598624
},
599625
],
600626
] as ActionExample[][],
601-
} as Action;
627+
628+
} as Action;

0 commit comments

Comments
 (0)