Skip to content

Commit

Permalink
Merge branch 'develop' into fix/ENABLE_ACTION_PROCESSING
Browse files Browse the repository at this point in the history
  • Loading branch information
odilitime authored Dec 20, 2024
2 parents 03e2c00 + e201228 commit db8db28
Show file tree
Hide file tree
Showing 8 changed files with 2,891 additions and 18,145 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ tsup.config.bundled_*.mjs

coverage
.eslintcache

agent/content
9 changes: 6 additions & 3 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,17 +400,20 @@ export async function initializeClients(
elizaLogger.log("client keys", Object.keys(clients));

// TODO: Add Slack client to the list
// Initialize clients as an object


if (clientTypes.includes("slack")) {
const slackClient = await SlackClientInterface.start(runtime);
if (slackClient) clients.push(slackClient);
if (slackClient) clients.slack = slackClient; // Use object property instead of push
}

if (character.plugins?.length > 0) {
for (const plugin of character.plugins) {
// if plugin has clients, add those..
if (plugin.clients) {
for (const client of plugin.clients) {
clients.push(await client.start(runtime));
const startedClient = await client.start(runtime);
clients[client.name] = startedClient; // Assuming client has a name property
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion characters/trump.character.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "trump",
"clients": [],
"clients": ["slack"],
"modelProvider": "openai",
"settings": {
"secrets": {},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
},
"dependencies": {
"@0glabs/0g-ts-sdk": "0.2.1",
"@ai16z/adapter-postgres": "0.1.6-alpha.4",
"@coinbase/coinbase-sdk": "0.10.0",
"@deepgram/sdk": "^3.9.0",
"@vitest/eslint-plugin": "1.0.1",
Expand Down
41 changes: 31 additions & 10 deletions packages/client-discord/src/actions/chat_with_attachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
ModelClass,
State,
} from "@ai16z/eliza";
import * as fs from 'fs';

export const summarizationTemplate = `# Summarized so far (we are adding to this)
{{currentSummary}}
Expand Down Expand Up @@ -225,16 +227,35 @@ ${currentSummary.trim()}
`;
await callback(callbackData);
} else if (currentSummary.trim()) {
const summaryFilename = `content/summary_${Date.now()}`;
await runtime.cacheManager.set(summaryFilename, currentSummary);
// save the summary to a file
await callback(
{
...callbackData,
text: `I've attached the summary of the requested attachments as a text file.`,
},
[summaryFilename]
);
const summaryFilename = `content/summary_${Date.now()}.md`;

try {
// Debug: Log before file operations
console.log("Creating summary file:", {
filename: summaryFilename,
summaryLength: currentSummary.length
});

// Write file directly first
await fs.promises.writeFile(summaryFilename, currentSummary, 'utf8');
console.log("File written successfully");

// Then cache it
await runtime.cacheManager.set(summaryFilename, currentSummary);
console.log("Cache set operation completed");

await callback(
{
...callbackData,
text: `I've attached the summary of the requested attachments as a text file.`,
},
[summaryFilename]
);
console.log("Callback completed with summary file");
} catch (error) {
console.error("Error in file/cache process:", error);
throw error;
}
} else {
console.warn(
"Empty response from chat with attachments action, skipping"
Expand Down
9 changes: 9 additions & 0 deletions packages/client-slack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ settings:
7. On the "Basic Information" page, scroll down to "App Credentials"
8. Copy all the credentials - you'll need them in Step 3
### Step 2.5: Verify Event Subscription
Before proceeding to install the app, make sure to verify the event subscription:
1. In your Slack App settings, go to "Event Subscriptions."
2. Enter the request URL (your ngrok HTTPS URL followed by /slack/events).
3. Slack will send a verification request to this URL.
4. Ensure your server is running and configured to respond to the url_verification event by echoing back the challenge token provided in the request.
5. Once verified, you will see a confirmation in your Slack app settings.
### Step 3: Configure Environment Variables
1. Create or edit `.env` file in your project root:
```bash
Expand Down
2 changes: 1 addition & 1 deletion packages/client-slack/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ export async function validateSlackConfig(runtime: IAgentRuntime): Promise<Slack
}
throw error;
}
}
}
Loading

0 comments on commit db8db28

Please sign in to comment.