diff --git a/apps/workers/Dockerfile b/apps/workers/Dockerfile index 52c22f45..90126b6c 100644 --- a/apps/workers/Dockerfile +++ b/apps/workers/Dockerfile @@ -51,7 +51,7 @@ COPY libs/ai/ libs/ai/ RUN cd libs/ai && bunx tsc --project tsconfig.lib.json && \ mkdir -p /app/node_modules/@chatbot/ai && \ cp -rL /app/dist/libs/ai/libs/ai/src /app/node_modules/@chatbot/ai/src && \ - printf '{"name":"@chatbot/ai","version":"0.0.1","type":"module","main":"src/index.js","types":"src/index.d.ts"}\n' > /app/node_modules/@chatbot/ai/package.json + printf '{"name":"@chatbot/ai","version":"0.0.1","type":"module","main":"src/index.js","types":"src/index.d.ts","exports":{".":"./src/index.js","./*":"./src/*.js"}}\n' > /app/node_modules/@chatbot/ai/package.json COPY libs/knowledge-base/ libs/knowledge-base/ RUN cd libs/knowledge-base && bunx tsc --project tsconfig.lib.json && \ diff --git a/libs/ai/src/providers/openai-compatible.test.ts b/libs/ai/src/providers/openai-compatible.test.ts index 043deb77..bdae5bd9 100644 --- a/libs/ai/src/providers/openai-compatible.test.ts +++ b/libs/ai/src/providers/openai-compatible.test.ts @@ -3,6 +3,12 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'; const { mockCreateOpenAI, mockStreamText } = vi.hoisted(() => ({ mockCreateOpenAI: vi.fn(() => { const provider = (model: string) => ({ modelId: model, provider: 'openai-compatible' }); + // streamChat calls `this.client.chat(model)`, not the bare callable — the + // bare call routes to OpenAIResponsesModelId/`/v1/responses`, which most + // OpenAI-compatible gateways (Ollama, vLLM, LiteLLM, ...) never implement. + // `.chat()` routes to OpenAIChatModelId/`/v1/chat/completions`, which they + // all support. See openai-compatible.ts's streamChat for the full story. + provider.chat = (model: string) => ({ modelId: model, provider: 'openai-compatible' }); provider.textEmbeddingModel = (model: string) => ({ modelId: model, type: 'embedding' }); return provider; }), diff --git a/libs/ai/src/providers/openai-compatible.ts b/libs/ai/src/providers/openai-compatible.ts index 67a29fe9..fb5fe5d2 100644 --- a/libs/ai/src/providers/openai-compatible.ts +++ b/libs/ai/src/providers/openai-compatible.ts @@ -41,7 +41,7 @@ export class OpenAICompatibleProvider implements LLMProvider { onFinish, } = options; return streamText({ - model: this.client(model ?? this.chatModel), + model: this.client.chat(model ?? this.chatModel), messages, system, temperature,