test
This commit is contained in:
10
convex/_generated/api.d.ts
vendored
10
convex/_generated/api.d.ts
vendored
@@ -8,11 +8,8 @@
|
||||
* @module
|
||||
*/
|
||||
|
||||
import type * as abcv from "../abcv.js";
|
||||
import type * as actions_jwt from "../actions/jwt.js";
|
||||
import type * as actions_redis from "../actions/redis.js";
|
||||
import type * as http from "../http.js";
|
||||
import type * as xiong from "../xiong.js";
|
||||
|
||||
import type {
|
||||
ApiFromModules,
|
||||
@@ -21,11 +18,8 @@ import type {
|
||||
} from "convex/server";
|
||||
|
||||
declare const fullApi: ApiFromModules<{
|
||||
abcv: typeof abcv;
|
||||
"actions/jwt": typeof actions_jwt;
|
||||
"actions/redis": typeof actions_redis;
|
||||
http: typeof http;
|
||||
xiong: typeof xiong;
|
||||
}>;
|
||||
|
||||
/**
|
||||
@@ -54,4 +48,6 @@ export declare const internal: FilterApi<
|
||||
FunctionReference<any, "internal">
|
||||
>;
|
||||
|
||||
export declare const components: {};
|
||||
export declare const components: {
|
||||
component: {};
|
||||
};
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
import { query, mutation, action } from "./_generated/server";
|
||||
import { Kevisual } from '@kevisual/ai/browser'
|
||||
import { v } from "convex/values";
|
||||
export const get = query({
|
||||
args: {},
|
||||
handler: async (ctx) => {
|
||||
const auth = await ctx.auth.getUserIdentity();
|
||||
console.log("Query abcv.get called, auth:", auth);
|
||||
if (auth) {
|
||||
console.log("Authenticated user ID:", auth.subject);
|
||||
}
|
||||
return await ctx.db.query("abcv").collect();
|
||||
},
|
||||
});
|
||||
// import { query, mutation, action } from "./_generated/server";
|
||||
// import { Kevisual } from '@kevisual/ai/browser'
|
||||
// import { v } from "convex/values";
|
||||
// export const get = query({
|
||||
// args: {},
|
||||
// handler: async (ctx) => {
|
||||
// const auth = await ctx.auth.getUserIdentity();
|
||||
// console.log("Query abcv.get called, auth:", auth);
|
||||
// if (auth) {
|
||||
// console.log("Authenticated user ID:", auth.subject);
|
||||
// }
|
||||
// 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 || "",
|
||||
});
|
||||
// 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;
|
||||
},
|
||||
});
|
||||
// const response = await kevisual.chat({
|
||||
// messages: [
|
||||
// { role: "user", content: message }
|
||||
// ]
|
||||
// })
|
||||
// return kevisual.responseText;
|
||||
// },
|
||||
// });
|
||||
@@ -1,22 +1,22 @@
|
||||
'use node';
|
||||
// 'use node';
|
||||
|
||||
import { query, mutation, action } from "../_generated/server";
|
||||
import { Kevisual } from '@kevisual/ai/browser'
|
||||
import { v } from "convex/values";
|
||||
import { Redis } from "ioredis";
|
||||
const redisClient = new Redis({
|
||||
host: process.env.REDIS_HOST,
|
||||
password: process.env.REDIS_PASSWORD,
|
||||
});
|
||||
let time: any = null;
|
||||
export const isConnected = action({
|
||||
args: {},
|
||||
handler: async (ctx) => {
|
||||
const result = await redisClient.ping();
|
||||
if (time === null) {
|
||||
time = new Date();
|
||||
}
|
||||
console.log("Redis PING at", new Date().toISOString(), "since", time);
|
||||
return result === "PONG";
|
||||
},
|
||||
});
|
||||
// import { query, mutation, action } from "../_generated/server";
|
||||
// import { Kevisual } from '@kevisual/ai/browser'
|
||||
// import { v } from "convex/values";
|
||||
// import { Redis } from "ioredis";
|
||||
// const redisClient = new Redis({
|
||||
// host: process.env.REDIS_HOST,
|
||||
// password: process.env.REDIS_PASSWORD,
|
||||
// });
|
||||
// let time: any = null;
|
||||
// export const isConnected = action({
|
||||
// args: {},
|
||||
// handler: async (ctx) => {
|
||||
// const result = await redisClient.ping();
|
||||
// if (time === null) {
|
||||
// time = new Date();
|
||||
// }
|
||||
// console.log("Redis PING at", new Date().toISOString(), "since", time);
|
||||
// return result === "PONG";
|
||||
// },
|
||||
// });
|
||||
8
convex/convex.config.ts
Normal file
8
convex/convex.config.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { defineApp } from "convex/server";
|
||||
import myComponent from "../component/convex.config.ts";
|
||||
|
||||
const app = defineApp();
|
||||
|
||||
// app.use(myComponent);
|
||||
|
||||
export default app;
|
||||
@@ -3,23 +3,23 @@ import { v } from "convex/values";
|
||||
import { authTables } from "@convex-dev/auth/server";
|
||||
// Define a messages table with an index.
|
||||
export default defineSchema({
|
||||
abcv: defineTable({
|
||||
title: v.string(),
|
||||
}),
|
||||
xiong: defineTable({
|
||||
name: v.string(),
|
||||
title: v.string(),
|
||||
}),
|
||||
users: defineTable({
|
||||
id: v.string(), // 外部系统的用户 ID
|
||||
name: v.string(),
|
||||
createdAt: v.string(),
|
||||
lastLoginAt: v.optional(v.string()),
|
||||
}).index("id", ["id"]),
|
||||
sessions: defineTable({
|
||||
userId: v.id("users"),
|
||||
createdAt: v.string(),
|
||||
expiresAt: v.optional(v.string()),
|
||||
token: v.optional(v.string()),
|
||||
}).index("token", ["token"]),
|
||||
// abcv: defineTable({
|
||||
// title: v.string(),
|
||||
// }),
|
||||
// xiong: defineTable({
|
||||
// name: v.string(),
|
||||
// title: v.string(),
|
||||
// }),
|
||||
// users: defineTable({
|
||||
// id: v.string(), // 外部系统的用户 ID
|
||||
// name: v.string(),
|
||||
// createdAt: v.string(),
|
||||
// lastLoginAt: v.optional(v.string()),
|
||||
// }).index("id", ["id"]),
|
||||
// sessions: defineTable({
|
||||
// userId: v.id("users"),
|
||||
// createdAt: v.string(),
|
||||
// expiresAt: v.optional(v.string()),
|
||||
// token: v.optional(v.string()),
|
||||
// }).index("token", ["token"]),
|
||||
});
|
||||
9
convex/wrapper.ts
Normal file
9
convex/wrapper.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
// import { query } from "./_generated/server";
|
||||
// import { components } from "./_generated/api";
|
||||
|
||||
// export const getTest2 = query({
|
||||
// args: {},
|
||||
// handler: async (ctx) => {
|
||||
// return await ctx.runQuery(components.component.test2.get);
|
||||
// },
|
||||
// });
|
||||
@@ -1,8 +1,8 @@
|
||||
import { query, mutation, action } from "./_generated/server";
|
||||
// import { query, mutation, action } from "./_generated/server";
|
||||
|
||||
export const get = query({
|
||||
args: {},
|
||||
handler: async (ctx) => {
|
||||
return await ctx.db.query("xiong").collect();
|
||||
},
|
||||
});
|
||||
// export const get = query({
|
||||
// args: {},
|
||||
// handler: async (ctx) => {
|
||||
// return await ctx.db.query("xiong").collect();
|
||||
// },
|
||||
// });
|
||||
Reference in New Issue
Block a user