feat(expansion): OpenAI-compat JSON mode replaces Anthropic tool use#165
Closed
MichaelChristopher wants to merge 1 commit into
Closed
feat(expansion): OpenAI-compat JSON mode replaces Anthropic tool use#165MichaelChristopher wants to merge 1 commit into
MichaelChristopher wants to merge 1 commit into
Conversation
Swap @anthropic-ai/sdk for openai package so multi-query expansion can route through any OpenAI-compat provider. Default model changed from claude-haiku-4-5-20251001 to gemma4:latest (local Ollama) for long-term stability: no credential dependency, zero cost, offline-capable. JSON mode (response_format: json_object) is used instead of Anthropic tool use syntax for portability across providers. Existing try/catch fallback to [query] handles malformed responses gracefully. Env vars: - GBRAIN_EXPANSION_MODEL (default: gemma4:latest) - GBRAIN_EXPANSION_BASE_URL (falls back to OPENAI_BASE_URL) Local patch 0004/0004 for Phase B gbrain adoption. Co-Authored-By: Claude Opus 4.6 (1M context) <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.
Summary
Replaces the Anthropic SDK dependency in query expansion with the OpenAI-compatible SDK, enabling multi-provider routing through any OpenAI-compatible endpoint (OpenRouter, Ollama, llama.cpp, etc.).
Key Changes
openaipackage in expansion pipelineresponse_format: { type: "json_object" }) instead of Anthropic tool use syntaxGBRAIN_EXPANSION_MODEL,GBRAIN_EXPANSION_BASE_URL, and standard provider credential conventions[query]on malformed responsesMotivation
The hard dependency on the Anthropic SDK for query expansion limits gbrain to a single provider. This change enables:
Changes
src/core/search/expansion.ts: 62 insertions, 41 deletions