mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-20 02:34:52 +00:00
fix: file_id undefined bug (#275)
This commit is contained in:
@@ -3,7 +3,9 @@ import type { NextApiRequest, NextApiResponse } from 'next';
|
|||||||
import { jsonRes } from '@/service/response';
|
import { jsonRes } from '@/service/response';
|
||||||
import { authUser } from '@/service/utils/auth';
|
import { authUser } from '@/service/utils/auth';
|
||||||
import { connectToDatabase, KB } from '@/service/mongo';
|
import { connectToDatabase, KB } from '@/service/mongo';
|
||||||
import { KbTypeEnum, KbTypeMap } from '@/constants/kb';
|
import { KbTypeEnum } from '@/constants/kb';
|
||||||
|
import { PgClient } from '@/service/pg';
|
||||||
|
import { PgTrainingTableName } from '@/constants/plugin';
|
||||||
|
|
||||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
try {
|
try {
|
||||||
@@ -22,7 +24,14 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
jsonRes(res, {});
|
const response = await PgClient.update(PgTrainingTableName, {
|
||||||
|
where: [['file_id', 'undefined']],
|
||||||
|
values: [{ key: 'file_id', value: '' }]
|
||||||
|
});
|
||||||
|
|
||||||
|
jsonRes(res, {
|
||||||
|
data: response.rowCount
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
jsonRes(res, {
|
jsonRes(res, {
|
||||||
code: 500,
|
code: 500,
|
||||||
|
@@ -68,6 +68,7 @@ export async function getVector({
|
|||||||
)
|
)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (!res.data?.data?.[0]?.embedding) {
|
if (!res.data?.data?.[0]?.embedding) {
|
||||||
|
console.log(res.data);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return Promise.reject(res.data?.err?.message || 'Embedding API Error');
|
return Promise.reject(res.data?.err?.message || 'Embedding API Error');
|
||||||
}
|
}
|
||||||
|
@@ -179,7 +179,7 @@ export const insertKbItem = ({
|
|||||||
{ key: 'user_id', value: userId },
|
{ key: 'user_id', value: userId },
|
||||||
{ key: 'kb_id', value: kbId },
|
{ key: 'kb_id', value: kbId },
|
||||||
{ key: 'source', value: item.source?.slice(0, 30)?.trim() || '' },
|
{ key: 'source', value: item.source?.slice(0, 30)?.trim() || '' },
|
||||||
{ key: 'file_id', value: item.file_id },
|
{ key: 'file_id', value: item.file_id || '' },
|
||||||
{ key: 'q', value: item.q.replace(/'/g, '"') },
|
{ key: 'q', value: item.q.replace(/'/g, '"') },
|
||||||
{ key: 'a', value: item.a.replace(/'/g, '"') },
|
{ key: 'a', value: item.a.replace(/'/g, '"') },
|
||||||
{ key: 'vector', value: `[${item.vector}]` }
|
{ key: 'vector', value: `[${item.vector}]` }
|
||||||
|
Reference in New Issue
Block a user