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.

478 B
Raw Blame
export interface ModelIdMappingOptions {
  modelIdMapping?: Record<string, string>;
}

export const resolveMappedModelId = (model: string, options?: ModelIdMappingOptions) =>
  options?.modelIdMapping?.[model] ?? model;

export const withMappedModelId = <T extends { model: string }>(
  payload: T,
  options?: ModelIdMappingOptions,
): T => {
  const model = resolveMappedModelId(payload.model, options);

  return model === payload.model ? payload : { ...payload, model };
};