mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 15:39:05 +08:00
Fix App logs page modal show different model icon. (#1224)
This commit is contained in:
parent
fd9413874a
commit
8eae643911
@ -38,9 +38,9 @@ const CardView: FC<ICardViewProps> = ({ appId }) => {
|
|||||||
|
|
||||||
message ||= (type === 'success' ? 'modifiedSuccessfully' : 'modifiedUnsuccessfully')
|
message ||= (type === 'success' ? 'modifiedSuccessfully' : 'modifiedUnsuccessfully')
|
||||||
|
|
||||||
if (type === 'success') {
|
if (type === 'success')
|
||||||
mutate(detailParams)
|
mutate(detailParams)
|
||||||
}
|
|
||||||
notify({
|
notify({
|
||||||
type,
|
type,
|
||||||
message: t(`common.actionMsg.${message}`),
|
message: t(`common.actionMsg.${message}`),
|
||||||
@ -79,7 +79,7 @@ const CardView: FC<ICardViewProps> = ({ appId }) => {
|
|||||||
if (!err)
|
if (!err)
|
||||||
localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1')
|
localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1')
|
||||||
|
|
||||||
handleCallbackResult(err)
|
handleCallbackResult(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onGenerateCode = async () => {
|
const onGenerateCode = async () => {
|
||||||
|
@ -64,8 +64,8 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => {
|
|||||||
|
|
||||||
const getAppDetail = async () => {
|
const getAppDetail = async () => {
|
||||||
setDetailState({ loading: true })
|
setDetailState({ loading: true })
|
||||||
const [err, res] = await asyncRunSafe<App>(
|
const [err, res] = await asyncRunSafe(
|
||||||
fetchAppDetail({ url: '/apps', id: app.id }) as Promise<App>,
|
fetchAppDetail({ url: '/apps', id: app.id }),
|
||||||
)
|
)
|
||||||
if (!err) {
|
if (!err) {
|
||||||
setDetailState({ loading: false, detail: res })
|
setDetailState({ loading: false, detail: res })
|
||||||
@ -76,11 +76,11 @@ const AppCard = ({ app, onRefresh }: AppCardProps) => {
|
|||||||
|
|
||||||
const onSaveSiteConfig = useCallback(
|
const onSaveSiteConfig = useCallback(
|
||||||
async (params: ConfigParams) => {
|
async (params: ConfigParams) => {
|
||||||
const [err] = await asyncRunSafe<App>(
|
const [err] = await asyncRunSafe(
|
||||||
updateAppSiteConfig({
|
updateAppSiteConfig({
|
||||||
url: `/apps/${app.id}/site`,
|
url: `/apps/${app.id}/site`,
|
||||||
body: params,
|
body: params,
|
||||||
}) as Promise<App>,
|
}),
|
||||||
)
|
)
|
||||||
if (!err) {
|
if (!err) {
|
||||||
notify({
|
notify({
|
||||||
|
@ -18,7 +18,6 @@ import Config from '@/app/components/app/configuration/config'
|
|||||||
import Debug from '@/app/components/app/configuration/debug'
|
import Debug from '@/app/components/app/configuration/debug'
|
||||||
import Confirm from '@/app/components/base/confirm'
|
import Confirm from '@/app/components/base/confirm'
|
||||||
import { ProviderEnum } from '@/app/components/header/account-setting/model-page/declarations'
|
import { ProviderEnum } from '@/app/components/header/account-setting/model-page/declarations'
|
||||||
import type { AppDetailResponse } from '@/models/app'
|
|
||||||
import { ToastContext } from '@/app/components/base/toast'
|
import { ToastContext } from '@/app/components/base/toast'
|
||||||
import { fetchAppDetail, updateAppModelConfig } from '@/service/apps'
|
import { fetchAppDetail, updateAppModelConfig } from '@/service/apps'
|
||||||
import { promptVariablesToUserInputsForm, userInputsFormToPromptVariables } from '@/utils/model-config'
|
import { promptVariablesToUserInputsForm, userInputsFormToPromptVariables } from '@/utils/model-config'
|
||||||
@ -27,6 +26,11 @@ import AccountSetting from '@/app/components/header/account-setting'
|
|||||||
import { useProviderContext } from '@/context/provider-context'
|
import { useProviderContext } from '@/context/provider-context'
|
||||||
import { AppType } from '@/types/app'
|
import { AppType } from '@/types/app'
|
||||||
|
|
||||||
|
type PublichConfig = {
|
||||||
|
modelConfig: ModelConfig
|
||||||
|
completionParams: CompletionParams
|
||||||
|
}
|
||||||
|
|
||||||
const Configuration: FC = () => {
|
const Configuration: FC = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { notify } = useContext(ToastContext)
|
const { notify } = useContext(ToastContext)
|
||||||
@ -37,10 +41,7 @@ const Configuration: FC = () => {
|
|||||||
const matched = pathname.match(/\/app\/([^/]+)/)
|
const matched = pathname.match(/\/app\/([^/]+)/)
|
||||||
const appId = (matched?.length && matched[1]) ? matched[1] : ''
|
const appId = (matched?.length && matched[1]) ? matched[1] : ''
|
||||||
const [mode, setMode] = useState('')
|
const [mode, setMode] = useState('')
|
||||||
const [publishedConfig, setPublishedConfig] = useState<{
|
const [publishedConfig, setPublishedConfig] = useState<PublichConfig | null>(null)
|
||||||
modelConfig: ModelConfig
|
|
||||||
completionParams: CompletionParams
|
|
||||||
} | null>(null)
|
|
||||||
|
|
||||||
const [conversationId, setConversationId] = useState<string | null>('')
|
const [conversationId, setConversationId] = useState<string | null>('')
|
||||||
const [introduction, setIntroduction] = useState<string>('')
|
const [introduction, setIntroduction] = useState<string>('')
|
||||||
@ -100,13 +101,13 @@ const Configuration: FC = () => {
|
|||||||
|
|
||||||
const [dataSets, setDataSets] = useState<DataSet[]>([])
|
const [dataSets, setDataSets] = useState<DataSet[]>([])
|
||||||
|
|
||||||
const syncToPublishedConfig = (_publishedConfig: any) => {
|
const syncToPublishedConfig = (_publishedConfig: PublichConfig) => {
|
||||||
const modelConfig = _publishedConfig.modelConfig
|
const modelConfig = _publishedConfig.modelConfig
|
||||||
setModelConfig(_publishedConfig.modelConfig)
|
setModelConfig(_publishedConfig.modelConfig)
|
||||||
setCompletionParams(_publishedConfig.completionParams)
|
setCompletionParams(_publishedConfig.completionParams)
|
||||||
setDataSets(modelConfig.dataSets || [])
|
setDataSets(modelConfig.dataSets || [])
|
||||||
// feature
|
// feature
|
||||||
setIntroduction(modelConfig.opening_statement)
|
setIntroduction(modelConfig.opening_statement!)
|
||||||
setMoreLikeThisConfig(modelConfig.more_like_this || {
|
setMoreLikeThisConfig(modelConfig.more_like_this || {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
})
|
})
|
||||||
@ -143,7 +144,7 @@ const Configuration: FC = () => {
|
|||||||
const [isShowSetAPIKey, { setTrue: showSetAPIKey, setFalse: hideSetAPIkey }] = useBoolean()
|
const [isShowSetAPIKey, { setTrue: showSetAPIKey, setFalse: hideSetAPIkey }] = useBoolean()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(fetchAppDetail({ url: '/apps', id: appId }) as any).then(async (res: AppDetailResponse) => {
|
fetchAppDetail({ url: '/apps', id: appId }).then(async (res) => {
|
||||||
setMode(res.mode)
|
setMode(res.mode)
|
||||||
const modelConfig = res.model_config
|
const modelConfig = res.model_config
|
||||||
const model = res.model_config.model
|
const model = res.model_config.model
|
||||||
@ -250,7 +251,7 @@ const Configuration: FC = () => {
|
|||||||
|
|
||||||
const [showConfirm, setShowConfirm] = useState(false)
|
const [showConfirm, setShowConfirm] = useState(false)
|
||||||
const resetAppConfig = () => {
|
const resetAppConfig = () => {
|
||||||
syncToPublishedConfig(publishedConfig)
|
syncToPublishedConfig(publishedConfig!)
|
||||||
setShowConfirm(false)
|
setShowConfirm(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -48,7 +48,7 @@ const translation = {
|
|||||||
copyright: 'Copyright',
|
copyright: 'Copyright',
|
||||||
copyRightPlaceholder: 'Enter the name of the author or organization',
|
copyRightPlaceholder: 'Enter the name of the author or organization',
|
||||||
privacyPolicy: 'Privacy Policy',
|
privacyPolicy: 'Privacy Policy',
|
||||||
privacyPolicyPlaceholder: 'Enter the privacy policy',
|
privacyPolicyPlaceholder: 'Enter the privacy policy link',
|
||||||
privacyPolicyTip: 'Helps visitors understand the data the application collects, see Dify\'s <privacyPolicyLink>Privacy Policy</privacyPolicyLink>.',
|
privacyPolicyTip: 'Helps visitors understand the data the application collects, see Dify\'s <privacyPolicyLink>Privacy Policy</privacyPolicyLink>.',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -48,7 +48,7 @@ const translation = {
|
|||||||
copyright: '版权',
|
copyright: '版权',
|
||||||
copyRightPlaceholder: '请输入作者或组织名称',
|
copyRightPlaceholder: '请输入作者或组织名称',
|
||||||
privacyPolicy: '隐私政策',
|
privacyPolicy: '隐私政策',
|
||||||
privacyPolicyPlaceholder: '请输入隐私政策',
|
privacyPolicyPlaceholder: '请输入隐私政策链接',
|
||||||
privacyPolicyTip: '帮助访问者了解该应用收集的数据,可参考 Dify 的<privacyPolicyLink>隐私政策</privacyPolicyLink>。',
|
privacyPolicyTip: '帮助访问者了解该应用收集的数据,可参考 Dify 的<privacyPolicyLink>隐私政策</privacyPolicyLink>。',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -29,6 +29,12 @@ export type CompletionParamsType = {
|
|||||||
frequency_penalty: number
|
frequency_penalty: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type LogModelConfig = {
|
||||||
|
name: string
|
||||||
|
provider: string
|
||||||
|
completion_params: CompletionParamsType
|
||||||
|
}
|
||||||
|
|
||||||
export type ModelConfigDetail = {
|
export type ModelConfigDetail = {
|
||||||
introduction: string
|
introduction: string
|
||||||
prompt_template: string
|
prompt_template: string
|
||||||
@ -155,6 +161,7 @@ export type ChatConversationFullDetailResponse = Omit<CompletionConversationGene
|
|||||||
provider: string
|
provider: string
|
||||||
model_id: string
|
model_id: string
|
||||||
configs: ModelConfigDetail
|
configs: ModelConfigDetail
|
||||||
|
model: LogModelConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ export const fetchAppList: Fetcher<AppListResponse, { url: string; params?: Reco
|
|||||||
return get<AppListResponse>(url, { params })
|
return get<AppListResponse>(url, { params })
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fetchAppDetail: Fetcher<AppDetailResponse, { url: string; id: string }> = ({ url, id }) => {
|
export const fetchAppDetail = ({ url, id }: { url: string; id: string }) => {
|
||||||
return get<AppDetailResponse>(`${url}/${id}`)
|
return get<AppDetailResponse>(`${url}/${id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ export const updateAppSiteAccessToken: Fetcher<UpdateAppSiteCodeResponse, { url:
|
|||||||
return post<UpdateAppSiteCodeResponse>(url)
|
return post<UpdateAppSiteCodeResponse>(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateAppSiteConfig: Fetcher<AppDetailResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
|
export const updateAppSiteConfig = ({ url, body }: { url: string; body: Record<string, any> }) => {
|
||||||
return post<AppDetailResponse>(url, { body })
|
return post<AppDetailResponse>(url, { body })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { VAR_ITEM_TEMPLATE, getMaxVarNameLength, zhRegex, emojiRegex, MAX_VAR_KEY_LENGHT } from "@/config"
|
import { MAX_VAR_KEY_LENGHT, VAR_ITEM_TEMPLATE, getMaxVarNameLength } from '@/config'
|
||||||
const otherAllowedRegex = new RegExp(`^[a-zA-Z0-9_]+$`)
|
const otherAllowedRegex = /^[a-zA-Z0-9_]+$/
|
||||||
|
|
||||||
export const getNewVar = (key: string) => {
|
export const getNewVar = (key: string) => {
|
||||||
return {
|
return {
|
||||||
@ -10,19 +10,19 @@ export const getNewVar = (key: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const checkKey = (key: string, canBeEmpty?: boolean) => {
|
const checkKey = (key: string, canBeEmpty?: boolean) => {
|
||||||
if (key.length === 0 && !canBeEmpty) {
|
if (key.length === 0 && !canBeEmpty)
|
||||||
return 'canNoBeEmpty'
|
return 'canNoBeEmpty'
|
||||||
}
|
|
||||||
if (canBeEmpty && key === '') {
|
if (canBeEmpty && key === '')
|
||||||
return true
|
return true
|
||||||
}
|
|
||||||
if (key.length > MAX_VAR_KEY_LENGHT) {
|
if (key.length > MAX_VAR_KEY_LENGHT)
|
||||||
return 'tooLong'
|
return 'tooLong'
|
||||||
}
|
|
||||||
if (otherAllowedRegex.test(key)) {
|
if (otherAllowedRegex.test(key)) {
|
||||||
if (/[0-9]/.test(key[0])) {
|
if (/[0-9]/.test(key[0]))
|
||||||
return 'notStartWithNumber'
|
return 'notStartWithNumber'
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return 'notValid'
|
return 'notValid'
|
||||||
@ -33,9 +33,9 @@ export const checkKeys = (keys: string[], canBeEmpty?: boolean) => {
|
|||||||
let errorKey = ''
|
let errorKey = ''
|
||||||
let errorMessageKey = ''
|
let errorMessageKey = ''
|
||||||
keys.forEach((key) => {
|
keys.forEach((key) => {
|
||||||
if (!isValid) {
|
if (!isValid)
|
||||||
return
|
return
|
||||||
}
|
|
||||||
const res = checkKey(key, canBeEmpty)
|
const res = checkKey(key, canBeEmpty)
|
||||||
if (res !== true) {
|
if (res !== true) {
|
||||||
isValid = false
|
isValid = false
|
||||||
@ -44,4 +44,4 @@ export const checkKeys = (keys: string[], canBeEmpty?: boolean) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
return { isValid, errorKey, errorMessageKey }
|
return { isValid, errorKey, errorMessageKey }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user