Skip to content

Commit 06b3ec9

Browse files
committed
iterate
1 parent fcf786f commit 06b3ec9

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

agent.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ export const handleFindMatches = async ({senderFid, name, messages, response, no
143143
candidate_intent: matchedUser.intent,
144144
result: 'found_new'
145145
}
146+
146147
await sendToolMessage({fid: senderFid, messages, content: `Found a new match: ${JSON.stringify(foundNew)}`});
148+
147149
}
148150

149151
export const handleAcceptMatch = async ({senderFid, messages}) => {
@@ -311,15 +313,19 @@ export const handleExpiredMatches = async () => {
311313
}
312314

313315
export const agentLogic = async ({messages, conversationId, senderFid, name, username}) => {
316+
try {
317+
const matches = await getUserState(senderFid);
318+
319+
messages.unshift({
320+
role: `system`,
321+
content: `Here are the matching states for the user: ${matches.map(match =>
322+
Object.entries(match).map(([key, value]) => `${key}: ${value}`).join('\n')
323+
).join('\n----\n')}`
324+
});
325+
} catch (error) {
326+
console.error('Error getting user state:', error);
314327

315-
const matches = await getUserState(senderFid);
316-
317-
messages.unshift({
318-
role: `system`,
319-
content: `Here are the matching states for the user: ${matches.map(match =>
320-
Object.entries(match).map(([key, value]) => `${key}: ${value}`).join('\n')
321-
).join('\n----\n')}`
322-
});
328+
}
323329

324330
const response = await runAgent(messages);
325331

db.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,6 @@ export async function getUserState(fid) {
337337

338338
} catch (error) {
339339
console.error('Error getting user state:', error);
340-
throw error;
340+
341341
}
342342
}

0 commit comments

Comments
 (0)