Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

905 B
Raw Blame
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)))
  )
}