mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 10:28:10 +08:00
provider compatible in model_config
This commit is contained in:
@ -71,8 +71,9 @@ import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
|
|||||||
import { SupportUploadFileTypes } from '@/app/components/workflow/types'
|
import { SupportUploadFileTypes } from '@/app/components/workflow/types'
|
||||||
import NewFeaturePanel from '@/app/components/base/features/new-feature-panel'
|
import NewFeaturePanel from '@/app/components/base/features/new-feature-panel'
|
||||||
import { fetchFileUploadConfig } from '@/service/common'
|
import { fetchFileUploadConfig } from '@/service/common'
|
||||||
|
import { correctProvider } from '@/utils'
|
||||||
|
|
||||||
interface PublishConfig {
|
type PublishConfig = {
|
||||||
modelConfig: ModelConfig
|
modelConfig: ModelConfig
|
||||||
completionParams: FormValue
|
completionParams: FormValue
|
||||||
}
|
}
|
||||||
@ -156,6 +157,7 @@ const Configuration: FC = () => {
|
|||||||
const setCompletionParams = (value: FormValue) => {
|
const setCompletionParams = (value: FormValue) => {
|
||||||
const params = { ...value }
|
const params = { ...value }
|
||||||
|
|
||||||
|
// eslint-disable-next-line ts/no-use-before-define
|
||||||
if ((!params.stop || params.stop.length === 0) && (modeModeTypeRef.current === ModelModeType.completion)) {
|
if ((!params.stop || params.stop.length === 0) && (modeModeTypeRef.current === ModelModeType.completion)) {
|
||||||
params.stop = getTempStop()
|
params.stop = getTempStop()
|
||||||
setTempStop([])
|
setTempStop([])
|
||||||
@ -164,7 +166,7 @@ const Configuration: FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const [modelConfig, doSetModelConfig] = useState<ModelConfig>({
|
const [modelConfig, doSetModelConfig] = useState<ModelConfig>({
|
||||||
provider: 'openai',
|
provider: 'langgenius/openai/openai',
|
||||||
model_id: 'gpt-3.5-turbo',
|
model_id: 'gpt-3.5-turbo',
|
||||||
mode: ModelModeType.unset,
|
mode: ModelModeType.unset,
|
||||||
configs: {
|
configs: {
|
||||||
@ -187,7 +189,7 @@ const Configuration: FC = () => {
|
|||||||
|
|
||||||
const isAgent = mode === 'agent-chat'
|
const isAgent = mode === 'agent-chat'
|
||||||
|
|
||||||
const isOpenAI = modelConfig.provider === 'openai'
|
const isOpenAI = modelConfig.provider === 'langgenius/openai/openai'
|
||||||
|
|
||||||
const [collectionList, setCollectionList] = useState<Collection[]>([])
|
const [collectionList, setCollectionList] = useState<Collection[]>([])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -356,6 +358,7 @@ const Configuration: FC = () => {
|
|||||||
const [canReturnToSimpleMode, setCanReturnToSimpleMode] = useState(true)
|
const [canReturnToSimpleMode, setCanReturnToSimpleMode] = useState(true)
|
||||||
const setPromptMode = async (mode: PromptMode) => {
|
const setPromptMode = async (mode: PromptMode) => {
|
||||||
if (mode === PromptMode.advanced) {
|
if (mode === PromptMode.advanced) {
|
||||||
|
// eslint-disable-next-line ts/no-use-before-define
|
||||||
await migrateToDefaultPrompt()
|
await migrateToDefaultPrompt()
|
||||||
setCanReturnToSimpleMode(true)
|
setCanReturnToSimpleMode(true)
|
||||||
}
|
}
|
||||||
@ -540,8 +543,19 @@ const Configuration: FC = () => {
|
|||||||
if (modelConfig.retriever_resource)
|
if (modelConfig.retriever_resource)
|
||||||
setCitationConfig(modelConfig.retriever_resource)
|
setCitationConfig(modelConfig.retriever_resource)
|
||||||
|
|
||||||
if (modelConfig.annotation_reply)
|
if (modelConfig.annotation_reply) {
|
||||||
setAnnotationConfig(modelConfig.annotation_reply, true)
|
let annotationConfig = modelConfig.annotation_reply
|
||||||
|
if (modelConfig.annotation_reply.enabled) {
|
||||||
|
annotationConfig = {
|
||||||
|
...modelConfig.annotation_reply,
|
||||||
|
embedding_model: {
|
||||||
|
...modelConfig.annotation_reply.embedding_model,
|
||||||
|
embedding_provider_name: correctProvider(modelConfig.annotation_reply.embedding_model.embedding_provider_name),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setAnnotationConfig(annotationConfig, true)
|
||||||
|
}
|
||||||
|
|
||||||
if (modelConfig.sensitive_word_avoidance)
|
if (modelConfig.sensitive_word_avoidance)
|
||||||
setModerationConfig(modelConfig.sensitive_word_avoidance)
|
setModerationConfig(modelConfig.sensitive_word_avoidance)
|
||||||
@ -551,7 +565,7 @@ const Configuration: FC = () => {
|
|||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
modelConfig: {
|
modelConfig: {
|
||||||
provider: model.provider,
|
provider: correctProvider(model.provider),
|
||||||
model_id: model.name,
|
model_id: model.name,
|
||||||
mode: model.mode,
|
mode: model.mode,
|
||||||
configs: {
|
configs: {
|
||||||
@ -605,6 +619,10 @@ const Configuration: FC = () => {
|
|||||||
...tool,
|
...tool,
|
||||||
isDeleted: res.deleted_tools?.includes(tool.tool_name),
|
isDeleted: res.deleted_tools?.includes(tool.tool_name),
|
||||||
notAuthor: collectionList.find(c => tool.provider_id === c.id)?.is_team_authorization === false,
|
notAuthor: collectionList.find(c => tool.provider_id === c.id)?.is_team_authorization === false,
|
||||||
|
...(tool.provider_type === 'builtin' ? {
|
||||||
|
provider_id: correctProvider(tool.provider_name),
|
||||||
|
provider_name: correctProvider(tool.provider_name),
|
||||||
|
} : {}),
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
} : DEFAULT_AGENT_SETTING,
|
} : DEFAULT_AGENT_SETTING,
|
||||||
@ -622,6 +640,12 @@ const Configuration: FC = () => {
|
|||||||
retrieval_model: RETRIEVE_TYPE.multiWay,
|
retrieval_model: RETRIEVE_TYPE.multiWay,
|
||||||
...modelConfig.dataset_configs,
|
...modelConfig.dataset_configs,
|
||||||
...retrievalConfig,
|
...retrievalConfig,
|
||||||
|
...(retrievalConfig.reranking_model ? {
|
||||||
|
reranking_model: {
|
||||||
|
...retrievalConfig.reranking_model,
|
||||||
|
reranking_provider_name: correctProvider(modelConfig.dataset_configs.reranking_model.reranking_provider_name),
|
||||||
|
},
|
||||||
|
} : {}),
|
||||||
})
|
})
|
||||||
setHasFetchedDetail(true)
|
setHasFetchedDetail(true)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -35,6 +35,7 @@ import type { ToolNodeType } from './nodes/tool/types'
|
|||||||
import type { IterationNodeType } from './nodes/iteration/types'
|
import type { IterationNodeType } from './nodes/iteration/types'
|
||||||
import { CollectionType } from '@/app/components/tools/types'
|
import { CollectionType } from '@/app/components/tools/types'
|
||||||
import { toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema'
|
import { toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema'
|
||||||
|
import { correctProvider } from '@/utils'
|
||||||
|
|
||||||
const WHITE = 'WHITE'
|
const WHITE = 'WHITE'
|
||||||
const GRAY = 'GRAY'
|
const GRAY = 'GRAY'
|
||||||
@ -212,13 +213,6 @@ export const preprocessNodesAndEdges = (nodes: Node[], edges: Edge[]) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const correctProvider = (provider: string) => {
|
|
||||||
if (provider.includes('/'))
|
|
||||||
return provider
|
|
||||||
|
|
||||||
return `langgenius/${provider}/${provider}`
|
|
||||||
}
|
|
||||||
|
|
||||||
export const initialNodes = (originNodes: Node[], originEdges: Edge[]) => {
|
export const initialNodes = (originNodes: Node[], originEdges: Edge[]) => {
|
||||||
const { nodes, edges } = preprocessNodesAndEdges(cloneDeep(originNodes), cloneDeep(originEdges))
|
const { nodes, edges } = preprocessNodesAndEdges(cloneDeep(originNodes), cloneDeep(originEdges))
|
||||||
const firstNode = nodes[0]
|
const firstNode = nodes[0]
|
||||||
|
|||||||
@ -57,3 +57,10 @@ export async function fetchWithRetry<T = any>(fn: Promise<T>, retries = 3): Prom
|
|||||||
return [null, res]
|
return [null, res]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const correctProvider = (provider: string) => {
|
||||||
|
if (provider.includes('/'))
|
||||||
|
return provider
|
||||||
|
|
||||||
|
return `langgenius/${provider}/${provider}`
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user