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.6 KB
Raw Blame
import { AnthropicClient } from '../../../../src/nest/llm-parse/clients/anthropic.client';
import { ConnectionReadClient } from '../../../../src/nest/llm-parse/clients/connection-read.client';
import { OpenAiCompatibleClient } from '../../../../src/nest/llm-parse/clients/openai-compatible.client';
import { createLlmClient } from '../../../../src/nest/llm-parse/llm-client.factory';
import type { ResolvedLlmConfig } from '../../../../src/nest/llm-parse/llm-config';

import { describe, it, expect } from 'vitest';

const cfg = (provider: string): ResolvedLlmConfig =>
  ({ provider, model: 'm', baseUrl: 'http://x', multimodal: false }) as unknown as ResolvedLlmConfig;

describe('createLlmClient', () => {
  it('returns the Anthropic client for the anthropic provider', () => {
    expect(createLlmClient(cfg('anthropic'))).toBeInstanceOf(AnthropicClient);
  });

  it('returns the OpenAI-compatible client for openai and local', () => {
    expect(createLlmClient(cfg('openai'))).toBeInstanceOf(OpenAiCompatibleClient);
    expect(createLlmClient(cfg('local'))).toBeInstanceOf(OpenAiCompatibleClient);
  });

  it('reads a ChatGPT plan through the reader its connection lends', () => {
    const plan: ResolvedLlmConfig = {
      provider: 'chatgpt',
      model: 'gpt-x',
      vision: 'auto',
      read: async () => ({ text: '' }),
    };
    expect(createLlmClient(plan)).toBeInstanceOf(ConnectionReadClient);
  });

  it('falls back to the OpenAI-compatible client for an unknown provider', () => {
    expect(createLlmClient(cfg('something-else'))).toBeInstanceOf(OpenAiCompatibleClient);
  });
});