Repository navigation
refactor(api)!: run ai bots on the vercel ai sdk with channel history - #21
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
openai.AI_MODEL(provider:model) chooses the model fromanthropic(defaultanthropic:claude-haiku-5-5),openaiorollama(OLLAMA_BASE_URL).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_KEYis no longer required, and without a key the bots stay off. To enable them, setAI_MODELand the provider's key (ANTHROPIC_API_KEYorOPENAI_API_KEY). Ollama needs no key.Verification
pnpm checkpasses.--runInBandand no AI keys.tests/ai-bots.spec.ts.anthropic:claude-haiku-5-5,openai:gpt-5-miniand 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