Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

1.2 KB
Raw Blame
import { AnthropicClient } from './clients/anthropic.client';
import { ConnectionReadClient } from './clients/connection-read.client';
import { OpenAiCompatibleClient } from './clients/openai-compatible.client';
import type { ResolvedLlmConfig } from './llm-config';
import type { LlmExtractionClient } from './llm-provider.interface';

/**
 * Pick the provider client for a resolved config.
 *  - 'anthropic'        → Anthropic Messages API client
 *  - 'openai' | 'local' → OpenAI-compatible client (cloud or local base URL)
 *  - 'chatgpt'          → the plan the AI connection lends, read through it
 */
export function createLlmClient(config: ResolvedLlmConfig): LlmExtractionClient {
  switch (config.provider) {
    case 'anthropic':
      return new AnthropicClient();
    case 'chatgpt':
      return new ConnectionReadClient(config.read);
    case 'openai':
    case 'local':
      return new OpenAiCompatibleClient();
    // TODO(nuextract): add a NuExtract template adapter here (local vision model
    // with its own template-fill API) once the OpenAI-compatible path proves
    // insufficient for small local models — see the design seam in the plan.
    default:
      return new OpenAiCompatibleClient();
  }
}