Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

5.5 KB
Raw Blame
import * as businessDefaults from '@lobechat/business-const';
import {
  DEFAULT_ASR_MODEL,
  DEFAULT_ASR_PROVIDER,
  DEFAULT_EMBEDDING_PROVIDER,
  DEFAULT_MINI_PROVIDER,
  DEFAULT_PROVIDER,
  DEFAULT_VERIFY_MODEL,
  DEFAULT_VERIFY_PROVIDER,
} from '@lobechat/business-const';
import type {
  PromptRewriteSystemAgent,
  ServiceModelTier,
  SystemAgentItem,
  UserServiceModelConfig,
  UserServiceModelConfigKey,
} from '@lobechat/types';

import { DEFAULT_FILE_EMBEDDING_MODEL_ITEM } from './knowledge';
import { DEFAULT_EMBEDDING_MODEL, DEFAULT_MINI_MODEL, DEFAULT_MODEL } from './llm';

export const DEFAULT_SYSTEM_AGENT_ITEM: SystemAgentItem = {
  model: DEFAULT_MODEL,
  provider: DEFAULT_PROVIDER,
};

export const DEFAULT_MINI_SYSTEM_AGENT_ITEM: SystemAgentItem = {
  model: DEFAULT_MINI_MODEL,
  provider: DEFAULT_MINI_PROVIDER,
};

export const DEFAULT_PROMPT_REWRITE_SYSTEM_AGENT_ITEM: PromptRewriteSystemAgent = {
  enabled: true,
  model: DEFAULT_MINI_SYSTEM_AGENT_ITEM.model,
  provider: DEFAULT_MINI_SYSTEM_AGENT_ITEM.provider,
};

export const DEFAULT_INPUT_COMPLETION_SYSTEM_AGENT_ITEM: SystemAgentItem = {
  enabled: false,
  model: DEFAULT_MINI_SYSTEM_AGENT_ITEM.model,
  provider: DEFAULT_MINI_SYSTEM_AGENT_ITEM.provider,
};

export const DEFAULT_FOLLOW_UP_ACTION_SYSTEM_AGENT_ITEM: SystemAgentItem = {
  enabled: false,
  model: DEFAULT_MINI_SYSTEM_AGENT_ITEM.model,
  provider: DEFAULT_MINI_SYSTEM_AGENT_ITEM.provider,
};

// Opt-in: summarizing runs unattended in the background and spends the user's
// own budget, so it stays off until they turn it on. Model/provider follow the
// branded defaults rather than a hardcoded pair, so the deployment's own
// gateway resolves the credentials instead of a per-provider server env key.
export const DEFAULT_TOPIC_AUTO_SUMMARY_SYSTEM_AGENT_ITEM: SystemAgentItem = {
  ...DEFAULT_SYSTEM_AGENT_ITEM,
  enabled: false,
};

// Speech-to-text is only usable where the provider implements transcription, so the default
// counts only once that provider is enabled (see the voice-message capability check).
// Deployments can repoint it with `SYSTEM_AGENT=asr=<provider>/<model>`.
export const DEFAULT_ASR_SYSTEM_AGENT_ITEM: SystemAgentItem = {
  model: DEFAULT_ASR_MODEL,
  provider: DEFAULT_ASR_PROVIDER,
};

export const DEFAULT_USER_MEMORY_EMBEDDING_SYSTEM_AGENT_ITEM: SystemAgentItem = {
  model: DEFAULT_EMBEDDING_MODEL,
  provider: DEFAULT_EMBEDDING_PROVIDER,
};

// Verification is the quality gate and reads screenshot evidence, so it has its
// own vision-capable tier instead of following 主模型 / Flash. Deployments can
// repoint it with `SYSTEM_AGENT=verify=<provider>/<model>`.
export const DEFAULT_VERIFY_SYSTEM_AGENT_ITEM: SystemAgentItem = {
  model: DEFAULT_VERIFY_MODEL,
  provider: DEFAULT_VERIFY_PROVIDER,
};

// Distribution overlays can deploy separately from the core. Read the new defaults
// optionally so an older overlay can still build with the self-hosted fallback.
const channelRoutingModel: unknown = Reflect.get(businessDefaults, 'DEFAULT_CHANNEL_ROUTING_MODEL');
const channelRoutingProvider: unknown = Reflect.get(
  businessDefaults,
  'DEFAULT_CHANNEL_ROUTING_PROVIDER',
);

export const DEFAULT_SYSTEM_AGENT_CONFIG: UserServiceModelConfig = {
  agentMeta: DEFAULT_SYSTEM_AGENT_ITEM,
  asr: DEFAULT_ASR_SYSTEM_AGENT_ITEM,
  channelRouting: {
    enabled: true,
    model: typeof channelRoutingModel === 'string' ? channelRoutingModel : 'jev-1.14.0',
    provider: typeof channelRoutingProvider === 'string' ? channelRoutingProvider : 'typesafe',
  },
  expertise: DEFAULT_SYSTEM_AGENT_ITEM,
  // The deployment default comes from `DEFAULT_FILES_CONFIG`, not `SYSTEM_AGENT`.
  fileEmbedding: DEFAULT_FILE_EMBEDDING_MODEL_ITEM,
  followUpAction: DEFAULT_FOLLOW_UP_ACTION_SYSTEM_AGENT_ITEM,
  generationTopic: DEFAULT_MINI_SYSTEM_AGENT_ITEM,
  goal: DEFAULT_SYSTEM_AGENT_ITEM,
  inputCompletion: DEFAULT_INPUT_COMPLETION_SYSTEM_AGENT_ITEM,
  memoryAnalysisAgentConfig: DEFAULT_MINI_SYSTEM_AGENT_ITEM,
  onboardingTaskRecommender: DEFAULT_MINI_SYSTEM_AGENT_ITEM,
  onboardingUnderstanding: DEFAULT_MINI_SYSTEM_AGENT_ITEM,
  userMemoryEmbedding: DEFAULT_USER_MEMORY_EMBEDDING_SYSTEM_AGENT_ITEM,
  userMemoryPersonaWriter: DEFAULT_MINI_SYSTEM_AGENT_ITEM,
  promptRewrite: DEFAULT_PROMPT_REWRITE_SYSTEM_AGENT_ITEM,
  thread: DEFAULT_MINI_SYSTEM_AGENT_ITEM,
  topic: DEFAULT_MINI_SYSTEM_AGENT_ITEM,
  topicAutoSummary: DEFAULT_TOPIC_AUTO_SUMMARY_SYSTEM_AGENT_ITEM,
  translation: DEFAULT_MINI_SYSTEM_AGENT_ITEM,
  verify: DEFAULT_VERIFY_SYSTEM_AGENT_ITEM,
};

/**
 * Which top-level Service Model tier each task slot follows. A slot's default
 * above is its tier's default, so a slot that follows an unset tier runs the
 * same system-recommended model the tier shows. The first slot of a tier
 * stands for the tier's own recommendation. Slots left out (`asr`,
 * `channelRouting`, `fileEmbedding`, onboarding) keep their own system default and
 * ignore tier changes. `fileEmbedding` must stay out: following a tier would move
 * file indexing to a new model and strand the vectors of files already embedded.
 */
export const SERVICE_MODEL_TIER_SLOTS: Record<ServiceModelTier, UserServiceModelConfigKey[]> = {
  embedding: ['userMemoryEmbedding'],
  flash: [
    'topic',
    'thread',
    'generationTopic',
    'translation',
    'promptRewrite',
    'memoryAnalysisAgentConfig',
    'userMemoryPersonaWriter',
    'inputCompletion',
    'followUpAction',
  ],
  main: ['agentMeta', 'expertise', 'goal', 'topicAutoSummary'],
  // Must stay vision-capable: the picker for this tier lists only vision models.
  verify: ['verify'],
};