Skip to content
Closed
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions app/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ async function submit(formData?: FormData, skip?: boolean) {
: answer.length === 0 && !errorOccurred
) {
const { fullResponse, hasError, toolResponses } = await researcher(
currentSystemPrompt + calendarNotesContext,
(currentSystemPrompt ?? '') + calendarNotesContext,
uiStream,
streamText,
messages,
Expand Down Expand Up @@ -352,7 +352,7 @@ async function submit(formData?: FormData, skip?: boolean) {
) as CoreMessage[]
const latestMessages = modifiedMessages.slice(maxMessages * -1)
answer = await writer(
currentSystemPrompt + calendarNotesContext,
(currentSystemPrompt ?? '') + calendarNotesContext,
uiStream,
streamText,
latestMessages
Expand Down
17 changes: 0 additions & 17 deletions lib/actions/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,6 @@ export async function saveNote(noteData: NewCalendarNote | CalendarNote): Promis
return savedNote;
});

if (result && result.chatId) {
const { createMessage } = await import('./chat-db');
await createMessage({
chatId: result.chatId,
userId: userId,
role: 'data',
content: JSON.stringify({
type: 'calendar_note',
note: {
...result,
locationTags,
userTags
},
}),
});
}

return result;
} catch (error) {
console.error('Error saving note:', error);
Expand Down
22 changes: 11 additions & 11 deletions lib/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ export const calendarNoteUserTags = pgTable('calendar_note_user_tags', {
noteTagUnique: unique('calendar_note_user_tags_note_tag_unique').on(t.noteId, t.tag),
}));

export const promptGenerationJobs = pgTable('prompt_generation_jobs', {
id: uuid('id').primaryKey().defaultRandom(),
userId: uuid('user_id').notNull().references(() => users.id, { onDelete: 'cascade' }),
domain: text('domain').notNull(),
status: text('status').notNull().default('pending'), // pending | processing | complete | error
resultPrompt: text('result_prompt'),
errorMessage: text('error_message'),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
});

// Relations
export const usersRelations = relations(users, ({ many }) => ({
chats: many(chats),
Expand Down Expand Up @@ -213,17 +224,6 @@ export const visualizationsRelations = relations(visualizations, ({ one }) => ({
}),
}));

export const promptGenerationJobs = pgTable('prompt_generation_jobs', {
id: uuid('id').primaryKey().defaultRandom(),
userId: uuid('user_id').notNull().references(() => users.id, { onDelete: 'cascade' }),
domain: text('domain').notNull(),
status: text('status').notNull().default('pending'), // pending | processing | complete | error
resultPrompt: text('result_prompt'),
errorMessage: text('error_message'),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
});

export const promptGenerationJobsRelations = relations(promptGenerationJobs, ({ one }) => ({
user: one(users, {
fields: [promptGenerationJobs.userId],
Expand Down