Skip to content

Commit

Permalink
feat: tmp upgrade code (#3559)
Browse files Browse the repository at this point in the history
* feat: tmp upgrade code

* fulltext search test

* update action
  • Loading branch information
c121914yu authored Jan 10, 2025
1 parent 1c0b323 commit fadb3e3
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/preview-fastgpt-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ jobs:
password: ${{ secrets.GH_PAT }}
- name: Set DOCKER_REPO_TAGGED based on branch or tag
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
env:
DOCKER_REPO_TAGGED: ${{ env.DOCKER_REPO_TAGGED }}
run: |
docker buildx build \
-f projects/app/Dockerfile \
--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" \
--push \
--cache-from=type=local,src=/tmp/.buildx-cache \
Expand Down
5 changes: 0 additions & 5 deletions packages/global/common/error/code/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ import { ErrType } from '../errorCode';
import { i18nT } from '../../../../web/i18n/utils';
/* team: 503000 */
export enum UserErrEnum {
unAuthUser = 'unAuthUser',
unAuthRole = 'unAuthRole',
binVisitor = 'binVisitor',
balanceNotEnough = 'balanceNotEnough',
unAuthSso = 'unAuthSso'
}
const errList = [
{
statusText: UserErrEnum.unAuthUser,
message: i18nT('common:code_error.user_error.un_auth_user')
},
{
statusText: UserErrEnum.binVisitor,
message: i18nT('common:code_error.user_error.bin_visitor')
Expand Down
12 changes: 7 additions & 5 deletions packages/service/core/dataset/data/dataTextSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ const DatasetDataTextSchema = new Schema({
ref: DatasetDataCollectionName,
required: true
},
fullTextToken: {
type: String,
required: true
}
fullTextToken: String
});

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 });
} catch (error) {
console.log(error);
Expand Down
4 changes: 2 additions & 2 deletions packages/service/core/dataset/data/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ try {
chunkIndex: 1,
updateTime: -1
});
// full text index
// DatasetDataSchema.index({ teamId: 1, datasetId: 1, fullTextToken: 'text' });
// FullText tmp full text index
DatasetDataSchema.index({ teamId: 1, datasetId: 1, fullTextToken: 'text' });
// Recall vectors after data matching
DatasetDataSchema.index({ teamId: 1, datasetId: 1, collectionId: 1, 'indexes.dataId': 1 });
DatasetDataSchema.index({ updateTime: 1 });
Expand Down
1 change: 1 addition & 0 deletions packages/service/core/dataset/search/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ export async function searchDatasetData(props: SearchDatasetDataProps) {
forbidCollectionIdList,
filterCollectionIdList
}),
// FullText tmp
fullTextRecall2({
query,
limit: fullTextLimit,
Expand Down
2 changes: 1 addition & 1 deletion packages/service/support/permission/auth/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function getUserChatInfoAndAuthTeamPoints(tmbId: string) {
])
.lean();

if (!tmb) return Promise.reject(UserErrEnum.unAuthUser);
if (!tmb) return Promise.reject(UserErrEnum.binVisitor);

await checkTeamAIPoints(tmb.team._id);

Expand Down
12 changes: 6 additions & 6 deletions projects/app/src/pages/api/admin/initv4818.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ const initData = async (batchSize: number) => {
})),
{ ordered: false, session, lean: true }
);
// 把成功插入的新数据的 dataId 更新为已初始化
await MongoDatasetData.updateMany(
{ _id: { $in: result.map((item) => item.dataId) } },
{ $set: { initFullText: true }, $unset: { fullTextToken: 1 } },
{ session }
);
// FullText tmp 把成功插入的新数据的 dataId 更新为已初始化
// await MongoDatasetData.updateMany(
// { _id: { $in: result.map((item) => item.dataId) } },
// { $set: { initFullText: true }, $unset: { fullTextToken: 1 } },
// { session }
// );

success += result.length;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
'status'
);
if (!authCert) {
return Promise.reject(UserErrEnum.unAuthUser);
return Promise.reject(UserErrEnum.binVisitor);
}

if (authCert.status === UserStatusEnum.forbidden) {
Expand Down
6 changes: 4 additions & 2 deletions projects/app/src/service/core/dataset/data/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ export async function insertData2Dataset({
collectionId,
q,
a,
// fullTextToken: jiebaSplit({ text: qaStr }),
// FullText tmp
fullTextToken: jiebaSplit({ text: qaStr }),
chunkIndex,
indexes: indexes?.map((item, i) => ({
...item,
Expand Down Expand Up @@ -241,7 +242,8 @@ export async function updateData2Dataset({
// update mongo other data
mongoData.q = q || mongoData.q;
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
mongoData.indexes = newIndexes;
await mongoData.save({ session });
Expand Down

0 comments on commit fadb3e3

Please sign in to comment.