Scaffold web app

This commit is contained in:
tedspare
2025-11-18 16:05:05 -05:00
parent 15dce46be2
commit 51a8916a4c
40 changed files with 808 additions and 1 deletions

34
src/app/(app)/ai.tsx Normal file
View File

@@ -0,0 +1,34 @@
'use server'
import { executeTodoAgent } from '~/agents/todo'
import env from '~/env'
import { publish } from '~/events/server'
export async function sendMessage({ userId, message }: { userId: string; message: string }) {
const { response } = await executeTodoAgent({
messages: [{ content: message, role: 'user' }],
onEvent: async events => {
switch (events.type) {
case 'assistant_message': {
await publish({
channel: userId,
eventType: events.type,
payload: events
})
break
}
case 'function_call': {
await publish({
channel: userId,
eventType: events.name,
payload: events
})
break
}
}
},
openAIKey: env.OPENAI_API_KEY
})
console.log(response)
}