feat: tmp upgrade code (#3559)

* feat: tmp upgrade code

* fulltext search test

* update action
This commit is contained in:
Archer
2025-01-10 14:41:29 +08:00
committed by GitHub
parent 1c0b323b1b
commit fadb3e3ceb
9 changed files with 24 additions and 24 deletions

View File

@@ -36,7 +36,7 @@ jobs:
password: ${{ secrets.GH_PAT }} password: ${{ secrets.GH_PAT }}
- name: Set DOCKER_REPO_TAGGED based on branch or tag - name: Set DOCKER_REPO_TAGGED based on branch or tag
run: | run: |
echo "DOCKER_REPO_TAGGED=ghcr.io/${{ github.repository_owner }}/fastgpt-pr:${{ github.event.pull_request.number }}" >> $GITHUB_ENV echo "DOCKER_REPO_TAGGED=ghcr.io/${{ github.repository_owner }}/fastgpt-pr:${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
- name: Build image for PR - name: Build image for PR
env: env:
DOCKER_REPO_TAGGED: ${{ env.DOCKER_REPO_TAGGED }} DOCKER_REPO_TAGGED: ${{ env.DOCKER_REPO_TAGGED }}
@@ -44,7 +44,7 @@ jobs:
docker buildx build \ docker buildx build \
-f projects/app/Dockerfile \ -f projects/app/Dockerfile \
--label "org.opencontainers.image.source=https://github.com/${{ github.repository_owner }}/FastGPT" \ --label "org.opencontainers.image.source=https://github.com/${{ github.repository_owner }}/FastGPT" \
--label "org.opencontainers.image.description=fastgpt-pr imae" \ --label "org.opencontainers.image.description=fastgpt-pr image" \
--label "org.opencontainers.image.licenses=Apache" \ --label "org.opencontainers.image.licenses=Apache" \
--push \ --push \
--cache-from=type=local,src=/tmp/.buildx-cache \ --cache-from=type=local,src=/tmp/.buildx-cache \

View File

@@ -2,17 +2,12 @@ import { ErrType } from '../errorCode';
import { i18nT } from '../../../../web/i18n/utils'; import { i18nT } from '../../../../web/i18n/utils';
/* team: 503000 */ /* team: 503000 */
export enum UserErrEnum { export enum UserErrEnum {
unAuthUser = 'unAuthUser',
unAuthRole = 'unAuthRole', unAuthRole = 'unAuthRole',
binVisitor = 'binVisitor', binVisitor = 'binVisitor',
balanceNotEnough = 'balanceNotEnough', balanceNotEnough = 'balanceNotEnough',
unAuthSso = 'unAuthSso' unAuthSso = 'unAuthSso'
} }
const errList = [ const errList = [
{
statusText: UserErrEnum.unAuthUser,
message: i18nT('common:code_error.user_error.un_auth_user')
},
{ {
statusText: UserErrEnum.binVisitor, statusText: UserErrEnum.binVisitor,
message: i18nT('common:code_error.user_error.bin_visitor') message: i18nT('common:code_error.user_error.bin_visitor')

View File

@@ -29,14 +29,16 @@ const DatasetDataTextSchema = new Schema({
ref: DatasetDataCollectionName, ref: DatasetDataCollectionName,
required: true required: true
}, },
fullTextToken: { fullTextToken: String
type: String,
required: true
}
}); });
try { try {
DatasetDataTextSchema.index({ teamId: 1, datasetId: 1, fullTextToken: 'text' }); DatasetDataTextSchema.index(
{ teamId: 1, datasetId: 1, fullTextToken: 'text' },
{
partialFilterExpression: { fullTextToken: { $exists: true } }
}
);
DatasetDataTextSchema.index({ dataId: 1 }, { unique: true }); DatasetDataTextSchema.index({ dataId: 1 }, { unique: true });
} catch (error) { } catch (error) {
console.log(error); console.log(error);

View File

@@ -86,8 +86,8 @@ try {
chunkIndex: 1, chunkIndex: 1,
updateTime: -1 updateTime: -1
}); });
// full text index // FullText tmp full text index
// DatasetDataSchema.index({ teamId: 1, datasetId: 1, fullTextToken: 'text' }); DatasetDataSchema.index({ teamId: 1, datasetId: 1, fullTextToken: 'text' });
// Recall vectors after data matching // Recall vectors after data matching
DatasetDataSchema.index({ teamId: 1, datasetId: 1, collectionId: 1, 'indexes.dataId': 1 }); DatasetDataSchema.index({ teamId: 1, datasetId: 1, collectionId: 1, 'indexes.dataId': 1 });
DatasetDataSchema.index({ updateTime: 1 }); DatasetDataSchema.index({ updateTime: 1 });

View File

@@ -636,6 +636,7 @@ export async function searchDatasetData(props: SearchDatasetDataProps) {
forbidCollectionIdList, forbidCollectionIdList,
filterCollectionIdList filterCollectionIdList
}), }),
// FullText tmp
fullTextRecall2({ fullTextRecall2({
query, query,
limit: fullTextLimit, limit: fullTextLimit,

View File

@@ -18,7 +18,7 @@ export async function getUserChatInfoAndAuthTeamPoints(tmbId: string) {
]) ])
.lean(); .lean();
if (!tmb) return Promise.reject(UserErrEnum.unAuthUser); if (!tmb) return Promise.reject(UserErrEnum.binVisitor);
await checkTeamAIPoints(tmb.team._id); await checkTeamAIPoints(tmb.team._id);

View File

@@ -59,12 +59,12 @@ const initData = async (batchSize: number) => {
})), })),
{ ordered: false, session, lean: true } { ordered: false, session, lean: true }
); );
// 把成功插入的新数据的 dataId 更新为已初始化 // FullText tmp 把成功插入的新数据的 dataId 更新为已初始化
await MongoDatasetData.updateMany( // await MongoDatasetData.updateMany(
{ _id: { $in: result.map((item) => item.dataId) } }, // { _id: { $in: result.map((item) => item.dataId) } },
{ $set: { initFullText: true }, $unset: { fullTextToken: 1 } }, // { $set: { initFullText: true }, $unset: { fullTextToken: 1 } },
{ session } // { session }
); // );
success += result.length; success += result.length;

View File

@@ -25,7 +25,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
'status' 'status'
); );
if (!authCert) { if (!authCert) {
return Promise.reject(UserErrEnum.unAuthUser); return Promise.reject(UserErrEnum.binVisitor);
} }
if (authCert.status === UserStatusEnum.forbidden) { if (authCert.status === UserStatusEnum.forbidden) {

View File

@@ -89,7 +89,8 @@ export async function insertData2Dataset({
collectionId, collectionId,
q, q,
a, a,
// fullTextToken: jiebaSplit({ text: qaStr }), // FullText tmp
fullTextToken: jiebaSplit({ text: qaStr }),
chunkIndex, chunkIndex,
indexes: indexes?.map((item, i) => ({ indexes: indexes?.map((item, i) => ({
...item, ...item,
@@ -241,7 +242,8 @@ export async function updateData2Dataset({
// update mongo other data // update mongo other data
mongoData.q = q || mongoData.q; mongoData.q = q || mongoData.q;
mongoData.a = a ?? mongoData.a; mongoData.a = a ?? mongoData.a;
// mongoData.fullTextToken = jiebaSplit({ text: `${mongoData.q}\n${mongoData.a}`.trim() }); // FullText tmp
mongoData.fullTextToken = jiebaSplit({ text: `${mongoData.q}\n${mongoData.a}`.trim() });
// @ts-ignore // @ts-ignore
mongoData.indexes = newIndexes; mongoData.indexes = newIndexes;
await mongoData.save({ session }); await mongoData.save({ session });