General fixes. Still far from good or working

This commit is contained in:
2026-01-11 13:21:01 -05:00
parent 0a361f51a1
commit 67daefb919
83 changed files with 733 additions and 1053 deletions

View File

@@ -1,9 +1,9 @@
import { v } from "convex/values";
import OpenAI from "openai";
import { v } from 'convex/values';
import OpenAI from 'openai';
import { internal } from "./_generated/api";
import { internalAction, internalMutation, query } from "./_generated/server";
import { missingEnvVariableUrl } from "./utils";
import { internal } from './_generated/api';
import { internalAction, internalMutation, query } from './_generated/server';
import { missingEnvVariableUrl } from './utils';
export const openaiKeySet = query({
args: {},
@@ -14,7 +14,7 @@ export const openaiKeySet = query({
export const summary = internalAction({
args: {
id: v.id("notes"),
id: v.id('notes'),
title: v.string(),
content: v.string(),
},
@@ -24,8 +24,8 @@ export const summary = internalAction({
const apiKey = process.env.OPENAI_API_KEY;
if (!apiKey) {
const error = missingEnvVariableUrl(
"OPENAI_API_KEY",
"https://platform.openai.com/account/api-keys",
'OPENAI_API_KEY',
'https://platform.openai.com/account/api-keys',
);
console.error(error);
await ctx.runMutation(internal.openai.saveSummary, {
@@ -38,14 +38,14 @@ export const summary = internalAction({
const output = await openai.chat.completions.create({
messages: [
{
role: "system",
role: 'system',
content:
"You are a helpful assistant designed to output JSON in this format: {summary: string}",
'You are a helpful assistant designed to output JSON in this format: {summary: string}',
},
{ role: "user", content: prompt },
{ role: 'user', content: prompt },
],
model: "gpt-4-1106-preview",
response_format: { type: "json_object" },
model: 'gpt-4-1106-preview',
response_format: { type: 'json_object' },
});
// Pull the message content out of the response
@@ -65,7 +65,7 @@ export const summary = internalAction({
export const saveSummary = internalMutation({
args: {
id: v.id("notes"),
id: v.id('notes'),
summary: v.string(),
},
handler: async (ctx, { id, summary }) => {