mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-11 02:29:00 +08:00
fix: cover missed source paths for eslint (#1956)
This commit is contained in:
parent
5ff701ca3f
commit
69d42ae95b
@ -10,20 +10,21 @@ export type WorkspacesContextValue = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const WorkspacesContext = createContext<WorkspacesContextValue>({
|
const WorkspacesContext = createContext<WorkspacesContextValue>({
|
||||||
workspaces: []
|
workspaces: [],
|
||||||
})
|
})
|
||||||
|
|
||||||
interface IWorkspaceProviderProps {
|
type IWorkspaceProviderProps = {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WorkspaceProvider = ({
|
export const WorkspaceProvider = ({
|
||||||
children
|
children,
|
||||||
}: IWorkspaceProviderProps) => {
|
}: IWorkspaceProviderProps) => {
|
||||||
const { data } = useSWR({ url: '/workspaces' }, fetchWorkspaces)
|
const { data } = useSWR({ url: '/workspaces' }, fetchWorkspaces)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WorkspacesContext.Provider value={{
|
<WorkspacesContext.Provider value={{
|
||||||
workspaces: data?.workspaces || []
|
workspaces: data?.workspaces || [],
|
||||||
}}>
|
}}>
|
||||||
{children}
|
{children}
|
||||||
</WorkspacesContext.Provider>
|
</WorkspacesContext.Provider>
|
||||||
|
@ -1,44 +1,45 @@
|
|||||||
"use client";
|
'use client'
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from 'react-i18next'
|
||||||
import dayjs from "dayjs";
|
import dayjs from 'dayjs'
|
||||||
import { formatNumber, formatFileSize, formatTime } from '@/utils/format'
|
import { formatFileSize, formatNumber, formatTime } from '@/utils/format'
|
||||||
import type { DocType } from '@/models/datasets'
|
import type { DocType } from '@/models/datasets'
|
||||||
|
|
||||||
export type inputType = 'input' | 'select' | 'textarea'
|
export type inputType = 'input' | 'select' | 'textarea'
|
||||||
export type metadataType = DocType | 'originInfo' | 'technicalParameters'
|
export type metadataType = DocType | 'originInfo' | 'technicalParameters'
|
||||||
|
|
||||||
type MetadataMap = Record<
|
type MetadataMap =
|
||||||
metadataType,
|
Record<
|
||||||
{
|
metadataType,
|
||||||
text: string;
|
{
|
||||||
allowEdit?: boolean;
|
text: string
|
||||||
icon?: React.ReactNode;
|
allowEdit?: boolean
|
||||||
iconName?: string;
|
icon?: React.ReactNode
|
||||||
subFieldsMap: Record<
|
iconName?: string
|
||||||
|
subFieldsMap: Record<
|
||||||
string,
|
string,
|
||||||
{
|
{
|
||||||
label: string;
|
label: string
|
||||||
inputType?: inputType;
|
inputType?: inputType
|
||||||
field?: string;
|
field?: string
|
||||||
render?: (value: any, total?: number) => React.ReactNode | string
|
render?: (value: any, total?: number) => React.ReactNode | string
|
||||||
}
|
}
|
||||||
>;
|
>
|
||||||
}
|
}
|
||||||
>;
|
>
|
||||||
|
|
||||||
const fieldPrefix = "datasetDocuments.metadata.field";
|
const fieldPrefix = 'datasetDocuments.metadata.field'
|
||||||
|
|
||||||
export const useMetadataMap = (): MetadataMap => {
|
export const useMetadataMap = (): MetadataMap => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation()
|
||||||
return {
|
return {
|
||||||
book: {
|
book: {
|
||||||
text: t("datasetDocuments.metadata.type.book"),
|
text: t('datasetDocuments.metadata.type.book'),
|
||||||
iconName: "bookOpen",
|
iconName: 'bookOpen',
|
||||||
subFieldsMap: {
|
subFieldsMap: {
|
||||||
title: { label: t(`${fieldPrefix}.book.title`) },
|
title: { label: t(`${fieldPrefix}.book.title`) },
|
||||||
language: {
|
language: {
|
||||||
label: t(`${fieldPrefix}.book.language`),
|
label: t(`${fieldPrefix}.book.language`),
|
||||||
inputType: "select",
|
inputType: 'select',
|
||||||
},
|
},
|
||||||
author: { label: t(`${fieldPrefix}.book.author`) },
|
author: { label: t(`${fieldPrefix}.book.author`) },
|
||||||
publisher: { label: t(`${fieldPrefix}.book.publisher`) },
|
publisher: { label: t(`${fieldPrefix}.book.publisher`) },
|
||||||
@ -46,346 +47,346 @@ export const useMetadataMap = (): MetadataMap => {
|
|||||||
isbn: { label: t(`${fieldPrefix}.book.ISBN`) },
|
isbn: { label: t(`${fieldPrefix}.book.ISBN`) },
|
||||||
category: {
|
category: {
|
||||||
label: t(`${fieldPrefix}.book.category`),
|
label: t(`${fieldPrefix}.book.category`),
|
||||||
inputType: "select",
|
inputType: 'select',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
web_page: {
|
web_page: {
|
||||||
text: t("datasetDocuments.metadata.type.webPage"),
|
text: t('datasetDocuments.metadata.type.webPage'),
|
||||||
iconName: "globe",
|
iconName: 'globe',
|
||||||
subFieldsMap: {
|
subFieldsMap: {
|
||||||
title: { label: t(`${fieldPrefix}.webPage.title`) },
|
'title': { label: t(`${fieldPrefix}.webPage.title`) },
|
||||||
url: { label: t(`${fieldPrefix}.webPage.url`) },
|
'url': { label: t(`${fieldPrefix}.webPage.url`) },
|
||||||
language: {
|
'language': {
|
||||||
label: t(`${fieldPrefix}.webPage.language`),
|
label: t(`${fieldPrefix}.webPage.language`),
|
||||||
inputType: "select",
|
inputType: 'select',
|
||||||
},
|
},
|
||||||
['author/publisher']: { label: t(`${fieldPrefix}.webPage.authorPublisher`) },
|
'author/publisher': { label: t(`${fieldPrefix}.webPage.authorPublisher`) },
|
||||||
publish_date: { label: t(`${fieldPrefix}.webPage.publishDate`) },
|
'publish_date': { label: t(`${fieldPrefix}.webPage.publishDate`) },
|
||||||
['topics/keywords']: { label: t(`${fieldPrefix}.webPage.topicsKeywords`) },
|
'topics/keywords': { label: t(`${fieldPrefix}.webPage.topicsKeywords`) },
|
||||||
description: { label: t(`${fieldPrefix}.webPage.description`) },
|
'description': { label: t(`${fieldPrefix}.webPage.description`) },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
paper: {
|
paper: {
|
||||||
text: t("datasetDocuments.metadata.type.paper"),
|
text: t('datasetDocuments.metadata.type.paper'),
|
||||||
iconName: "graduationHat",
|
iconName: 'graduationHat',
|
||||||
subFieldsMap: {
|
subFieldsMap: {
|
||||||
title: { label: t(`${fieldPrefix}.paper.title`) },
|
'title': { label: t(`${fieldPrefix}.paper.title`) },
|
||||||
language: {
|
'language': {
|
||||||
label: t(`${fieldPrefix}.paper.language`),
|
label: t(`${fieldPrefix}.paper.language`),
|
||||||
inputType: "select",
|
inputType: 'select',
|
||||||
},
|
},
|
||||||
author: { label: t(`${fieldPrefix}.paper.author`) },
|
'author': { label: t(`${fieldPrefix}.paper.author`) },
|
||||||
publish_date: { label: t(`${fieldPrefix}.paper.publishDate`) },
|
'publish_date': { label: t(`${fieldPrefix}.paper.publishDate`) },
|
||||||
['journal/conference_name']: {
|
'journal/conference_name': {
|
||||||
label: t(`${fieldPrefix}.paper.journalConferenceName`),
|
label: t(`${fieldPrefix}.paper.journalConferenceName`),
|
||||||
},
|
},
|
||||||
['volume/issue/page_numbers']: { label: t(`${fieldPrefix}.paper.volumeIssuePage`) },
|
'volume/issue/page_numbers': { label: t(`${fieldPrefix}.paper.volumeIssuePage`) },
|
||||||
doi: { label: t(`${fieldPrefix}.paper.DOI`) },
|
'doi': { label: t(`${fieldPrefix}.paper.DOI`) },
|
||||||
['topics/keywords']: { label: t(`${fieldPrefix}.paper.topicsKeywords`) },
|
'topics/keywords': { label: t(`${fieldPrefix}.paper.topicsKeywords`) },
|
||||||
abstract: {
|
'abstract': {
|
||||||
label: t(`${fieldPrefix}.paper.abstract`),
|
label: t(`${fieldPrefix}.paper.abstract`),
|
||||||
inputType: "textarea",
|
inputType: 'textarea',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
social_media_post: {
|
social_media_post: {
|
||||||
text: t("datasetDocuments.metadata.type.socialMediaPost"),
|
text: t('datasetDocuments.metadata.type.socialMediaPost'),
|
||||||
iconName: "atSign",
|
iconName: 'atSign',
|
||||||
subFieldsMap: {
|
subFieldsMap: {
|
||||||
platform: { label: t(`${fieldPrefix}.socialMediaPost.platform`) },
|
'platform': { label: t(`${fieldPrefix}.socialMediaPost.platform`) },
|
||||||
['author/username']: {
|
'author/username': {
|
||||||
label: t(`${fieldPrefix}.socialMediaPost.authorUsername`),
|
label: t(`${fieldPrefix}.socialMediaPost.authorUsername`),
|
||||||
},
|
},
|
||||||
publish_date: { label: t(`${fieldPrefix}.socialMediaPost.publishDate`) },
|
'publish_date': { label: t(`${fieldPrefix}.socialMediaPost.publishDate`) },
|
||||||
post_url: { label: t(`${fieldPrefix}.socialMediaPost.postURL`) },
|
'post_url': { label: t(`${fieldPrefix}.socialMediaPost.postURL`) },
|
||||||
['topics/tags']: { label: t(`${fieldPrefix}.socialMediaPost.topicsTags`) },
|
'topics/tags': { label: t(`${fieldPrefix}.socialMediaPost.topicsTags`) },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
personal_document: {
|
personal_document: {
|
||||||
text: t("datasetDocuments.metadata.type.personalDocument"),
|
text: t('datasetDocuments.metadata.type.personalDocument'),
|
||||||
iconName: "file",
|
iconName: 'file',
|
||||||
subFieldsMap: {
|
subFieldsMap: {
|
||||||
title: { label: t(`${fieldPrefix}.personalDocument.title`) },
|
'title': { label: t(`${fieldPrefix}.personalDocument.title`) },
|
||||||
author: { label: t(`${fieldPrefix}.personalDocument.author`) },
|
'author': { label: t(`${fieldPrefix}.personalDocument.author`) },
|
||||||
creation_date: {
|
'creation_date': {
|
||||||
label: t(`${fieldPrefix}.personalDocument.creationDate`),
|
label: t(`${fieldPrefix}.personalDocument.creationDate`),
|
||||||
},
|
},
|
||||||
last_modified_date: {
|
'last_modified_date': {
|
||||||
label: t(`${fieldPrefix}.personalDocument.lastModifiedDate`),
|
label: t(`${fieldPrefix}.personalDocument.lastModifiedDate`),
|
||||||
},
|
},
|
||||||
document_type: {
|
'document_type': {
|
||||||
label: t(`${fieldPrefix}.personalDocument.documentType`),
|
label: t(`${fieldPrefix}.personalDocument.documentType`),
|
||||||
inputType: "select",
|
inputType: 'select',
|
||||||
},
|
},
|
||||||
['tags/category']: {
|
'tags/category': {
|
||||||
label: t(`${fieldPrefix}.personalDocument.tagsCategory`),
|
label: t(`${fieldPrefix}.personalDocument.tagsCategory`),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
business_document: {
|
business_document: {
|
||||||
text: t("datasetDocuments.metadata.type.businessDocument"),
|
text: t('datasetDocuments.metadata.type.businessDocument'),
|
||||||
iconName: "briefcase",
|
iconName: 'briefcase',
|
||||||
subFieldsMap: {
|
subFieldsMap: {
|
||||||
title: { label: t(`${fieldPrefix}.businessDocument.title`) },
|
'title': { label: t(`${fieldPrefix}.businessDocument.title`) },
|
||||||
author: { label: t(`${fieldPrefix}.businessDocument.author`) },
|
'author': { label: t(`${fieldPrefix}.businessDocument.author`) },
|
||||||
creation_date: {
|
'creation_date': {
|
||||||
label: t(`${fieldPrefix}.businessDocument.creationDate`),
|
label: t(`${fieldPrefix}.businessDocument.creationDate`),
|
||||||
},
|
},
|
||||||
last_modified_date: {
|
'last_modified_date': {
|
||||||
label: t(`${fieldPrefix}.businessDocument.lastModifiedDate`),
|
label: t(`${fieldPrefix}.businessDocument.lastModifiedDate`),
|
||||||
},
|
},
|
||||||
document_type: {
|
'document_type': {
|
||||||
label: t(`${fieldPrefix}.businessDocument.documentType`),
|
label: t(`${fieldPrefix}.businessDocument.documentType`),
|
||||||
inputType: "select",
|
inputType: 'select',
|
||||||
},
|
},
|
||||||
['department/team']: {
|
'department/team': {
|
||||||
label: t(`${fieldPrefix}.businessDocument.departmentTeam`),
|
label: t(`${fieldPrefix}.businessDocument.departmentTeam`),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
im_chat_log: {
|
im_chat_log: {
|
||||||
text: t("datasetDocuments.metadata.type.IMChat"),
|
text: t('datasetDocuments.metadata.type.IMChat'),
|
||||||
iconName: "messageTextCircle",
|
iconName: 'messageTextCircle',
|
||||||
subFieldsMap: {
|
subFieldsMap: {
|
||||||
chat_platform: { label: t(`${fieldPrefix}.IMChat.chatPlatform`) },
|
'chat_platform': { label: t(`${fieldPrefix}.IMChat.chatPlatform`) },
|
||||||
['chat_participants/group_name']: {
|
'chat_participants/group_name': {
|
||||||
label: t(`${fieldPrefix}.IMChat.chatPartiesGroupName`),
|
label: t(`${fieldPrefix}.IMChat.chatPartiesGroupName`),
|
||||||
},
|
},
|
||||||
start_date: { label: t(`${fieldPrefix}.IMChat.startDate`) },
|
'start_date': { label: t(`${fieldPrefix}.IMChat.startDate`) },
|
||||||
end_date: { label: t(`${fieldPrefix}.IMChat.endDate`) },
|
'end_date': { label: t(`${fieldPrefix}.IMChat.endDate`) },
|
||||||
participants: { label: t(`${fieldPrefix}.IMChat.participants`) },
|
'participants': { label: t(`${fieldPrefix}.IMChat.participants`) },
|
||||||
topicsKeywords: {
|
'topicsKeywords': {
|
||||||
label: t(`${fieldPrefix}.IMChat.topicsKeywords`),
|
label: t(`${fieldPrefix}.IMChat.topicsKeywords`),
|
||||||
inputType: "textarea",
|
inputType: 'textarea',
|
||||||
},
|
},
|
||||||
fileType: { label: t(`${fieldPrefix}.IMChat.fileType`) },
|
'fileType': { label: t(`${fieldPrefix}.IMChat.fileType`) },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wikipedia_entry: {
|
wikipedia_entry: {
|
||||||
text: t("datasetDocuments.metadata.type.wikipediaEntry"),
|
text: t('datasetDocuments.metadata.type.wikipediaEntry'),
|
||||||
allowEdit: false,
|
allowEdit: false,
|
||||||
subFieldsMap: {
|
subFieldsMap: {
|
||||||
title: { label: t(`${fieldPrefix}.wikipediaEntry.title`) },
|
'title': { label: t(`${fieldPrefix}.wikipediaEntry.title`) },
|
||||||
language: {
|
'language': {
|
||||||
label: t(`${fieldPrefix}.wikipediaEntry.language`),
|
label: t(`${fieldPrefix}.wikipediaEntry.language`),
|
||||||
inputType: "select",
|
inputType: 'select',
|
||||||
},
|
},
|
||||||
web_page_url: { label: t(`${fieldPrefix}.wikipediaEntry.webpageURL`) },
|
'web_page_url': { label: t(`${fieldPrefix}.wikipediaEntry.webpageURL`) },
|
||||||
['editor/contributor']: {
|
'editor/contributor': {
|
||||||
label: t(`${fieldPrefix}.wikipediaEntry.editorContributor`),
|
label: t(`${fieldPrefix}.wikipediaEntry.editorContributor`),
|
||||||
},
|
},
|
||||||
last_edit_date: {
|
'last_edit_date': {
|
||||||
label: t(`${fieldPrefix}.wikipediaEntry.lastEditDate`),
|
label: t(`${fieldPrefix}.wikipediaEntry.lastEditDate`),
|
||||||
},
|
},
|
||||||
['summary/introduction']: {
|
'summary/introduction': {
|
||||||
label: t(`${fieldPrefix}.wikipediaEntry.summaryIntroduction`),
|
label: t(`${fieldPrefix}.wikipediaEntry.summaryIntroduction`),
|
||||||
inputType: "textarea",
|
inputType: 'textarea',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
synced_from_notion: {
|
synced_from_notion: {
|
||||||
text: t("datasetDocuments.metadata.type.notion"),
|
text: t('datasetDocuments.metadata.type.notion'),
|
||||||
allowEdit: false,
|
allowEdit: false,
|
||||||
subFieldsMap: {
|
subFieldsMap: {
|
||||||
title: { label: t(`${fieldPrefix}.notion.title`) },
|
'title': { label: t(`${fieldPrefix}.notion.title`) },
|
||||||
language: { label: t(`${fieldPrefix}.notion.lang`), inputType: "select" },
|
'language': { label: t(`${fieldPrefix}.notion.lang`), inputType: 'select' },
|
||||||
['author/creator']: { label: t(`${fieldPrefix}.notion.author`) },
|
'author/creator': { label: t(`${fieldPrefix}.notion.author`) },
|
||||||
creation_date: { label: t(`${fieldPrefix}.notion.createdTime`) },
|
'creation_date': { label: t(`${fieldPrefix}.notion.createdTime`) },
|
||||||
last_modified_date: {
|
'last_modified_date': {
|
||||||
label: t(`${fieldPrefix}.notion.lastModifiedTime`),
|
label: t(`${fieldPrefix}.notion.lastModifiedTime`),
|
||||||
},
|
},
|
||||||
notion_page_link: { label: t(`${fieldPrefix}.notion.url`) },
|
'notion_page_link': { label: t(`${fieldPrefix}.notion.url`) },
|
||||||
['category/tags']: { label: t(`${fieldPrefix}.notion.tag`) },
|
'category/tags': { label: t(`${fieldPrefix}.notion.tag`) },
|
||||||
description: { label: t(`${fieldPrefix}.notion.desc`) },
|
'description': { label: t(`${fieldPrefix}.notion.desc`) },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
synced_from_github: {
|
synced_from_github: {
|
||||||
text: t("datasetDocuments.metadata.type.github"),
|
text: t('datasetDocuments.metadata.type.github'),
|
||||||
allowEdit: false,
|
allowEdit: false,
|
||||||
subFieldsMap: {
|
subFieldsMap: {
|
||||||
repository_name: { label: t(`${fieldPrefix}.github.repoName`) },
|
'repository_name': { label: t(`${fieldPrefix}.github.repoName`) },
|
||||||
repository_description: { label: t(`${fieldPrefix}.github.repoDesc`) },
|
'repository_description': { label: t(`${fieldPrefix}.github.repoDesc`) },
|
||||||
['repository_owner/organization']: { label: t(`${fieldPrefix}.github.repoOwner`) },
|
'repository_owner/organization': { label: t(`${fieldPrefix}.github.repoOwner`) },
|
||||||
code_filename: { label: t(`${fieldPrefix}.github.fileName`) },
|
'code_filename': { label: t(`${fieldPrefix}.github.fileName`) },
|
||||||
code_file_path: { label: t(`${fieldPrefix}.github.filePath`) },
|
'code_file_path': { label: t(`${fieldPrefix}.github.filePath`) },
|
||||||
programming_language: { label: t(`${fieldPrefix}.github.programmingLang`) },
|
'programming_language': { label: t(`${fieldPrefix}.github.programmingLang`) },
|
||||||
github_link: { label: t(`${fieldPrefix}.github.url`) },
|
'github_link': { label: t(`${fieldPrefix}.github.url`) },
|
||||||
open_source_license: { label: t(`${fieldPrefix}.github.license`) },
|
'open_source_license': { label: t(`${fieldPrefix}.github.license`) },
|
||||||
commit_date: { label: t(`${fieldPrefix}.github.lastCommitTime`) },
|
'commit_date': { label: t(`${fieldPrefix}.github.lastCommitTime`) },
|
||||||
commit_author: {
|
'commit_author': {
|
||||||
label: t(`${fieldPrefix}.github.lastCommitAuthor`),
|
label: t(`${fieldPrefix}.github.lastCommitAuthor`),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
originInfo: {
|
originInfo: {
|
||||||
text: "",
|
text: '',
|
||||||
allowEdit: false,
|
allowEdit: false,
|
||||||
subFieldsMap: {
|
subFieldsMap: {
|
||||||
name: { label: t(`${fieldPrefix}.originInfo.originalFilename`) },
|
'name': { label: t(`${fieldPrefix}.originInfo.originalFilename`) },
|
||||||
"data_source_info.upload_file.size": {
|
'data_source_info.upload_file.size': {
|
||||||
label: t(`${fieldPrefix}.originInfo.originalFileSize`),
|
label: t(`${fieldPrefix}.originInfo.originalFileSize`),
|
||||||
render: (value) => formatFileSize(value)
|
render: value => formatFileSize(value),
|
||||||
},
|
},
|
||||||
created_at: {
|
'created_at': {
|
||||||
label: t(`${fieldPrefix}.originInfo.uploadDate`),
|
label: t(`${fieldPrefix}.originInfo.uploadDate`),
|
||||||
render: (value) => dayjs.unix(value).format(t('datasetDocuments.metadata.dateTimeFormat') as string)
|
render: value => dayjs.unix(value).format(t('datasetDocuments.metadata.dateTimeFormat') as string),
|
||||||
},
|
},
|
||||||
completed_at: {
|
'completed_at': {
|
||||||
label: t(`${fieldPrefix}.originInfo.lastUpdateDate`),
|
label: t(`${fieldPrefix}.originInfo.lastUpdateDate`),
|
||||||
render: (value) => dayjs.unix(value).format(t('datasetDocuments.metadata.dateTimeFormat') as string)
|
render: value => dayjs.unix(value).format(t('datasetDocuments.metadata.dateTimeFormat') as string),
|
||||||
},
|
},
|
||||||
data_source_type: {
|
'data_source_type': {
|
||||||
label: t(`${fieldPrefix}.originInfo.source`),
|
label: t(`${fieldPrefix}.originInfo.source`),
|
||||||
render: (value) => t(`datasetDocuments.metadata.source.${value}`)
|
render: value => t(`datasetDocuments.metadata.source.${value}`),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
technicalParameters: {
|
technicalParameters: {
|
||||||
text: t("datasetDocuments.metadata.type.technicalParameters"),
|
text: t('datasetDocuments.metadata.type.technicalParameters'),
|
||||||
allowEdit: false,
|
allowEdit: false,
|
||||||
subFieldsMap: {
|
subFieldsMap: {
|
||||||
'dataset_process_rule.mode': {
|
'dataset_process_rule.mode': {
|
||||||
label: t(`${fieldPrefix}.technicalParameters.segmentSpecification`),
|
label: t(`${fieldPrefix}.technicalParameters.segmentSpecification`),
|
||||||
render: value => value === 'automatic' ? (t('datasetDocuments.embedding.automatic') as string) : (t('datasetDocuments.embedding.custom') as string)
|
render: value => value === 'automatic' ? (t('datasetDocuments.embedding.automatic') as string) : (t('datasetDocuments.embedding.custom') as string),
|
||||||
},
|
},
|
||||||
'dataset_process_rule.rules.segmentation.max_tokens': {
|
'dataset_process_rule.rules.segmentation.max_tokens': {
|
||||||
label: t(`${fieldPrefix}.technicalParameters.segmentLength`),
|
label: t(`${fieldPrefix}.technicalParameters.segmentLength`),
|
||||||
render: value => formatNumber(value)
|
render: value => formatNumber(value),
|
||||||
},
|
},
|
||||||
average_segment_length: {
|
'average_segment_length': {
|
||||||
label: t(`${fieldPrefix}.technicalParameters.avgParagraphLength`),
|
label: t(`${fieldPrefix}.technicalParameters.avgParagraphLength`),
|
||||||
render: (value) => `${formatNumber(value)} characters`
|
render: value => `${formatNumber(value)} characters`,
|
||||||
},
|
},
|
||||||
segment_count: {
|
'segment_count': {
|
||||||
label: t(`${fieldPrefix}.technicalParameters.paragraphs`),
|
label: t(`${fieldPrefix}.technicalParameters.paragraphs`),
|
||||||
render: (value) => `${formatNumber(value)} paragraphs`
|
render: value => `${formatNumber(value)} paragraphs`,
|
||||||
},
|
},
|
||||||
hit_count: {
|
'hit_count': {
|
||||||
label: t(`${fieldPrefix}.technicalParameters.hitCount`),
|
label: t(`${fieldPrefix}.technicalParameters.hitCount`),
|
||||||
render: (value, total) => {
|
render: (value, total) => {
|
||||||
const v = value || 0;
|
const v = value || 0
|
||||||
return `${!total ? 0 : ((v / total) * 100).toFixed(2)}% (${v}/${total})`
|
return `${!total ? 0 : ((v / total) * 100).toFixed(2)}% (${v}/${total})`
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
indexing_latency: {
|
'indexing_latency': {
|
||||||
label: t(`${fieldPrefix}.technicalParameters.embeddingTime`),
|
label: t(`${fieldPrefix}.technicalParameters.embeddingTime`),
|
||||||
render: (value) => formatTime(value)
|
render: value => formatTime(value),
|
||||||
},
|
},
|
||||||
tokens: {
|
'tokens': {
|
||||||
label: t(`${fieldPrefix}.technicalParameters.embeddedSpend`),
|
label: t(`${fieldPrefix}.technicalParameters.embeddedSpend`),
|
||||||
render: (value) => `${formatNumber(value)} tokens`
|
render: value => `${formatNumber(value)} tokens`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
const langPrefix = "datasetDocuments.metadata.languageMap.";
|
const langPrefix = 'datasetDocuments.metadata.languageMap.'
|
||||||
|
|
||||||
export const useLanguages = () => {
|
export const useLanguages = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation()
|
||||||
return {
|
return {
|
||||||
zh: t(langPrefix + "zh"),
|
zh: t(`${langPrefix}zh`),
|
||||||
en: t(langPrefix + "en"),
|
en: t(`${langPrefix}en`),
|
||||||
es: t(langPrefix + "es"),
|
es: t(`${langPrefix}es`),
|
||||||
fr: t(langPrefix + "fr"),
|
fr: t(`${langPrefix}fr`),
|
||||||
de: t(langPrefix + "de"),
|
de: t(`${langPrefix}de`),
|
||||||
ja: t(langPrefix + "ja"),
|
ja: t(`${langPrefix}ja`),
|
||||||
ko: t(langPrefix + "ko"),
|
ko: t(`${langPrefix}ko`),
|
||||||
ru: t(langPrefix + "ru"),
|
ru: t(`${langPrefix}ru`),
|
||||||
ar: t(langPrefix + "ar"),
|
ar: t(`${langPrefix}ar`),
|
||||||
pt: t(langPrefix + "pt"),
|
pt: t(`${langPrefix}pt`),
|
||||||
it: t(langPrefix + "it"),
|
it: t(`${langPrefix}it`),
|
||||||
nl: t(langPrefix + "nl"),
|
nl: t(`${langPrefix}nl`),
|
||||||
pl: t(langPrefix + "pl"),
|
pl: t(`${langPrefix}pl`),
|
||||||
sv: t(langPrefix + "sv"),
|
sv: t(`${langPrefix}sv`),
|
||||||
tr: t(langPrefix + "tr"),
|
tr: t(`${langPrefix}tr`),
|
||||||
he: t(langPrefix + "he"),
|
he: t(`${langPrefix}he`),
|
||||||
hi: t(langPrefix + "hi"),
|
hi: t(`${langPrefix}hi`),
|
||||||
da: t(langPrefix + "da"),
|
da: t(`${langPrefix}da`),
|
||||||
fi: t(langPrefix + "fi"),
|
fi: t(`${langPrefix}fi`),
|
||||||
no: t(langPrefix + "no"),
|
no: t(`${langPrefix}no`),
|
||||||
hu: t(langPrefix + "hu"),
|
hu: t(`${langPrefix}hu`),
|
||||||
el: t(langPrefix + "el"),
|
el: t(`${langPrefix}el`),
|
||||||
cs: t(langPrefix + "cs"),
|
cs: t(`${langPrefix}cs`),
|
||||||
th: t(langPrefix + "th"),
|
th: t(`${langPrefix}th`),
|
||||||
id: t(langPrefix + "id"),
|
id: t(`${langPrefix}id`),
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
const bookCategoryPrefix = "datasetDocuments.metadata.categoryMap.book.";
|
const bookCategoryPrefix = 'datasetDocuments.metadata.categoryMap.book.'
|
||||||
|
|
||||||
export const useBookCategories = () => {
|
export const useBookCategories = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation()
|
||||||
return {
|
return {
|
||||||
fiction: t(bookCategoryPrefix + "fiction"),
|
fiction: t(`${bookCategoryPrefix}fiction`),
|
||||||
biography: t(bookCategoryPrefix + "biography"),
|
biography: t(`${bookCategoryPrefix}biography`),
|
||||||
history: t(bookCategoryPrefix + "history"),
|
history: t(`${bookCategoryPrefix}history`),
|
||||||
science: t(bookCategoryPrefix + "science"),
|
science: t(`${bookCategoryPrefix}science`),
|
||||||
technology: t(bookCategoryPrefix + "technology"),
|
technology: t(`${bookCategoryPrefix}technology`),
|
||||||
education: t(bookCategoryPrefix + "education"),
|
education: t(`${bookCategoryPrefix}education`),
|
||||||
philosophy: t(bookCategoryPrefix + "philosophy"),
|
philosophy: t(`${bookCategoryPrefix}philosophy`),
|
||||||
religion: t(bookCategoryPrefix + "religion"),
|
religion: t(`${bookCategoryPrefix}religion`),
|
||||||
socialSciences: t(bookCategoryPrefix + "socialSciences"),
|
socialSciences: t(`${bookCategoryPrefix}socialSciences`),
|
||||||
art: t(bookCategoryPrefix + "art"),
|
art: t(`${bookCategoryPrefix}art`),
|
||||||
travel: t(bookCategoryPrefix + "travel"),
|
travel: t(`${bookCategoryPrefix}travel`),
|
||||||
health: t(bookCategoryPrefix + "health"),
|
health: t(`${bookCategoryPrefix}health`),
|
||||||
selfHelp: t(bookCategoryPrefix + "selfHelp"),
|
selfHelp: t(`${bookCategoryPrefix}selfHelp`),
|
||||||
businessEconomics: t(bookCategoryPrefix + "businessEconomics"),
|
businessEconomics: t(`${bookCategoryPrefix}businessEconomics`),
|
||||||
cooking: t(bookCategoryPrefix + "cooking"),
|
cooking: t(`${bookCategoryPrefix}cooking`),
|
||||||
childrenYoungAdults: t(bookCategoryPrefix + "childrenYoungAdults"),
|
childrenYoungAdults: t(`${bookCategoryPrefix}childrenYoungAdults`),
|
||||||
comicsGraphicNovels: t(bookCategoryPrefix + "comicsGraphicNovels"),
|
comicsGraphicNovels: t(`${bookCategoryPrefix}comicsGraphicNovels`),
|
||||||
poetry: t(bookCategoryPrefix + "poetry"),
|
poetry: t(`${bookCategoryPrefix}poetry`),
|
||||||
drama: t(bookCategoryPrefix + "drama"),
|
drama: t(`${bookCategoryPrefix}drama`),
|
||||||
other: t(bookCategoryPrefix + "other"),
|
other: t(`${bookCategoryPrefix}other`),
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
const personalDocCategoryPrefix =
|
const personalDocCategoryPrefix
|
||||||
"datasetDocuments.metadata.categoryMap.personalDoc.";
|
= 'datasetDocuments.metadata.categoryMap.personalDoc.'
|
||||||
|
|
||||||
export const usePersonalDocCategories = () => {
|
export const usePersonalDocCategories = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation()
|
||||||
return {
|
return {
|
||||||
notes: t(personalDocCategoryPrefix + "notes"),
|
notes: t(`${personalDocCategoryPrefix}notes`),
|
||||||
blogDraft: t(personalDocCategoryPrefix + "blogDraft"),
|
blogDraft: t(`${personalDocCategoryPrefix}blogDraft`),
|
||||||
diary: t(personalDocCategoryPrefix + "diary"),
|
diary: t(`${personalDocCategoryPrefix}diary`),
|
||||||
researchReport: t(personalDocCategoryPrefix + "researchReport"),
|
researchReport: t(`${personalDocCategoryPrefix}researchReport`),
|
||||||
bookExcerpt: t(personalDocCategoryPrefix + "bookExcerpt"),
|
bookExcerpt: t(`${personalDocCategoryPrefix}bookExcerpt`),
|
||||||
schedule: t(personalDocCategoryPrefix + "schedule"),
|
schedule: t(`${personalDocCategoryPrefix}schedule`),
|
||||||
list: t(personalDocCategoryPrefix + "list"),
|
list: t(`${personalDocCategoryPrefix}list`),
|
||||||
projectOverview: t(personalDocCategoryPrefix + "projectOverview"),
|
projectOverview: t(`${personalDocCategoryPrefix}projectOverview`),
|
||||||
photoCollection: t(personalDocCategoryPrefix + "photoCollection"),
|
photoCollection: t(`${personalDocCategoryPrefix}photoCollection`),
|
||||||
creativeWriting: t(personalDocCategoryPrefix + "creativeWriting"),
|
creativeWriting: t(`${personalDocCategoryPrefix}creativeWriting`),
|
||||||
codeSnippet: t(personalDocCategoryPrefix + "codeSnippet"),
|
codeSnippet: t(`${personalDocCategoryPrefix}codeSnippet`),
|
||||||
designDraft: t(personalDocCategoryPrefix + "designDraft"),
|
designDraft: t(`${personalDocCategoryPrefix}designDraft`),
|
||||||
personalResume: t(personalDocCategoryPrefix + "personalResume"),
|
personalResume: t(`${personalDocCategoryPrefix}personalResume`),
|
||||||
other: t(personalDocCategoryPrefix + "other"),
|
other: t(`${personalDocCategoryPrefix}other`),
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
const businessDocCategoryPrefix =
|
const businessDocCategoryPrefix
|
||||||
"datasetDocuments.metadata.categoryMap.businessDoc.";
|
= 'datasetDocuments.metadata.categoryMap.businessDoc.'
|
||||||
|
|
||||||
export const useBusinessDocCategories = () => {
|
export const useBusinessDocCategories = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation()
|
||||||
return {
|
return {
|
||||||
meetingMinutes: t(businessDocCategoryPrefix + "meetingMinutes"),
|
meetingMinutes: t(`${businessDocCategoryPrefix}meetingMinutes`),
|
||||||
researchReport: t(businessDocCategoryPrefix + "researchReport"),
|
researchReport: t(`${businessDocCategoryPrefix}researchReport`),
|
||||||
proposal: t(businessDocCategoryPrefix + "proposal"),
|
proposal: t(`${businessDocCategoryPrefix}proposal`),
|
||||||
employeeHandbook: t(businessDocCategoryPrefix + "employeeHandbook"),
|
employeeHandbook: t(`${businessDocCategoryPrefix}employeeHandbook`),
|
||||||
trainingMaterials: t(businessDocCategoryPrefix + "trainingMaterials"),
|
trainingMaterials: t(`${businessDocCategoryPrefix}trainingMaterials`),
|
||||||
requirementsDocument: t(businessDocCategoryPrefix + "requirementsDocument"),
|
requirementsDocument: t(`${businessDocCategoryPrefix}requirementsDocument`),
|
||||||
designDocument: t(businessDocCategoryPrefix + "designDocument"),
|
designDocument: t(`${businessDocCategoryPrefix}designDocument`),
|
||||||
productSpecification: t(businessDocCategoryPrefix + "productSpecification"),
|
productSpecification: t(`${businessDocCategoryPrefix}productSpecification`),
|
||||||
financialReport: t(businessDocCategoryPrefix + "financialReport"),
|
financialReport: t(`${businessDocCategoryPrefix}financialReport`),
|
||||||
marketAnalysis: t(businessDocCategoryPrefix + "marketAnalysis"),
|
marketAnalysis: t(`${businessDocCategoryPrefix}marketAnalysis`),
|
||||||
projectPlan: t(businessDocCategoryPrefix + "projectPlan"),
|
projectPlan: t(`${businessDocCategoryPrefix}projectPlan`),
|
||||||
teamStructure: t(businessDocCategoryPrefix + "teamStructure"),
|
teamStructure: t(`${businessDocCategoryPrefix}teamStructure`),
|
||||||
policiesProcedures: t(businessDocCategoryPrefix + "policiesProcedures"),
|
policiesProcedures: t(`${businessDocCategoryPrefix}policiesProcedures`),
|
||||||
contractsAgreements: t(businessDocCategoryPrefix + "contractsAgreements"),
|
contractsAgreements: t(`${businessDocCategoryPrefix}contractsAgreements`),
|
||||||
emailCorrespondence: t(businessDocCategoryPrefix + "emailCorrespondence"),
|
emailCorrespondence: t(`${businessDocCategoryPrefix}emailCorrespondence`),
|
||||||
other: t(businessDocCategoryPrefix + "other"),
|
other: t(`${businessDocCategoryPrefix}other`),
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { createInstance } from 'i18next'
|
import { createInstance } from 'i18next'
|
||||||
import resourcesToBackend from 'i18next-resources-to-backend'
|
import resourcesToBackend from 'i18next-resources-to-backend'
|
||||||
import { initReactI18next } from 'react-i18next/initReactI18next'
|
import { initReactI18next } from 'react-i18next/initReactI18next'
|
||||||
import { Locale } from '.'
|
import type { Locale } from '.'
|
||||||
|
|
||||||
// https://locize.com/blog/next-13-app-dir-i18n/
|
// https://locize.com/blog/next-13-app-dir-i18n/
|
||||||
const initI18next = async (lng: Locale, ns: string) => {
|
const initI18next = async (lng: Locale, ns: string) => {
|
||||||
@ -21,6 +21,6 @@ export async function useTranslation(lng: Locale, ns = '', options: Record<strin
|
|||||||
const i18nextInstance = await initI18next(lng, ns)
|
const i18nextInstance = await initI18next(lng, ns)
|
||||||
return {
|
return {
|
||||||
t: i18nextInstance.getFixedT(lng, ns, options.keyPrefix),
|
t: i18nextInstance.getFixedT(lng, ns, options.keyPrefix),
|
||||||
i18n: i18nextInstance
|
i18n: i18nextInstance,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Locale } from '@/i18n'
|
import type { Locale } from '@/i18n'
|
||||||
|
|
||||||
export type ResponseHolder = {}
|
export type ResponseHolder = {}
|
||||||
|
|
||||||
@ -6,7 +6,7 @@ export type ConversationItem = {
|
|||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
inputs: Record<string, any> | null
|
inputs: Record<string, any> | null
|
||||||
introduction: string,
|
introduction: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SiteInfo = {
|
export type SiteInfo = {
|
||||||
@ -18,4 +18,4 @@ export type SiteInfo = {
|
|||||||
prompt_public: boolean
|
prompt_public: boolean
|
||||||
copyright?: string
|
copyright?: string
|
||||||
privacy_policy?: string
|
privacy_policy?: string
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ const nextConfig = {
|
|||||||
// Warning: This allows production builds to successfully complete even if
|
// Warning: This allows production builds to successfully complete even if
|
||||||
// your project has ESLint errors.
|
// your project has ESLint errors.
|
||||||
ignoreDuringBuilds: true,
|
ignoreDuringBuilds: true,
|
||||||
|
dirs: ['app', 'bin', 'config', 'context', 'hooks', 'i18n', 'models', 'service', 'test', 'types', 'utils'],
|
||||||
},
|
},
|
||||||
typescript: {
|
typescript: {
|
||||||
// https://nextjs.org/docs/api-reference/next.config.js/ignoring-typescript-errors
|
// https://nextjs.org/docs/api-reference/next.config.js/ignoring-typescript-errors
|
||||||
|
@ -6,61 +6,61 @@ import type { User } from '@/models/user'
|
|||||||
import type { Log } from '@/models/log'
|
import type { Log } from '@/models/log'
|
||||||
|
|
||||||
export const seedHistory = () => {
|
export const seedHistory = () => {
|
||||||
return Factory.extend<Partial<History>>({
|
return Factory.extend<Partial<History>>({
|
||||||
source() {
|
source() {
|
||||||
return faker.address.streetAddress()
|
return faker.address.streetAddress()
|
||||||
},
|
},
|
||||||
target() {
|
target() {
|
||||||
return faker.address.streetAddress()
|
return faker.address.streetAddress()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const seedUser = () => {
|
export const seedUser = () => {
|
||||||
return Factory.extend<Partial<User>>({
|
return Factory.extend<Partial<User>>({
|
||||||
firstName() {
|
firstName() {
|
||||||
return faker.name.firstName()
|
return faker.name.firstName()
|
||||||
},
|
},
|
||||||
lastName() {
|
lastName() {
|
||||||
return faker.name.lastName()
|
return faker.name.lastName()
|
||||||
},
|
},
|
||||||
name() {
|
name() {
|
||||||
return faker.address.streetAddress()
|
return faker.address.streetAddress()
|
||||||
},
|
},
|
||||||
phone() {
|
phone() {
|
||||||
return faker.phone.number()
|
return faker.phone.number()
|
||||||
},
|
},
|
||||||
email() {
|
email() {
|
||||||
return faker.internet.email()
|
return faker.internet.email()
|
||||||
},
|
},
|
||||||
username() {
|
username() {
|
||||||
return faker.internet.userName()
|
return faker.internet.userName()
|
||||||
},
|
},
|
||||||
avatar() {
|
avatar() {
|
||||||
return faker.internet.avatar()
|
return faker.internet.avatar()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const seedLog = () => {
|
export const seedLog = () => {
|
||||||
return Factory.extend<Partial<Log>>({
|
return Factory.extend<Partial<Log>>({
|
||||||
get key() {
|
get key() {
|
||||||
return faker.datatype.uuid()
|
return faker.datatype.uuid()
|
||||||
},
|
},
|
||||||
get conversationId() {
|
get conversationId() {
|
||||||
return faker.datatype.uuid()
|
return faker.datatype.uuid()
|
||||||
},
|
},
|
||||||
get question() {
|
get question() {
|
||||||
return faker.lorem.sentence()
|
return faker.lorem.sentence()
|
||||||
},
|
},
|
||||||
get answer() {
|
get answer() {
|
||||||
return faker.lorem.sentence()
|
return faker.lorem.sentence()
|
||||||
},
|
},
|
||||||
get userRate() {
|
get userRate() {
|
||||||
return faker.datatype.number(5)
|
return faker.datatype.number(5)
|
||||||
},
|
},
|
||||||
get adminRate() {
|
get adminRate() {
|
||||||
return faker.datatype.number(5)
|
return faker.datatype.number(5)
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,7 @@ import { Model, createServer } from 'miragejs'
|
|||||||
import type { User } from '@/models/user'
|
import type { User } from '@/models/user'
|
||||||
import type { History } from '@/models/history'
|
import type { History } from '@/models/history'
|
||||||
import type { Log } from '@/models/log'
|
import type { Log } from '@/models/log'
|
||||||
import { seedUser, seedHistory, seedLog } from '@/test/factories'
|
import { seedHistory, seedLog, seedUser } from '@/test/factories'
|
||||||
|
|
||||||
|
|
||||||
export function mockAPI() {
|
export function mockAPI() {
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user