fix: ts (#4948)
This commit is contained in:
parent
92c38d9d2f
commit
86f5a68d8c
11
packages/global/core/dataset/type.d.ts
vendored
11
packages/global/core/dataset/type.d.ts
vendored
@ -286,3 +286,14 @@ export type SearchDataResponseItemType = Omit<
|
|||||||
score: { type: `${SearchScoreTypeEnum}`; value: number; index: number }[];
|
score: { type: `${SearchScoreTypeEnum}`; value: number; index: number }[];
|
||||||
// score: number;
|
// score: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type DatasetCiteItemType = {
|
||||||
|
_id: string;
|
||||||
|
q: string;
|
||||||
|
a?: string;
|
||||||
|
imagePreivewUrl?: string;
|
||||||
|
history?: DatasetDataSchemaType['history'];
|
||||||
|
updateTime: DatasetDataSchemaType['updateTime'];
|
||||||
|
index: DatasetDataSchemaType['chunkIndex'];
|
||||||
|
updated?: boolean;
|
||||||
|
};
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { getDatasetImagePreviewUrl } from '../image/utils';
|
import { getDatasetImagePreviewUrl } from '../image/utils';
|
||||||
import type { QuoteDataItemType } from '../../../../../projects/app/src/service/core/chat/constants';
|
import type { DatasetCiteItemType, DatasetDataSchemaType } from '@fastgpt/global/core/dataset/type';
|
||||||
import type { DatasetDataSchemaType } from '@fastgpt/global/core/dataset/type';
|
|
||||||
|
|
||||||
export const formatDatasetDataValue = ({
|
export const formatDatasetDataValue = ({
|
||||||
q,
|
q,
|
||||||
@ -41,7 +40,7 @@ export const formatDatasetDataValue = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getFormatDatasetCiteList = (list: DatasetDataSchemaType[]) => {
|
export const getFormatDatasetCiteList = (list: DatasetDataSchemaType[]) => {
|
||||||
return list.map<QuoteDataItemType>((item) => ({
|
return list.map<DatasetCiteItemType>((item) => ({
|
||||||
_id: item._id,
|
_id: item._id,
|
||||||
...formatDatasetDataValue({
|
...formatDatasetDataValue({
|
||||||
teamId: item.teamId,
|
teamId: item.teamId,
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
import { Box, Flex, HStack } from '@chakra-ui/react';
|
import { Box, Flex, HStack } from '@chakra-ui/react';
|
||||||
import { type SearchDataResponseItemType } from '@fastgpt/global/core/dataset/type';
|
import {
|
||||||
|
type DatasetCiteItemType,
|
||||||
|
type SearchDataResponseItemType
|
||||||
|
} from '@fastgpt/global/core/dataset/type';
|
||||||
import { getSourceNameIcon } from '@fastgpt/global/core/dataset/utils';
|
import { getSourceNameIcon } from '@fastgpt/global/core/dataset/utils';
|
||||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
@ -20,7 +23,6 @@ import { getCollectionQuote } from '@/web/core/chat/api';
|
|||||||
import MyIconButton from '@fastgpt/web/components/common/Icon/button';
|
import MyIconButton from '@fastgpt/web/components/common/Icon/button';
|
||||||
import MyBox from '@fastgpt/web/components/common/MyBox';
|
import MyBox from '@fastgpt/web/components/common/MyBox';
|
||||||
import { getCollectionSourceAndOpen } from '@/web/core/dataset/hooks/readCollectionSource';
|
import { getCollectionSourceAndOpen } from '@/web/core/dataset/hooks/readCollectionSource';
|
||||||
import { type QuoteDataItemType } from '@/service/core/chat/constants';
|
|
||||||
|
|
||||||
const CollectionReader = ({
|
const CollectionReader = ({
|
||||||
rawSearch,
|
rawSearch,
|
||||||
@ -99,7 +101,7 @@ const CollectionReader = ({
|
|||||||
|
|
||||||
const formatedDataList = useMemo(
|
const formatedDataList = useMemo(
|
||||||
() =>
|
() =>
|
||||||
datasetDataList.map((item: QuoteDataItemType) => {
|
datasetDataList.map((item: DatasetCiteItemType) => {
|
||||||
const isCurrentSelected = currentQuoteItem?.id === item._id;
|
const isCurrentSelected = currentQuoteItem?.id === item._id;
|
||||||
const quoteIndex = filterResults.findIndex((res) => res.id === item._id);
|
const quoteIndex = filterResults.findIndex((res) => res.id === item._id);
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
import { NextAPI } from '@/service/middleware/entry';
|
import { NextAPI } from '@/service/middleware/entry';
|
||||||
import { authChatCrud, authCollectionInChat } from '@/service/support/permission/auth/chat';
|
import { authChatCrud, authCollectionInChat } from '@/service/support/permission/auth/chat';
|
||||||
import { type DatasetDataSchemaType } from '@fastgpt/global/core/dataset/type';
|
import {
|
||||||
|
type DatasetCiteItemType,
|
||||||
|
type DatasetDataSchemaType
|
||||||
|
} from '@fastgpt/global/core/dataset/type';
|
||||||
import { MongoDatasetData } from '@fastgpt/service/core/dataset/data/schema';
|
import { MongoDatasetData } from '@fastgpt/service/core/dataset/data/schema';
|
||||||
import { type ApiRequestProps } from '@fastgpt/service/type/next';
|
import { type ApiRequestProps } from '@fastgpt/service/type/next';
|
||||||
import {
|
import {
|
||||||
@ -8,7 +11,7 @@ import {
|
|||||||
type LinkedPaginationProps
|
type LinkedPaginationProps
|
||||||
} from '@fastgpt/web/common/fetch/type';
|
} from '@fastgpt/web/common/fetch/type';
|
||||||
import { type FilterQuery, Types } from 'mongoose';
|
import { type FilterQuery, Types } from 'mongoose';
|
||||||
import { quoteDataFieldSelector, type QuoteDataItemType } from '@/service/core/chat/constants';
|
import { quoteDataFieldSelector } from '@/service/core/chat/constants';
|
||||||
import { processChatTimeFilter } from '@/service/core/chat/utils';
|
import { processChatTimeFilter } from '@/service/core/chat/utils';
|
||||||
import { ChatErrEnum } from '@fastgpt/global/common/error/code/chat';
|
import { ChatErrEnum } from '@fastgpt/global/common/error/code/chat';
|
||||||
import { getCollectionWithDataset } from '@fastgpt/service/core/dataset/controller';
|
import { getCollectionWithDataset } from '@fastgpt/service/core/dataset/controller';
|
||||||
@ -27,7 +30,7 @@ export type GetCollectionQuoteProps = LinkedPaginationProps & {
|
|||||||
teamToken?: string;
|
teamToken?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type GetCollectionQuoteRes = LinkedListResponse<QuoteDataItemType>;
|
export type GetCollectionQuoteRes = LinkedListResponse<DatasetCiteItemType>;
|
||||||
|
|
||||||
type BaseMatchType = FilterQuery<DatasetDataSchemaType>;
|
type BaseMatchType = FilterQuery<DatasetDataSchemaType>;
|
||||||
|
|
||||||
|
|||||||
@ -2,13 +2,11 @@ import { NextAPI } from '@/service/middleware/entry';
|
|||||||
import { authChatCrud, authCollectionInChat } from '@/service/support/permission/auth/chat';
|
import { authChatCrud, authCollectionInChat } from '@/service/support/permission/auth/chat';
|
||||||
import { MongoDatasetData } from '@fastgpt/service/core/dataset/data/schema';
|
import { MongoDatasetData } from '@fastgpt/service/core/dataset/data/schema';
|
||||||
import { type ApiRequestProps } from '@fastgpt/service/type/next';
|
import { type ApiRequestProps } from '@fastgpt/service/type/next';
|
||||||
import { quoteDataFieldSelector, type QuoteDataItemType } from '@/service/core/chat/constants';
|
import { quoteDataFieldSelector } from '@/service/core/chat/constants';
|
||||||
import { processChatTimeFilter } from '@/service/core/chat/utils';
|
import { processChatTimeFilter } from '@/service/core/chat/utils';
|
||||||
import { ChatErrEnum } from '@fastgpt/global/common/error/code/chat';
|
import { ChatErrEnum } from '@fastgpt/global/common/error/code/chat';
|
||||||
import {
|
import { getFormatDatasetCiteList } from '@fastgpt/service/core/dataset/data/controller';
|
||||||
formatDatasetDataValue,
|
import type { DatasetCiteItemType } from '@fastgpt/global/core/dataset/type';
|
||||||
getFormatDatasetCiteList
|
|
||||||
} from '@fastgpt/service/core/dataset/data/controller';
|
|
||||||
|
|
||||||
export type GetQuoteProps = {
|
export type GetQuoteProps = {
|
||||||
datasetDataIdList: string[];
|
datasetDataIdList: string[];
|
||||||
@ -23,7 +21,7 @@ export type GetQuoteProps = {
|
|||||||
teamToken?: string;
|
teamToken?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type GetQuotesRes = QuoteDataItemType[];
|
export type GetQuotesRes = DatasetCiteItemType[];
|
||||||
|
|
||||||
async function handler(req: ApiRequestProps<GetQuoteProps>): Promise<GetQuotesRes> {
|
async function handler(req: ApiRequestProps<GetQuoteProps>): Promise<GetQuotesRes> {
|
||||||
const {
|
const {
|
||||||
|
|||||||
@ -2,14 +2,3 @@ import { type DatasetDataSchemaType } from '@fastgpt/global/core/dataset/type';
|
|||||||
|
|
||||||
export const quoteDataFieldSelector =
|
export const quoteDataFieldSelector =
|
||||||
'_id teamId datasetId q a imageId history updateTime chunkIndex';
|
'_id teamId datasetId q a imageId history updateTime chunkIndex';
|
||||||
|
|
||||||
export type QuoteDataItemType = {
|
|
||||||
_id: string;
|
|
||||||
q: string;
|
|
||||||
a?: string;
|
|
||||||
imagePreivewUrl?: string;
|
|
||||||
history?: DatasetDataSchemaType['history'];
|
|
||||||
updateTime: DatasetDataSchemaType['updateTime'];
|
|
||||||
index: DatasetDataSchemaType['chunkIndex'];
|
|
||||||
updated?: boolean;
|
|
||||||
};
|
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import { type QuoteDataItemType } from './constants';
|
import type { DatasetCiteItemType } from '@fastgpt/global/core/dataset/type';
|
||||||
|
|
||||||
// 获取对话时间时,引用的内容
|
// 获取对话时间时,引用的内容
|
||||||
export function processChatTimeFilter(
|
export function processChatTimeFilter(
|
||||||
dataList: QuoteDataItemType[],
|
dataList: DatasetCiteItemType[],
|
||||||
chatTime: Date
|
chatTime: Date
|
||||||
): QuoteDataItemType[] {
|
): DatasetCiteItemType[] {
|
||||||
return dataList.map((item) => {
|
return dataList.map((item) => {
|
||||||
const defaultItem = item;
|
const defaultItem = item;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user