feat: 大量优化和bug修复
This commit is contained in:
@@ -22,6 +22,7 @@ import { prisma } from "~~/server/utils/db";
|
||||
import { createApiLogger, toSafeLogError } from "~~/server/utils/logging";
|
||||
import { askAnswerStream } from "~~/server/utils/openai";
|
||||
import { addQaRecord, lookupCachedAnswer } from "~~/server/utils/runtimeState";
|
||||
import { getUserEffectiveApiConfig } from "~~/server/utils/sysConfig";
|
||||
|
||||
/**
|
||||
* 把 query/body/form 中的值统一转成字符串
|
||||
@@ -166,6 +167,10 @@ export default defineEventHandler(async (event) => {
|
||||
return createOcsErrorResponse("请先登录或提供有效 token");
|
||||
}
|
||||
|
||||
// 读取用户生效配置:如果用户开启了自定义 API 且完整填写,则使用自定义 base+key
|
||||
// 否则完全回退到系统配置,保证系统 key 不流向用户自定义的 endpoint
|
||||
const effectiveCfg = await getUserEffectiveApiConfig(userId);
|
||||
|
||||
logger.info("read_question", {
|
||||
questionLength: params.title.length,
|
||||
type: params.type,
|
||||
@@ -196,7 +201,8 @@ export default defineEventHandler(async (event) => {
|
||||
);
|
||||
const streamResult = await askAnswerStream({
|
||||
prompt,
|
||||
systemPrompt: ANSWER_SYSTEM_PROMPT
|
||||
systemPrompt: ANSWER_SYSTEM_PROMPT,
|
||||
cfg: effectiveCfg
|
||||
});
|
||||
const processedAnswer = extractAnswer(streamResult.answer, params.type);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user