Skip to content

Commit

Permalink
fix farcaster memory
Browse files Browse the repository at this point in the history
  • Loading branch information
CryptoGraffe committed Jan 14, 2025
1 parent a3bbaf6 commit bcd1a07
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/client-farcaster/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export async function sendCast({
cast,
memory: createCastMemory({
roomId,
senderId: runtime.agentId,
runtime,
cast,
}),
Expand Down
5 changes: 5 additions & 0 deletions packages/client-farcaster/src/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ export class FarcasterInteractionManager {

const currentPost = formatCast(cast);


const senderId = stringToUuid(cast.authorFid.toString());


const { timeline } = await this.client.getTimeline({
fid: agent.fid,
pageSize: 10,
Expand Down Expand Up @@ -190,6 +194,7 @@ export class FarcasterInteractionManager {
await this.runtime.messageManager.createMemory(
createCastMemory({
roomId: memory.roomId,
senderId,
runtime: this.runtime,
cast,
})
Expand Down
7 changes: 5 additions & 2 deletions packages/client-farcaster/src/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import { FarcasterClient } from "./client";

export function createCastMemory({
roomId,
senderId,
runtime,
cast,
}: {
roomId: UUID;
senderId: UUID;
runtime: IAgentRuntime;
cast: Cast;
}): Memory {
Expand All @@ -33,7 +35,7 @@ export function createCastMemory({
agentId: runtime.agentId,
}),
agentId: runtime.agentId,
userId: runtime.agentId,
userId: senderId,
content: {
text: cast.text,
source: "farcaster",
Expand Down Expand Up @@ -75,7 +77,7 @@ export async function buildConversationThread({
if (!memory) {
elizaLogger.log("Creating memory for cast", currentCast.hash);

const userId = stringToUuid(currentCast.profile.username);
const userId = stringToUuid(currentCast.authorFid.toString());

await runtime.ensureConnection(
userId,
Expand All @@ -88,6 +90,7 @@ export async function buildConversationThread({
await runtime.messageManager.createMemory(
createCastMemory({
roomId,
senderId: userId,
runtime,
cast: currentCast,
})
Expand Down
1 change: 1 addition & 0 deletions packages/client-farcaster/src/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export class FarcasterPostManager {
await this.runtime.messageManager.createMemory(
createCastMemory({
roomId,
senderId: this.runtime.agentId,
runtime: this.runtime,
cast,
})
Expand Down

0 comments on commit bcd1a07

Please sign in to comment.