Skip to content

Commit e105e74

Browse files
committed
iterate
1 parent 06b3ec9 commit e105e74

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

agent.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,9 @@ export const handleFindMatches = async ({senderFid, name, messages, response, no
136136

137137
await createMatch(senderFid.toString(), matchedUser.fid.toString());
138138

139-
const foundNew = {
140-
candidate_name: matchedUser.name,
141-
candidate_username: matchedUser.username,
142-
candidate_profile: matchedUser.profile,
143-
candidate_intent: matchedUser.intent,
144-
result: 'found_new'
145-
}
146-
147-
await sendToolMessage({fid: senderFid, messages, content: `Found a new match: ${JSON.stringify(foundNew)}`});
139+
const currentUser = await findUserByFid(senderFid);
140+
const introMessage = await prepareIntroMessage(currentUser, matchedUser);
141+
await farcaster.sendDirectMessage(senderFid, introMessage);
148142

149143
}
150144

@@ -316,12 +310,14 @@ export const agentLogic = async ({messages, conversationId, senderFid, name, use
316310
try {
317311
const matches = await getUserState(senderFid);
318312

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-
});
313+
if (matches.length > 0) {
314+
messages.unshift({
315+
role: `system`,
316+
content: `Here are the pending match state for the user: ${matches.map(match =>
317+
Object.entries(match).map(([key, value]) => `${key}: ${value}`).join('\n')
318+
).join('\n----\n')}`
319+
});
320+
}
325321
} catch (error) {
326322
console.error('Error getting user state:', error);
327323

db.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ export async function getUserState(fid) {
327327
FROM matches m
328328
JOIN users u1 ON m.user1_fid = u1.fid
329329
JOIN users u2 ON m.user2_fid = u2.fid
330-
WHERE m.user1_fid = ? OR m.user2_fid = ?
330+
WHERE (m.user1_fid = ? OR m.user2_fid = ?) AND m.status = 'pending'
331331
ORDER BY m.created_at ASC`,
332332
[fid, fid, fid, fid, fid, fid, fid]
333333
);
@@ -336,7 +336,7 @@ export async function getUserState(fid) {
336336

337337

338338
} catch (error) {
339-
console.error('Error getting user state:', error);
339+
return [];
340340

341341
}
342342
}

find_matches.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,17 @@ Profile: ${match.profile}
160160
Intent: ${match.intent}
161161
162162
Important:
163+
- You must ensure username (@${match.username}) is always included in the message.
163164
- Always talk to the user, not the match
164165
- Do not expose sensitive personal information
165166
- Focus on value and mutual benefit
166167
- Keep the message concise and engaging
167168
- Highlight key points of alignment
168-
- Ensure username (@${match.username}) is correctly displayed.
169169
- Ask for the opt-in request natural and low-pressure, giving them a comfortable way to decline`;
170170

171171
const aiResponse = await openai.chat.completions.create({
172172
model: "gpt-4o",
173-
temperature: 0.7,
173+
temperature: 0.2,
174174
messages: [{ role: "system", content: agentPromptText }, { role: "system", content: prompt }],
175175
response_format: zodResponseFormat(introMessageSchema, "response"),
176176
stream: false,

0 commit comments

Comments
 (0)