Skip to content

refactor(api)!: run ai bots on the vercel ai sdk with channel history - #21

Merged
Datzu712 merged 8 commits into
mainfrom
refactor/ai-module-vercel-sdk
Nov 17, 2026
Merged

Datzu712 merged 8 commits into
mainfrom
refactor/ai-module-vercel-sdk

Conversation

@Datzu712

@Datzu712 Datzu712 commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

What

  • AI bots run on the Vercel AI SDK instead of openai. AI_MODEL (provider:model) chooses the model from anthropic (default anthropic:claude-haiku-5-5), openai or ollama (OLLAMA_BASE_URL).
  • Bots read the last 30 channel messages before replying, so they keep the conversation context.
  • Bots are defined as data (bots.ts), and one service makes the call. Triggers use word boundaries, and each call has a timeout and retries. Replies are capped at 2000 characters.

Why

The bots only worked with OpenAI's retired gpt-3.5-turbo, and they had no conversation context.

Breaking change

OPENAI_API_KEY is no longer required, and without a key the bots stay off. To enable them, set AI_MODEL and the provider's key (ANTHROPIC_API_KEY or OPENAI_API_KEY). Ollama needs no key.

Verification

  • pnpm check passes.
  • The api suite passes 57/57 with --runInBand and no AI keys.
  • New unit tests in tests/ai-bots.spec.ts.
  • Tested end to end against anthropic:claude-haiku-5-5, openai:gpt-5-mini and a local Ollama (llama3.2:1b). Each bot answered with context from earlier messages, and a follow-up worked with its own earlier reply in the history.

🤖 Generated with Claude Code

Datzu712 and others added 7 commits November 16, 2026 15:56
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The bots no longer depend on OpenAI: the model comes from AI_MODEL
(provider:model, default anthropic:claude-haiku-5-5) through an AI SDK
provider registry with Anthropic and OpenAI. Each reply now reads the
last 30 channel messages, so the bots keep the conversation context.

BREAKING CHANGE: OPENAI_API_KEY is no longer required. Set AI_MODEL and
the provider key (ANTHROPIC_API_KEY or OPENAI_API_KEY); without the key
the bots stay off and the api still boots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop the bot's own messages at the edges of the history window (Anthropic
needs a leading user turn and rejects assistant prefill), disable thinking
so it does not consume the 500-token reply budget, warn on empty or
truncated replies, and route AI SDK warnings through the Nest logger.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AI_MODEL=ollama:<model> talks to Ollama through its OpenAI-compatible API
(@ai-sdk/openai-compatible) at OLLAMA_BASE_URL, default
http://localhost:11434/v1. It needs no key, so the bots are on whenever it
is selected. The demo compose reaches an Ollama on the host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Datzu712
Datzu712 merged commit c53b4ac into main Nov 17, 2026
5 checks passed
@Datzu712
Datzu712 deleted the refactor/ai-module-vercel-sdk branch November 17, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant