Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/workers/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
6 changes: 6 additions & 0 deletions libs/ai/src/providers/openai-compatible.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}),
Expand Down
2 changes: 1 addition & 1 deletion libs/ai/src/providers/openai-compatible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down