Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix farcaster client process action issue #963

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions packages/client-farcaster/src/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class FarcasterInteractionManager {
try {
await this.handleInteractions();
} catch (error) {
elizaLogger.error(error)
elizaLogger.error(error);
return;
}

Expand Down Expand Up @@ -96,7 +96,7 @@ export class FarcasterInteractionManager {
});

const memory: Memory = {
content: { text: mention.text },
content: { text: mention.text, hash: mention.hash },
agentId: this.runtime.agentId,
userId,
roomId,
Expand All @@ -106,7 +106,7 @@ export class FarcasterInteractionManager {
agent,
cast: mention,
memory,
thread
thread,
});
}

Expand All @@ -117,15 +117,15 @@ export class FarcasterInteractionManager {
agent,
cast,
memory,
thread
thread,
}: {
agent: Profile;
cast: Cast;
memory: Memory;
thread: Cast[]
thread: Cast[];
}) {
if (cast.profile.fid === agent.fid) {
elizaLogger.info("skipping cast from bot itself", cast.hash)
elizaLogger.info("skipping cast from bot itself", cast.hash);
return;
}

Expand Down Expand Up @@ -164,7 +164,7 @@ export class FarcasterInteractionManager {
farcasterUsername: agent.username,
timeline: formattedTimeline,
currentPost,
formattedConversation
formattedConversation,
});

const shouldRespondContext = composeContext({
Expand Down Expand Up @@ -200,8 +200,13 @@ export class FarcasterInteractionManager {
modelClass: ModelClass.SMALL,
});

if (shouldRespondResponse === "IGNORE" || shouldRespondResponse === "STOP") {
elizaLogger.info(`Not responding to cast because generated ShouldRespond was ${shouldRespondResponse}`)
if (
shouldRespondResponse === "IGNORE" ||
shouldRespondResponse === "STOP"
) {
elizaLogger.info(
`Not responding to cast because generated ShouldRespond was ${shouldRespondResponse}`
);
return;
}

Expand All @@ -224,7 +229,6 @@ export class FarcasterInteractionManager {

if (!response.text) return;


if (this.runtime.getSetting("FARCASTER_DRY_RUN") === "true") {
elizaLogger.info(
`Dry run: would have responded to cast ${cast.hash} with ${response.text}`
Expand All @@ -247,6 +251,8 @@ export class FarcasterInteractionManager {
hash: cast.hash,
},
});
// sendCast lost response action, so we need to add it back here
results[0].memory.content.action = response.action;

const newState = await this.runtime.updateRecentMessageState(state);

Expand Down