mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 19:59:50 +08:00
parent
f2a5da918b
commit
c39be7852f
|
@ -25,7 +25,7 @@ import { useSelectedDatasetsMode } from '@/app/components/workflow/nodes/knowled
|
|||
import Switch from '@/app/components/base/switch'
|
||||
import Toast from '@/app/components/base/toast'
|
||||
|
||||
type Props = {
|
||||
interface Props {
|
||||
datasetConfigs: DatasetConfigs
|
||||
onChange: (configs: DatasetConfigs, isRetrievalModeChange?: boolean) => void
|
||||
isInWorkflow?: boolean
|
||||
|
@ -71,7 +71,6 @@ const ConfigContent: FC<Props> = ({
|
|||
? {
|
||||
...rerankDefaultModel,
|
||||
provider: rerankDefaultModel.provider.provider,
|
||||
plugin_id: rerankDefaultModel.provider.plugin_id,
|
||||
}
|
||||
: undefined,
|
||||
)
|
||||
|
@ -81,14 +80,12 @@ const ConfigContent: FC<Props> = ({
|
|||
return {
|
||||
provider_name: datasetConfigs.reranking_model.reranking_provider_name,
|
||||
model_name: datasetConfigs.reranking_model.reranking_model_name,
|
||||
plugin_id: datasetConfigs.reranking_model.reranking_plugin_id,
|
||||
}
|
||||
}
|
||||
else if (rerankDefaultModel) {
|
||||
return {
|
||||
provider_name: rerankDefaultModel.provider.provider,
|
||||
model_name: rerankDefaultModel.model,
|
||||
plugin_id: rerankDefaultModel.provider.plugin_id,
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
@ -175,7 +172,7 @@ const ConfigContent: FC<Props> = ({
|
|||
return false
|
||||
|
||||
return datasetConfigs.reranking_enable
|
||||
}, [canManuallyToggleRerank, datasetConfigs.reranking_enable, isRerankDefaultModelValid])
|
||||
}, [canManuallyToggleRerank, datasetConfigs.reranking_enable])
|
||||
|
||||
const handleDisabledSwitchClick = useCallback(() => {
|
||||
if (!currentRerankModel && !showRerankModel)
|
||||
|
@ -303,14 +300,13 @@ const ConfigContent: FC<Props> = ({
|
|||
</div>
|
||||
<div>
|
||||
<ModelSelector
|
||||
defaultModel={rerankModel && { provider: rerankModel?.provider_name, model: rerankModel?.model_name, plugin_id: rerankModel?.plugin_id }}
|
||||
defaultModel={rerankModel && { provider: rerankModel?.provider_name, model: rerankModel?.model_name }}
|
||||
onSelect={(v) => {
|
||||
onChange({
|
||||
...datasetConfigs,
|
||||
reranking_model: {
|
||||
reranking_provider_name: v.provider,
|
||||
reranking_model_name: v.model,
|
||||
reranking_plugin_id: v.plugin_id,
|
||||
},
|
||||
})
|
||||
}}
|
||||
|
@ -388,7 +384,6 @@ const ConfigContent: FC<Props> = ({
|
|||
portalToFollowElemContentClassName='!z-[1002]'
|
||||
isAdvancedMode={true}
|
||||
mode={model?.mode}
|
||||
pluginId={model?.plugin_id}
|
||||
provider={model?.provider}
|
||||
completionParams={model?.completion_params}
|
||||
modelId={model?.name}
|
||||
|
|
|
@ -36,13 +36,12 @@ const ModelParameterTrigger: FC<ModelParameterTriggerProps> = ({
|
|||
const language = useLanguage()
|
||||
const index = multipleModelConfigs.findIndex(v => v.id === modelAndParameter.id)
|
||||
|
||||
const handleSelectModel = ({ modelId, provider, pluginId }: { modelId: string; provider: string; pluginId: string }) => {
|
||||
const handleSelectModel = ({ modelId, provider }: { modelId: string; provider: string }) => {
|
||||
const newModelConfigs = [...multipleModelConfigs]
|
||||
newModelConfigs[index] = {
|
||||
...newModelConfigs[index],
|
||||
model: modelId,
|
||||
provider,
|
||||
plugin_id: pluginId,
|
||||
}
|
||||
onMultipleModelConfigsChange(true, newModelConfigs)
|
||||
}
|
||||
|
@ -59,7 +58,6 @@ const ModelParameterTrigger: FC<ModelParameterTriggerProps> = ({
|
|||
<ModelParameterModal
|
||||
mode={mode}
|
||||
isAdvancedMode={isAdvancedMode}
|
||||
pluginId={modelAndParameter.plugin_id}
|
||||
provider={modelAndParameter.provider}
|
||||
modelId={modelAndParameter.model}
|
||||
completionParams={modelAndParameter.parameters}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
export type ModelAndParameter = {
|
||||
id: string
|
||||
model: string
|
||||
plugin_id: string
|
||||
provider: string
|
||||
parameters: Record<string, any>
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ import { SupportUploadFileTypes } from '@/app/components/workflow/types'
|
|||
import NewFeaturePanel from '@/app/components/base/features/new-feature-panel'
|
||||
import { fetchFileUploadConfig } from '@/service/common'
|
||||
|
||||
type PublishConfig = {
|
||||
interface PublishConfig {
|
||||
modelConfig: ModelConfig
|
||||
completionParams: FormValue
|
||||
}
|
||||
|
@ -156,7 +156,6 @@ const Configuration: FC = () => {
|
|||
const setCompletionParams = (value: FormValue) => {
|
||||
const params = { ...value }
|
||||
|
||||
// eslint-disable-next-line ts/no-use-before-define
|
||||
if ((!params.stop || params.stop.length === 0) && (modeModeTypeRef.current === ModelModeType.completion)) {
|
||||
params.stop = getTempStop()
|
||||
setTempStop([])
|
||||
|
@ -165,7 +164,6 @@ const Configuration: FC = () => {
|
|||
}
|
||||
|
||||
const [modelConfig, doSetModelConfig] = useState<ModelConfig>({
|
||||
plugin_id: 'langgenius',
|
||||
provider: 'openai',
|
||||
model_id: 'gpt-3.5-turbo',
|
||||
mode: ModelModeType.unset,
|
||||
|
@ -200,7 +198,6 @@ const Configuration: FC = () => {
|
|||
reranking_model: {
|
||||
reranking_provider_name: '',
|
||||
reranking_model_name: '',
|
||||
reranking_plugin_id: '',
|
||||
},
|
||||
top_k: DATASET_DEFAULT.top_k,
|
||||
score_threshold_enabled: false,
|
||||
|
@ -282,7 +279,6 @@ const Configuration: FC = () => {
|
|||
reranking_model: restConfigs.reranking_model && {
|
||||
reranking_provider_name: restConfigs.reranking_model.reranking_provider_name,
|
||||
reranking_model_name: restConfigs.reranking_model.reranking_model_name,
|
||||
reranking_plugin_id: restConfigs.reranking_model.reranking_plugin_id,
|
||||
},
|
||||
retrieval_model,
|
||||
score_threshold_enabled,
|
||||
|
@ -324,7 +320,6 @@ const Configuration: FC = () => {
|
|||
textGenerationModelList,
|
||||
} = useTextGenerationCurrentProviderAndModelAndModelList(
|
||||
{
|
||||
plugin_id: modelConfig.plugin_id,
|
||||
provider: modelConfig.provider,
|
||||
model: modelConfig.model_id,
|
||||
},
|
||||
|
@ -355,7 +350,6 @@ const Configuration: FC = () => {
|
|||
const [canReturnToSimpleMode, setCanReturnToSimpleMode] = useState(true)
|
||||
const setPromptMode = async (mode: PromptMode) => {
|
||||
if (mode === PromptMode.advanced) {
|
||||
// eslint-disable-next-line ts/no-use-before-define
|
||||
await migrateToDefaultPrompt()
|
||||
setCanReturnToSimpleMode(true)
|
||||
}
|
||||
|
@ -551,7 +545,6 @@ const Configuration: FC = () => {
|
|||
|
||||
const config = {
|
||||
modelConfig: {
|
||||
plugin_id: model.plugin_id,
|
||||
provider: model.provider,
|
||||
model_id: model.name,
|
||||
mode: model.mode,
|
||||
|
@ -770,8 +763,8 @@ const Configuration: FC = () => {
|
|||
handleMultipleModelConfigsChange(
|
||||
true,
|
||||
[
|
||||
{ id: `${Date.now()}`, model: modelConfig.model_id, plugin_id: modelConfig.plugin_id, provider: modelConfig.provider, parameters: completionParams },
|
||||
{ id: `${Date.now()}-no-repeat`, model: '', plugin_id: '', provider: '', parameters: {} },
|
||||
{ id: `${Date.now()}`, model: modelConfig.model_id, provider: modelConfig.provider, parameters: completionParams },
|
||||
{ id: `${Date.now()}-no-repeat`, model: '', provider: '', parameters: {} },
|
||||
],
|
||||
)
|
||||
setAppSiderbarExpand('collapse')
|
||||
|
@ -893,7 +886,6 @@ const Configuration: FC = () => {
|
|||
<ModelParameterModal
|
||||
isAdvancedMode={isAdvancedMode}
|
||||
mode={mode}
|
||||
pluginId={modelConfig.plugin_id}
|
||||
provider={modelConfig.provider}
|
||||
completionParams={completionParams}
|
||||
modelId={modelConfig.model_id}
|
||||
|
|
|
@ -38,9 +38,8 @@ export type ModelParameterModalProps = {
|
|||
isAdvancedMode: boolean
|
||||
mode: string
|
||||
modelId: string
|
||||
pluginId: string
|
||||
provider: string
|
||||
setModel: (model: { modelId: string; provider: string; pluginId: string; mode?: string; features?: string[] }) => void
|
||||
setModel: (model: { modelId: string; provider: string; mode?: string; features?: string[] }) => void
|
||||
completionParams: FormValue
|
||||
onCompletionParamsChange: (newParams: FormValue) => void
|
||||
hideDebugWithMultipleModel?: boolean
|
||||
|
@ -75,7 +74,6 @@ const ModelParameterModal: FC<ModelParameterModalProps> = ({
|
|||
portalToFollowElemContentClassName,
|
||||
isAdvancedMode,
|
||||
modelId,
|
||||
pluginId,
|
||||
provider,
|
||||
setModel,
|
||||
completionParams,
|
||||
|
@ -90,17 +88,13 @@ const ModelParameterModal: FC<ModelParameterModalProps> = ({
|
|||
const { t } = useTranslation()
|
||||
const { isAPIKeySet } = useProviderContext()
|
||||
const [open, setOpen] = useState(false)
|
||||
const { data: parameterRulesData, isLoading } = useSWR((provider && modelId) ? `/workspaces/current/model-providers/${pluginId}/${provider}/models/parameter-rules?model=${modelId}` : null, fetchModelParameterRules)
|
||||
const { data: parameterRulesData, isLoading } = useSWR((provider && modelId) ? `/workspaces/current/model-providers/${provider}/models/parameter-rules?model=${modelId}` : null, fetchModelParameterRules)
|
||||
const {
|
||||
currentProvider,
|
||||
currentModel,
|
||||
activeTextGenerationModelList,
|
||||
} = useTextGenerationCurrentProviderAndModelAndModelList(
|
||||
{
|
||||
plugin_id: pluginId,
|
||||
provider,
|
||||
model: modelId,
|
||||
},
|
||||
{ provider, model: modelId },
|
||||
)
|
||||
|
||||
const hasDeprecated = !currentProvider || !currentModel
|
||||
|
@ -118,12 +112,11 @@ const ModelParameterModal: FC<ModelParameterModalProps> = ({
|
|||
})
|
||||
}
|
||||
|
||||
const handleChangeModel = ({ provider, model, plugin_id }: DefaultModel) => {
|
||||
const handleChangeModel = ({ provider, model }: DefaultModel) => {
|
||||
const targetProvider = activeTextGenerationModelList.find(modelItem => modelItem.provider === provider)
|
||||
const targetModelItem = targetProvider?.models.find(modelItem => modelItem.model === model)
|
||||
setModel({
|
||||
modelId: model,
|
||||
pluginId: plugin_id,
|
||||
provider,
|
||||
mode: targetModelItem?.model_properties.mode as string,
|
||||
features: targetModelItem?.features || [],
|
||||
|
@ -208,7 +201,7 @@ const ModelParameterModal: FC<ModelParameterModalProps> = ({
|
|||
{t('common.modelProvider.model').toLocaleUpperCase()}
|
||||
</div>
|
||||
<ModelSelector
|
||||
defaultModel={(provider || modelId) ? { plugin_id: pluginId, provider, model: modelId } : undefined}
|
||||
defaultModel={(provider || modelId) ? { provider, model: modelId } : undefined}
|
||||
modelList={activeTextGenerationModelList}
|
||||
onSelect={handleChangeModel}
|
||||
triggerClassName='max-w-[295px]'
|
||||
|
|
|
@ -41,11 +41,11 @@ const ModelSelector: FC<ModelSelectorProps> = ({
|
|||
defaultModel,
|
||||
)
|
||||
|
||||
const handleSelect = (pluginId: string, provider: string, model: ModelItem) => {
|
||||
const handleSelect = (provider: string, model: ModelItem) => {
|
||||
setOpen(false)
|
||||
|
||||
if (onSelect)
|
||||
onSelect({ plugin_id: pluginId, provider, model: model.model })
|
||||
onSelect({ provider, model: model.model })
|
||||
}
|
||||
|
||||
const handleToggle = () => {
|
||||
|
|
|
@ -25,7 +25,7 @@ import Tooltip from '@/app/components/base/tooltip'
|
|||
type PopupItemProps = {
|
||||
defaultModel?: DefaultModel
|
||||
model: Model
|
||||
onSelect: (pluginId: string, provider: string, model: ModelItem) => void
|
||||
onSelect: (provider: string, model: ModelItem) => void
|
||||
}
|
||||
const PopupItem: FC<PopupItemProps> = ({
|
||||
defaultModel,
|
||||
|
@ -39,11 +39,11 @@ const PopupItem: FC<PopupItemProps> = ({
|
|||
const updateModelList = useUpdateModelList()
|
||||
const updateModelProviders = useUpdateModelProviders()
|
||||
const currentProvider = modelProviders.find(provider => provider.provider === model.provider)!
|
||||
const handleSelect = (pluginId: string, provider: string, modelItem: ModelItem) => {
|
||||
const handleSelect = (provider: string, modelItem: ModelItem) => {
|
||||
if (modelItem.status !== ModelStatusEnum.active)
|
||||
return
|
||||
|
||||
onSelect(pluginId, provider, modelItem)
|
||||
onSelect(provider, modelItem)
|
||||
}
|
||||
const handleOpenModelModal = () => {
|
||||
setShowModelModal({
|
||||
|
@ -80,7 +80,7 @@ const PopupItem: FC<PopupItemProps> = ({
|
|||
group relative flex items-center px-3 py-1.5 h-8 rounded-lg
|
||||
${modelItem.status === ModelStatusEnum.active ? 'cursor-pointer hover:bg-gray-50' : 'cursor-not-allowed hover:bg-gray-50/60'}
|
||||
`}
|
||||
onClick={() => handleSelect(model.plugin_id, model.provider, modelItem)}
|
||||
onClick={() => handleSelect(model.provider, modelItem)}
|
||||
>
|
||||
<ModelIcon
|
||||
className={`
|
||||
|
|
|
@ -15,7 +15,7 @@ import { XCircle } from '@/app/components/base/icons/src/vender/solid/general'
|
|||
type PopupProps = {
|
||||
defaultModel?: DefaultModel
|
||||
modelList: Model[]
|
||||
onSelect: (pluginId: string, provider: string, model: ModelItem) => void
|
||||
onSelect: (provider: string, model: ModelItem) => void
|
||||
}
|
||||
const Popup: FC<PopupProps> = ({
|
||||
defaultModel,
|
||||
|
|
|
@ -132,7 +132,6 @@ const Panel: FC<NodePanelProps<LLMNodeType>> = ({
|
|||
isInWorkflow
|
||||
isAdvancedMode={true}
|
||||
mode={model?.mode}
|
||||
pluginId={model?.plugin_id}
|
||||
provider={model?.provider}
|
||||
completionParams={model?.completion_params}
|
||||
modelId={model?.name}
|
||||
|
|
|
@ -123,7 +123,7 @@ const useConfig = (id: string, payload: LLMNodeType) => {
|
|||
},
|
||||
})
|
||||
|
||||
const handleModelChanged = useCallback((model: { provider: string; modelId: string; pluginId: string; mode?: string }) => {
|
||||
const handleModelChanged = useCallback((model: { provider: string; modelId: string; mode?: string }) => {
|
||||
const newInputs = produce(inputRef.current, (draft) => {
|
||||
draft.model.provider = model.provider
|
||||
draft.model.name = model.modelId
|
||||
|
@ -139,7 +139,6 @@ const useConfig = (id: string, payload: LLMNodeType) => {
|
|||
useEffect(() => {
|
||||
if (currentProvider?.provider && currentModel?.model && !model.provider) {
|
||||
handleModelChanged({
|
||||
pluginId: currentProvider?.plugin_id,
|
||||
provider: currentProvider?.provider,
|
||||
modelId: currentModel?.model,
|
||||
mode: currentModel?.model_properties?.mode as string,
|
||||
|
|
|
@ -77,7 +77,6 @@ const Panel: FC<NodePanelProps<ParameterExtractorNodeType>> = ({
|
|||
isInWorkflow
|
||||
isAdvancedMode={true}
|
||||
mode={model?.mode}
|
||||
pluginId={model?.plugin_id}
|
||||
provider={model?.provider}
|
||||
completionParams={model?.completion_params}
|
||||
modelId={model?.name}
|
||||
|
|
|
@ -65,7 +65,6 @@ const Panel: FC<NodePanelProps<QuestionClassifierNodeType>> = ({
|
|||
isInWorkflow
|
||||
isAdvancedMode={true}
|
||||
mode={model?.mode}
|
||||
pluginId={model?.plugin_id}
|
||||
provider={model?.provider}
|
||||
completionParams={model.completion_params}
|
||||
modelId={model.name}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { CommonNodeType, Memory, ModelConfig, ValueSelector, VisionSetting } from '@/app/components/workflow/types'
|
||||
|
||||
export type Topic = {
|
||||
export interface Topic {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ export enum ControlMode {
|
|||
Hand = 'hand',
|
||||
}
|
||||
|
||||
export type Branch = {
|
||||
export interface Branch {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ export type CommonNodeType<T = {}> = {
|
|||
height?: number
|
||||
} & T & Partial<Pick<ToolDefaultValue, 'provider_id' | 'provider_type' | 'provider_name' | 'tool_name'>>
|
||||
|
||||
export type CommonEdgeType = {
|
||||
export interface CommonEdgeType {
|
||||
_hovering?: boolean
|
||||
_connectedNodeIsHovering?: boolean
|
||||
_connectedNodeIsSelected?: boolean
|
||||
|
@ -82,14 +82,14 @@ export type CommonEdgeType = {
|
|||
|
||||
export type Node<T = {}> = ReactFlowNode<CommonNodeType<T>>
|
||||
export type SelectedNode = Pick<Node, 'id' | 'data'>
|
||||
export type NodeProps<T = unknown> = { id: string; data: CommonNodeType<T> }
|
||||
export type NodePanelProps<T> = {
|
||||
export interface NodeProps<T = unknown> { id: string; data: CommonNodeType<T> }
|
||||
export interface NodePanelProps<T> {
|
||||
id: string
|
||||
data: CommonNodeType<T>
|
||||
}
|
||||
export type Edge = ReactFlowEdge<CommonEdgeType>
|
||||
|
||||
export type WorkflowDataUpdater = {
|
||||
export interface WorkflowDataUpdater {
|
||||
nodes: Node[]
|
||||
edges: Edge[]
|
||||
viewport: Viewport
|
||||
|
@ -97,7 +97,7 @@ export type WorkflowDataUpdater = {
|
|||
|
||||
export type ValueSelector = string[] // [nodeId, key | obj key path]
|
||||
|
||||
export type Variable = {
|
||||
export interface Variable {
|
||||
variable: string
|
||||
label?: string | {
|
||||
nodeType: BlockEnum
|
||||
|
@ -112,14 +112,14 @@ export type Variable = {
|
|||
isParagraph?: boolean
|
||||
}
|
||||
|
||||
export type EnvironmentVariable = {
|
||||
export interface EnvironmentVariable {
|
||||
id: string
|
||||
name: string
|
||||
value: any
|
||||
value_type: 'string' | 'number' | 'secret'
|
||||
}
|
||||
|
||||
export type ConversationVariable = {
|
||||
export interface ConversationVariable {
|
||||
id: string
|
||||
name: string
|
||||
value_type: ChatVarType
|
||||
|
@ -127,13 +127,13 @@ export type ConversationVariable = {
|
|||
description: string
|
||||
}
|
||||
|
||||
export type GlobalVariable = {
|
||||
export interface GlobalVariable {
|
||||
name: string
|
||||
value_type: 'string' | 'number'
|
||||
description: string
|
||||
}
|
||||
|
||||
export type VariableWithValue = {
|
||||
export interface VariableWithValue {
|
||||
key: string
|
||||
value: string
|
||||
}
|
||||
|
@ -169,8 +169,7 @@ export type InputVar = {
|
|||
value_selector?: ValueSelector
|
||||
} & Partial<UploadFileSetting>
|
||||
|
||||
export type ModelConfig = {
|
||||
plugin_id: string
|
||||
export interface ModelConfig {
|
||||
provider: string
|
||||
name: string
|
||||
mode: string
|
||||
|
@ -188,7 +187,7 @@ export enum EditionType {
|
|||
jinja2 = 'jinja2',
|
||||
}
|
||||
|
||||
export type PromptItem = {
|
||||
export interface PromptItem {
|
||||
id?: string
|
||||
role?: PromptRole
|
||||
text: string
|
||||
|
@ -201,12 +200,12 @@ export enum MemoryRole {
|
|||
assistant = 'assistant',
|
||||
}
|
||||
|
||||
export type RolePrefix = {
|
||||
export interface RolePrefix {
|
||||
user: string
|
||||
assistant: string
|
||||
}
|
||||
|
||||
export type Memory = {
|
||||
export interface Memory {
|
||||
role_prefix?: RolePrefix
|
||||
window: {
|
||||
enabled: boolean
|
||||
|
@ -230,7 +229,7 @@ export enum VarType {
|
|||
any = 'any',
|
||||
}
|
||||
|
||||
export type Var = {
|
||||
export interface Var {
|
||||
variable: string
|
||||
type: VarType
|
||||
children?: Var[] // if type is obj, has the children struct
|
||||
|
@ -241,21 +240,21 @@ export type Var = {
|
|||
des?: string
|
||||
}
|
||||
|
||||
export type NodeOutPutVar = {
|
||||
export interface NodeOutPutVar {
|
||||
nodeId: string
|
||||
title: string
|
||||
vars: Var[]
|
||||
isStartNode?: boolean
|
||||
}
|
||||
|
||||
export type Block = {
|
||||
export interface Block {
|
||||
classification?: string
|
||||
type: BlockEnum
|
||||
title: string
|
||||
description?: string
|
||||
}
|
||||
|
||||
export type NodeDefault<T> = {
|
||||
export interface NodeDefault<T> {
|
||||
defaultValue: Partial<T>
|
||||
getAvailablePrevNodes: (isChatMode: boolean) => BlockEnum[]
|
||||
getAvailableNextNodes: (isChatMode: boolean) => BlockEnum[]
|
||||
|
@ -295,19 +294,19 @@ export type OnNodeAdd = (
|
|||
}
|
||||
) => void
|
||||
|
||||
export type CheckValidRes = {
|
||||
export interface CheckValidRes {
|
||||
isValid: boolean
|
||||
errorMessage?: string
|
||||
}
|
||||
|
||||
export type RunFile = {
|
||||
export interface RunFile {
|
||||
type: string
|
||||
transfer_method: TransferMethod[]
|
||||
url?: string
|
||||
upload_file_id?: string
|
||||
}
|
||||
|
||||
export type WorkflowRunningData = {
|
||||
export interface WorkflowRunningData {
|
||||
task_id?: string
|
||||
message_id?: string
|
||||
conversation_id?: string
|
||||
|
@ -332,7 +331,7 @@ export type WorkflowRunningData = {
|
|||
tracing?: NodeTracing[]
|
||||
}
|
||||
|
||||
export type HistoryWorkflowData = {
|
||||
export interface HistoryWorkflowData {
|
||||
id: string
|
||||
sequence_number: number
|
||||
status: string
|
||||
|
@ -344,7 +343,7 @@ export enum ChangeType {
|
|||
remove = 'remove',
|
||||
}
|
||||
|
||||
export type MoreInfo = {
|
||||
export interface MoreInfo {
|
||||
type: ChangeType
|
||||
payload?: {
|
||||
beforeKey: string
|
||||
|
@ -364,7 +363,7 @@ export enum SupportUploadFileTypes {
|
|||
custom = 'custom',
|
||||
}
|
||||
|
||||
export type UploadFileSetting = {
|
||||
export interface UploadFileSetting {
|
||||
allowed_file_upload_methods: TransferMethod[]
|
||||
allowed_file_types: SupportUploadFileTypes[]
|
||||
allowed_file_extensions?: string[]
|
||||
|
@ -372,7 +371,7 @@ export type UploadFileSetting = {
|
|||
number_limits?: number
|
||||
}
|
||||
|
||||
export type VisionSetting = {
|
||||
export interface VisionSetting {
|
||||
variable_selector: ValueSelector
|
||||
detail: Resolution
|
||||
}
|
||||
|
|
|
@ -10,25 +10,25 @@ export enum PromptMode {
|
|||
advanced = 'advanced',
|
||||
}
|
||||
|
||||
export type PromptItem = {
|
||||
export interface PromptItem {
|
||||
role?: PromptRole
|
||||
text: string
|
||||
}
|
||||
|
||||
export type ChatPromptConfig = {
|
||||
export interface ChatPromptConfig {
|
||||
prompt: PromptItem[]
|
||||
}
|
||||
|
||||
export type ConversationHistoriesRole = {
|
||||
export interface ConversationHistoriesRole {
|
||||
user_prefix: string
|
||||
assistant_prefix: string
|
||||
}
|
||||
export type CompletionPromptConfig = {
|
||||
export interface CompletionPromptConfig {
|
||||
prompt: PromptItem
|
||||
conversation_histories_role: ConversationHistoriesRole
|
||||
}
|
||||
|
||||
export type BlockStatus = {
|
||||
export interface BlockStatus {
|
||||
context: boolean
|
||||
history: boolean
|
||||
query: boolean
|
||||
|
@ -40,7 +40,7 @@ export enum PromptRole {
|
|||
assistant = 'assistant',
|
||||
}
|
||||
|
||||
export type PromptVariable = {
|
||||
export interface PromptVariable {
|
||||
key: string
|
||||
name: string
|
||||
type: string // "string" | "number" | "select",
|
||||
|
@ -55,7 +55,7 @@ export type PromptVariable = {
|
|||
icon_background?: string
|
||||
}
|
||||
|
||||
export type CompletionParams = {
|
||||
export interface CompletionParams {
|
||||
max_tokens: number
|
||||
temperature: number
|
||||
top_p: number
|
||||
|
@ -66,12 +66,12 @@ export type CompletionParams = {
|
|||
|
||||
export type ModelId = 'gpt-3.5-turbo' | 'text-davinci-003'
|
||||
|
||||
export type PromptConfig = {
|
||||
export interface PromptConfig {
|
||||
prompt_template: string
|
||||
prompt_variables: PromptVariable[]
|
||||
}
|
||||
|
||||
export type MoreLikeThisConfig = {
|
||||
export interface MoreLikeThisConfig {
|
||||
enabled: boolean
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ export type SuggestedQuestionsAfterAnswerConfig = MoreLikeThisConfig
|
|||
|
||||
export type SpeechToTextConfig = MoreLikeThisConfig
|
||||
|
||||
export type TextToSpeechConfig = {
|
||||
export interface TextToSpeechConfig {
|
||||
enabled: boolean
|
||||
voice?: string
|
||||
language?: string
|
||||
|
@ -88,7 +88,7 @@ export type TextToSpeechConfig = {
|
|||
|
||||
export type CitationConfig = MoreLikeThisConfig
|
||||
|
||||
export type AnnotationReplyConfig = {
|
||||
export interface AnnotationReplyConfig {
|
||||
id: string
|
||||
enabled: boolean
|
||||
score_threshold: number
|
||||
|
@ -98,7 +98,7 @@ export type AnnotationReplyConfig = {
|
|||
}
|
||||
}
|
||||
|
||||
export type ModerationContentConfig = {
|
||||
export interface ModerationContentConfig {
|
||||
enabled: boolean
|
||||
preset_response?: string
|
||||
}
|
||||
|
@ -113,15 +113,14 @@ export type ModerationConfig = MoreLikeThisConfig & {
|
|||
}
|
||||
|
||||
export type RetrieverResourceConfig = MoreLikeThisConfig
|
||||
export type AgentConfig = {
|
||||
export interface AgentConfig {
|
||||
enabled: boolean
|
||||
strategy: AgentStrategy
|
||||
max_iteration: number
|
||||
tools: ToolItem[]
|
||||
}
|
||||
// frontend use. Not the same as backend
|
||||
export type ModelConfig = {
|
||||
plugin_id: string
|
||||
export interface ModelConfig {
|
||||
provider: string // LLM Provider: for example "OPENAI"
|
||||
model_id: string
|
||||
mode: ModelModeType
|
||||
|
@ -139,17 +138,16 @@ export type ModelConfig = {
|
|||
dataSets: any[]
|
||||
agentConfig: AgentConfig
|
||||
}
|
||||
export type DatasetConfigItem = {
|
||||
export interface DatasetConfigItem {
|
||||
enable: boolean
|
||||
value: number
|
||||
}
|
||||
|
||||
export type DatasetConfigs = {
|
||||
export interface DatasetConfigs {
|
||||
retrieval_model: RETRIEVE_TYPE
|
||||
reranking_model: {
|
||||
reranking_provider_name: string
|
||||
reranking_model_name: string
|
||||
reranking_plugin_id: string
|
||||
}
|
||||
top_k: number
|
||||
score_threshold_enabled: boolean
|
||||
|
@ -174,39 +172,39 @@ export type DatasetConfigs = {
|
|||
reranking_enable?: boolean
|
||||
}
|
||||
|
||||
export type DebugRequestBody = {
|
||||
export interface DebugRequestBody {
|
||||
inputs: Inputs
|
||||
query: string
|
||||
completion_params: CompletionParams
|
||||
model_config: ModelConfig
|
||||
}
|
||||
|
||||
export type DebugResponse = {
|
||||
export interface DebugResponse {
|
||||
id: string
|
||||
answer: string
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export type DebugResponseStream = {
|
||||
export interface DebugResponseStream {
|
||||
id: string
|
||||
data: string
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export type FeedBackRequestBody = {
|
||||
export interface FeedBackRequestBody {
|
||||
message_id: string
|
||||
rating: 'like' | 'dislike'
|
||||
content?: string
|
||||
from_source: 'api' | 'log'
|
||||
}
|
||||
|
||||
export type FeedBackResponse = {
|
||||
export interface FeedBackResponse {
|
||||
message_id: string
|
||||
rating: 'like' | 'dislike'
|
||||
}
|
||||
|
||||
// Log session list
|
||||
export type LogSessionListQuery = {
|
||||
export interface LogSessionListQuery {
|
||||
keyword?: string
|
||||
start?: string // format datetime(YYYY-mm-dd HH:ii)
|
||||
end?: string // format datetime(YYYY-mm-dd HH:ii)
|
||||
|
@ -214,7 +212,7 @@ export type LogSessionListQuery = {
|
|||
limit: number // default 20. 1-100
|
||||
}
|
||||
|
||||
export type LogSessionListResponse = {
|
||||
export interface LogSessionListResponse {
|
||||
data: {
|
||||
id: string
|
||||
conversation_id: string
|
||||
|
@ -228,7 +226,7 @@ export type LogSessionListResponse = {
|
|||
}
|
||||
|
||||
// log session detail and debug
|
||||
export type LogSessionDetailResponse = {
|
||||
export interface LogSessionDetailResponse {
|
||||
id: string
|
||||
conversation_id: string
|
||||
model_provider: string
|
||||
|
@ -242,7 +240,7 @@ export type LogSessionDetailResponse = {
|
|||
from_source: 'api' | 'log'
|
||||
}
|
||||
|
||||
export type SavedMessage = {
|
||||
export interface SavedMessage {
|
||||
id: string
|
||||
answer: string
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@ import type { IOnCompleted, IOnData, IOnError, IOnFile, IOnMessageEnd, IOnMessag
|
|||
import type { ChatPromptConfig, CompletionPromptConfig } from '@/models/debug'
|
||||
import type { ModelModeType } from '@/types/app'
|
||||
import type { ModelParameterRule } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
||||
export type AutomaticRes = {
|
||||
export interface AutomaticRes {
|
||||
prompt: string
|
||||
variables: string[]
|
||||
opening_statement: string
|
||||
error?: string
|
||||
}
|
||||
export type CodeGenRes = {
|
||||
export interface CodeGenRes {
|
||||
code: string
|
||||
language: string[]
|
||||
error?: string
|
||||
|
@ -82,8 +82,8 @@ export const generateRuleCode = (body: Record<string, any>) => {
|
|||
})
|
||||
}
|
||||
|
||||
export const fetchModelParams = (pluginID: string, providerName: string, modelId: string) => {
|
||||
return get(`workspaces/current/model-providers/${pluginID}/${providerName}/models/parameter-rules`, {
|
||||
export const fetchModelParams = (providerName: string, modelId: string) => {
|
||||
return get(`workspaces/current/model-providers/${providerName}/models/parameter-rules`, {
|
||||
params: {
|
||||
model: modelId,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user