12This "migration" runs once on every app startup because it's imported in `index.ts`. You can comment this line out for a slight (30ms) performance improvement on cold starts. It's left in so that users who fork this project will have the migration run correctly.
13
14SQLite has much more limited support for altering existing tables as compared to other databases. Often it's easier to create new tables with the schema you want, and then copy the data over. Happily LLMs are quite good at those sort of database operations, but please reach out in the [Val Town Discord](https://discord.com/invite/dHv45uN5RY) if you need help.
15
16## Queries
12This "migration" runs once on every app startup because it's imported in `index.ts`. You can comment this line out for a slight (30ms) performance improvement on cold starts. It's left in so that users who fork this project will have the migration run correctly.
13
14SQLite has much more limited support for altering existing tables as compared to other databases. Often it's easier to create new tables with the schema you want, and then copy the data over. Happily LLMs are quite good at those sort of database operations, but please reach out in the [Val Town Discord](https://discord.com/invite/dHv45uN5RY) if you need help.
15
16## Queries
10Feel free to edit these examples or add new files to your project.
11
12For inspiration, check out our [Docs](https://docs.val.town/), [Templates](https://www.val.town/explore/use-cases), [Showcase](https://www.val.town/explore/community-showcase) and [Discord](https://discord.val.town/)!
13
14Stay as long as you'd like in this project, or head to your main [dashboard](/dashboard) to keep exploring the rest of Val Town.
10Feel free to edit these examples or add new files to your project.
11
12For inspiration, check out our [Docs](https://docs.val.town/), [Templates](https://www.val.town/explore/use-cases), [Showcase](https://www.val.town/explore/community-showcase) and [Discord](https://discord.val.town/)!
13
14Stay as long as you'd like in this project, or head to your main [dashboard](/dashboard) to keep exploring the rest of Val Town.
12This "migration" runs once on every app startup because it's imported in `index.ts`. You can comment this line out for a slight (30ms) performance improvement on cold starts. It's left in so that users who fork this project will have the migration run correctly.
13
14SQLite has much more limited support for altering existing tables as compared to other databases. Often it's easier to create new tables with the schema you want, and then copy the data over. Happily LLMs are quite good at those sort of database operations, but please reach out in the [Val Town Discord](https://discord.com/invite/dHv45uN5RY) if you need help.
15
16## Queries
73- [Steel Documentation](https://docs.steel.dev)
74- [API Reference](https://docs.steel.dev/api-reference)
75- [Discord Community](https://discord.gg/gPpvhNvc5R)
24 // Format messages for OpenAI
25 const formattedConversation = messages.map(msg => {
26 const author = msg.author_id === process.env.DISCORD_USER_ID ? 'You' : 'Partner';
27 return `${author}: ${msg.content}`;
28 }).join('\n');
1import { fetchAndStoreDMs } from './discord-client.js';
2import 'dotenv/config';
3
11 */
12export default async function cronHandler() {
13 console.log('Starting scheduled Discord DM fetch...');
14 try {
15 await fetchAndStoreDMs();
19 max_tokens: options.maxTokens || 1000,
20 temperature: options.temperature || 0.7,
21 system: options.systemPrompt || 'You are an assistant analyzing Discord conversations and helping users find information from their message history.',
22 messages: [
23 {
45 // Format the messages for Claude
46 const formattedMessages = messages.map(msg => {
47 const author = msg.author_id === process.env.DISCORD_USER_ID ? 'You' : 'Partner';
48 const date = new Date(parseInt(msg.timestamp)).toLocaleString();
49 return `${author} (${date}): ${msg.content}`;
52 // Create the prompt
53 const prompt = `
54I have a set of Discord direct messages between me and my partner.
55I want to analyze them to answer this question: "${query}"
56
141 // Format the messages for Claude
142 const formattedMessages = messages.map(msg => {
143 const author = msg.author_id === process.env.DISCORD_USER_ID ? 'You' : 'Partner';
144 const date = new Date(parseInt(msg.timestamp)).toLocaleString();
145 return `${author} (${date}): ${msg.content}`;
147
148 let prompt = `
149I have a set of Discord direct messages between me and my partner.
150I want you to create a concise summary of our conversation.
151 `;
46 try {
47 const prompt = `
48Determine the intent of this query about Discord messages between two people:
49"${query}"
50
150
151 const prompt = `
152I have a list of links shared in Discord messages. Based on this query: "${query}"
153Please determine which of these links are most relevant:
154
326 // Create prompt for furniture analysis
327 const prompt = `
328I have a set of Discord messages and links related to furniture. The user wants to know about: "${query}"
329
330Please analyze what the two people have discussed about furniture,