Skip to content

Commit

Permalink
feat: create memory for better context
Browse files Browse the repository at this point in the history
  • Loading branch information
KacperKoza343 committed Jan 21, 2025
1 parent 020194e commit 2abfbfe
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion characters/tate.character.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
]
],
"postExamples": [""],
"topics": ["Ai autonomy", "AI safety", "AI ethics", "AI governance", "AI regulation", "AI regulation", "AI companies", "AI in businesses"],
"topics": ["Rola pamiΔ™Δ‡ miΔ™sniowej w treningu"],
"style": {
"all": [""],
"chat": [""],
Expand Down
3 changes: 2 additions & 1 deletion packages/client-linkedin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
],
"dependencies": {
"@elizaos/core": "workspace:*",
"axios": "^1.7.9"
"axios": "^1.7.9",
"remove-markdown": "^0.6.0"
},
"devDependencies": {
"@vitest/coverage-v8": "1.1.3",
Expand Down
15 changes: 13 additions & 2 deletions packages/client-linkedin/src/services/LinkedInPostScheduler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AxiosInstance } from "axios";
import { LinkedInUserInfoFetcher } from "../repositories/LinkedinUserInfoFetcher";
import { PostContentCreator } from "./PostContentCreator";
import { elizaLogger, IAgentRuntime } from "@elizaos/core";
import { elizaLogger, IAgentRuntime, stringToUuid } from "@elizaos/core";
import { getRandomInteger } from "../helpers/get-random-integer";
import { LinkedInPostPublisher } from "../repositories/LinkedinPostPublisher";
import { PublisherConfig } from "../interfaces";
Expand Down Expand Up @@ -59,7 +59,9 @@ export class LinkedInPostScheduler {
const postText = await this.postContentCreator.createPostContent(
this.userId
);
elizaLogger.log(`Generated post text:\n${postText}`);

elizaLogger.log(`Generated post text`);
elizaLogger.log(postText);

if (!this.config.LINKEDIN_DRY_RUN) {
await this.postPublisher.publishPost({ postText });
Expand All @@ -70,6 +72,15 @@ export class LinkedInPostScheduler {
);
}

this.runtime.messageManager.createMemory({
userId: this.runtime.agentId,
agentId: this.runtime.agentId,
roomId: stringToUuid("linkedin_generate_room-" + this.userId),
content: {
text: postText,
},
});

await this.runtime.cacheManager.set(
"linkedin/" + this.userId + "/lastPost",
{ timestamp: Date.now() }
Expand Down
5 changes: 4 additions & 1 deletion packages/client-linkedin/src/services/PostContentCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
stringToUuid,
} from "@elizaos/core";
import { createLinkedinPostTemplate } from "../templates";
import removeMd from "remove-markdown";

export class PostContentCreator {
constructor(public runtime: IAgentRuntime) {}
Expand All @@ -29,10 +30,12 @@ export class PostContentCreator {
template: createLinkedinPostTemplate,
});

return await generateText({
const text = await generateText({
runtime: this.runtime,
context,
modelClass: ModelClass.SMALL,
});

return removeMd(text);
}
}
5 changes: 2 additions & 3 deletions packages/client-linkedin/src/templates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ Style Guidelines:
- Don't use first-person narrative.
Formatting:
- Do NOT use markdown format (no * or ** for bold/italic).
- Bold text: π„π±πšπ¦π©π₯𝐞 𝐭𝐞𝐱𝐭 123
- Use bold as in π„π±πšπ¦π©π₯𝐞 𝐭𝐞𝐱𝐭 for header and highlighting
- Use normal text for rest of post
- Use emojis sparingly.
Expand All @@ -29,6 +26,8 @@ Hashtags:
Avoid:
- Generic advice, motivational content, personal experiences, company-specific information, markdown formatting.
- Post similar to published post from {{state}}, first try to create post about topic not mentioned in {{state}}, if all topics are mentioned in {{state}} then create post about topic that is not mentioned in {{state}} but is related to one of the topics from {{state}}.
- Markdown formatting.
Important Note:
- Ensure that the reply strictly adheres to the formatting rules provided in the prompt, especially avoiding markdown formatting and using the specified text styles for bold, italics, and bold italics.
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2abfbfe

Please sign in to comment.