28 lines
769 B
TypeScript
28 lines
769 B
TypeScript
import { query, mutation, action } from "./_generated/server";
|
|
import { Kevisual } from '@kevisual/ai/browser'
|
|
import { v } from "convex/values";
|
|
import { } from "convex/server";
|
|
export const get = query({
|
|
args: {},
|
|
handler: async (ctx) => {
|
|
const auth = await ctx.auth.getUserIdentity();
|
|
console.log("Query abcv.get called", auth);
|
|
return await ctx.db.query("abcv").collect();
|
|
},
|
|
});
|
|
|
|
export const chat = action({
|
|
args: { message: v.string() },
|
|
handler: async (ctx, { message }) => {
|
|
const kevisual = new Kevisual({
|
|
apiKey: process.env.KEVISUAL_NEW_API_KEY || "",
|
|
});
|
|
|
|
const response = await kevisual.chat({
|
|
messages: [
|
|
{ role: "user", content: message }
|
|
]
|
|
})
|
|
return kevisual.responseText;
|
|
},
|
|
});
|