Files
gsfdc/demo-dify/dify/web/app/components/workflow/llm-environment-variable.ts
T
wuzilongandCursor 6519682885 chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-18 13:59:25 +08:00

24 lines
905 B
TypeScript

import type { LLMEnvironmentVariableValue } from '@/app/components/workflow/types'
const VALID_LLM_ENVIRONMENT_VARIABLE_MODES = new Set(['chat', 'completion'])
export function isLLMEnvironmentVariableValue(
value: unknown,
): value is LLMEnvironmentVariableValue {
if (typeof value !== 'object' || value === null) return false
const candidate = value as Partial<LLMEnvironmentVariableValue>
return (
typeof candidate.provider === 'string' &&
candidate.provider.trim().length > 0 &&
typeof candidate.name === 'string' &&
candidate.name.trim().length > 0 &&
typeof candidate.mode === 'string' &&
VALID_LLM_ENVIRONMENT_VARIABLE_MODES.has(candidate.mode) &&
(candidate.completion_params === undefined ||
(typeof candidate.completion_params === 'object' &&
candidate.completion_params !== null &&
!Array.isArray(candidate.completion_params)))
)
}