Repository navigation
Conversation
Owner
|
thanks @akrista for the PR. I'll take a closer look into it. |
This branch has not been deployed
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
Following the feedback on #19 (using OpenAI-compatible rather than adding a separate provider enum), we tested OpenCode (
opencode.ai) and OpenRouter (openrouter.ai) throughOpenAICompatibleProviderand hit four interoperability issues that prevented model listing, connection checks, and structured JSON extraction from succeeding.This PR keeps everything inside
OpenAICompatibleProviderwith no database or UI changes:normalizeBaseURL,isOpenCode,isOpenRouter):/inference/go(/openai/v1)?and/inference(/openai/v1)?to their/v1root (/inference/go/v1,/inference/v1), where bothGET /models(200 OK) andPOST /chat/completionsare served (GET .../openai/v1/modelsreturns404). AttachesUser-Agent: Dossier/<version>andx-opencode-session: ses_<uuid>, which OpenCode requires on/chat/completions(otherwise returning400 MissingSessionID).https://openrouter.aiandhttps://openrouter.ai/v1tohttps://openrouter.ai/api/v1so/v1suffixes don't hit OpenRouter's web 404 page.Authorization: Bearer not-neededheader whenapiKeyisnullso public model catalogs (like OpenCode's/v1/models) don't reject unauthenticated model-list requests with401 Invalid credential.SCHEMA_REFUSED,JSON_REFUSED):grammar is too large,parameters with union types,optional parameters,schema is too complex, as in Resume import fails with Anthropic: “compiled grammar is too large” #24 /AnthropicProvider) and remembers them per${baseURL} ${model} ${schemaName}inpromptSchemasso large schemas likeextract_profilefall back to prompt instructions while simpler schemas keep structured output.jsonRefusedto catch gateway parameter errors (400 Provider returned error,404/400 No endpoints found that support the provided parameters,invalid schema) soknown.jsonsteps down ("schema"→"object"→"prompt") instead of failing with a generic provider or unknown-model error.THINKING_TOKENS):reasoning_content,reasoning, thinking chunks, orreasoning_tokens > 0), remembersknown.thinks = trueand adds12,000tokens of headroom (matchingAnthropicProvider) so reasoning models on OpenCode and OpenRouter don't get cut off at4,096tokens mid-thought (finish_reason: "length"). If the first call is cut off while reasoning, it retries once with the added budget.Testing
yarn vitest run src/lib/ai/providers.test.ts src/lib/ai/structured-output.test.ts(74 tests pass)yarn typecheckyarn lint