-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New pic #4858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
New pic #4858
Conversation
|
Preview mcp_server Image: |
Preview sandbox Image: |
Preview mcp_server Image: |
Preview sandbox Image: |
Preview mcp_server Image: |
Preview sandbox Image: |
Preview mcp_server Image: |
Preview sandbox Image: |
Preview fastgpt Image: |
Preview mcp_server Image: |
Preview sandbox Image: |
Preview fastgpt Image: |
Preview mcp_server Image: |
Preview sandbox Image: |
Preview fastgpt Image: |
Preview mcp_server Image: |
Preview sandbox Image: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个不用动
Preview mcp_server Image: |
Preview sandbox Image: |
Preview fastgpt Image: |
Preview mcp_server Image: |
Preview sandbox Image: |
Deployment Status: ✅ Success |
…based on data source type, improving the import process for non-image datasets.
…ings, enhancing error messages, and streamlining the preview URL generation process.
Preview mcp_server Image: |
Deployment Status: ✅ Success |
Preview sandbox Image: |
Preview fastgpt Image: |
Preview sandbox Image: |
Deployment Status: ✅ Success |
Preview mcp_server Image: |
Preview fastgpt Image: |
Preview mcp_server Image: |
Preview sandbox Image: |
Deployment Status: ✅ Success |
Preview mcp_server Image: |
Preview sandbox Image: |
Deployment Status: ✅ Success |
Preview fastgpt Image: |
@@ -11,7 +11,7 @@ export const fileImgs = [ | |||
// { suffix: '.', src: '/imgs/files/file.svg' } | |||
]; | |||
|
|||
export function getFileIcon(name = '', defaultImg = 'file/fill/file') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个能改么
@@ -81,6 +81,7 @@ export type ApiDatasetCreateDatasetCollectionParams = ApiCreateDatasetCollection | |||
}; | |||
export type FileIdCreateDatasetCollectionParams = ApiCreateDatasetCollectionParams & { | |||
fileId: string; | |||
collectionId?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
创建集合为啥要带个 collectionId
@@ -129,6 +130,7 @@ export type PushDatasetDataChunkProps = { | |||
a?: string; // bonus content | |||
chunkIndex?: number; | |||
indexes?: Omit<DatasetDataIndexItemType, 'dataId'>[]; | |||
imageFileId?: string; //file id preview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
放在 a 字段下面
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
检查其他地方的也是,不要把 q,a,imageId 分开写
@@ -0,0 +1,19 @@ | |||
export interface DatasetCollectionImageSchema { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
系统都是用 type,非必要不用 interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dataset/image/type.d.ts
这个表是图库,不是图片知识库。
@@ -0,0 +1,19 @@ | |||
export interface DatasetCollectionImageSchema { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DatasetImageSchema
@@ -56,6 +59,7 @@ export const createCollectionAndInsertData = async ({ | |||
|
|||
billId?: string; | |||
session?: ClientSession; | |||
parentCollectionId?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这是啥逻辑
@@ -156,7 +170,26 @@ export const createCollectionAndInsertData = async ({ | |||
return newBillId; | |||
})(); | |||
|
|||
// 5. insert to training queue | |||
// 5. Update the collectionId field in the image record (for image collections) | |||
if (createCollectionParams.metadata?.isImageCollection && createCollectionParams.fileId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
都说了,不能主动指定啥 isImageCollection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createImageCollection 是一个单独的 api,这个函数不应该有任何改动。
trainingType: DatasetCollectionSchemaType['trainingType']; | ||
autoIndexes?: DatasetCollectionSchemaType['autoIndexes']; | ||
imageIndex?: DatasetCollectionSchemaType['imageIndex']; | ||
export const getTrainingModeByCollection = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不用改,trainingType 已经有图片处理了
@@ -372,3 +411,38 @@ export async function delCollection({ | |||
); | |||
}); | |||
} | |||
|
|||
export async function pushImageFileToTrainingQueue({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要批量加,不能一个个加
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
重写这个文件。
- 在 rawText 改成可选。 rawText 统计增加一个 imageIdList 的字段,表示插入的图片 ID。
- 修复第一步:const chunks = 有 rawText 的话走分块。没有的话,把图片 ID 作为 chunks,chunks 结构改成: q,a,imageId
- 最后批量删除过期索引
|
||
/* ============= dataset images ========== */ | ||
|
||
export async function createDatasetImage({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
放到 dataset/image/controller.ts 里
return String(image._id); | ||
} | ||
|
||
export async function getDatasetImage(imageId: string): Promise<any> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不能写 any
|
||
export async function getDatasetImage(imageId: string): Promise<any> { | ||
try { | ||
if (!imageId || imageId.length !== 24) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Types.ObjectId(id).isValid() 可以校验
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Types 从 mongoose 引入
@@ -145,3 +147,69 @@ try { | |||
} | |||
|
|||
export const MongoDataset = getMongoModel<DatasetSchemaType>(DatasetCollectionName, DatasetSchema); | |||
|
|||
export const DatasetCollectionImageCollectionName = 'dataset_collection_images'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
写到 dataset/image/schema.ts 里
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已经有组件了
@@ -184,6 +184,8 @@ | |||
"comfirm_leave_page": "确认离开该页面?", | |||
"comfirn_create": "确认创建", | |||
"commercial_function_tip": "请升级商业版后使用该功能:https://doc.fastgpt.cn/docs/commercial/intro/", | |||
"common.Create Failed": "创建集合失败", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
放 dataset 里
@@ -1,4 +1,5 @@ | |||
{ | |||
" error?.message || t('core.dataset.collection.Create Failed'),\n status.core.dataset.collection.Create Failed": "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
异常数据
@@ -54,11 +54,14 @@ const QuoteList = React.memo(function QuoteList({ | |||
const processedData = rawSearch.map((item) => { | |||
if (chatItemDataId && quoteList) { | |||
const currentFilterItem = quoteList.find((res) => res._id === item.id); | |||
return { | |||
const result = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不用再单独起变量名
// indexes: DatasetDataSchemaType['indexes']; | ||
imageFileId?: string; | ||
imageSize?: number; | ||
previewUrl?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imagePreviewUrl
{t('dataset:retain_collection')} | ||
</Button> | ||
)} | ||
{datasetDetail.type !== 'websiteDataset' && !!collection?.chunkSize && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要乱改逻辑
@@ -283,11 +327,79 @@ const DataCard = () => { | |||
|
|||
{/* Data content */} | |||
<Box wordBreak={'break-all'} fontSize={'sm'}> | |||
<Markdown source={item.q} isDisabled /> | |||
{!!item.a && ( | |||
{isImageCollection ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不用管是不是 imageCollection,直接根据 data 里有没有 imagePreviewUrl 决定。有的话就渲染图片模式
alignSelf="stretch" | ||
borderRadius="md" | ||
overflow="hidden" | ||
bg="var(--Gray-Modern-100, #F4F4F7)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bg={'myGray.100'}
padding="8px 8px 10px 8px" | ||
justifyContent="center" | ||
alignItems="center" | ||
alignSelf="stretch" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接标签,
<Box | ||
flex="1 0 0" | ||
color="var(--Gray-Modern-800, #1D2532)" | ||
fontFamily="PingFang SC" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不用指定字体。
fontSize={"sm"}
lineheight,letterSpacing,maxHeight 不用指定
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
大部分情况下,只需要指定 padding,margin fontSize,fontweight,color 即可。其他样式都是全局的了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create/images
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有用么?
@@ -230,6 +233,15 @@ export async function insertData2Dataset({ | |||
{ session, ordered: true } | |||
); | |||
|
|||
// 4. Remove TTL from image if imageFileId exists (prevent image expiration during training) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insertData 不需要删 ttl,插入集合时候已经删过了。
需要再 insertData接口里进行 TTL 删除
await deleteDatasetDataVector({ | ||
teamId: data.teamId, | ||
idList: data.indexes.map((item) => item.dataId) | ||
}); | ||
|
||
// 3. If there are any image files, delete the image records. | ||
if (data.imageFileId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要 catch,就是需要抛错,事务是保障全部成功,如果失败就要回退。
|
||
// Handle imageFileId update | ||
if (imageFileId !== undefined) { | ||
await MongoDatasetData.findByIdAndUpdate(dataId, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
无效命令
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
还需要删除原data 里的图片
知识库导入图片