-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add Anthropic Compatible provider support #7654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Introduces a new 'anthropic-compatible' provider with schema, API handler, and UI components for custom Anthropic-compatible endpoints. Updates provider selection, model handling, and settings to support custom base URLs, auth tokens, and model configuration.
webview-ui/src/components/settings/providers/AnthropicCompatible.tsx
Outdated
Show resolved
Hide resolved
| <Button | ||
| variant="secondary" | ||
| onClick={() => setApiConfigurationField("anthropicCustomModelInfo", openAiModelInfoSaneDefaults)}> | ||
| Reset to Defaults |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace the hardcoded 'Reset to Defaults' button text with a translation key to support internationalization.
| Reset to Defaults | |
| t("settings:providers.resetToDefaults") |
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! I've reviewed the changes and found several issues that need attention before this can be merged.
Critical Issues
-
Missing GitHub Issue Link - The PR template requires linking to an approved GitHub issue, but the "Closes: #" field is empty. This violates the contribution guidelines.
-
Incomplete PR Template - Several required sections are not filled out (Description, Test Procedure, Pre-Submission Checklist, etc.)
-
Missing Tests - No test files found for the new AnthropicCompatibleHandler class or UI component. This significant feature needs test coverage.
-
Custom Model Info Not Used - The handler doesn't use the custom model info that users configure in the UI (line 244 in anthropic-compatible.ts).
| import type { SingleCompletionHandler, ApiHandlerCreateMessageMetadata } from "../index" | ||
| import { calculateApiCostAnthropic } from "../../shared/cost" | ||
|
|
||
| export class AnthropicCompatibleHandler extends BaseProvider implements SingleCompletionHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This handler appears to be nearly identical to the AnthropicHandler (99% duplicate code). Could we refactor this to extend AnthropicHandler and only override the getModel() method to handle custom model info?
| getModel() { | ||
| const modelId = this.options.apiModelId | ||
| let id = modelId && modelId in anthropicModels ? (modelId as AnthropicModelId) : anthropicDefaultModelId | ||
| let info: ModelInfo = anthropicModels[id] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The custom model info (anthropicCustomModelInfo) that users can configure in the UI is not being used here. The handler always falls back to predefined anthropicModels instead of using the custom settings. Should this use: this.options.anthropicCustomModelInfo || anthropicModels[id]?
|
|
||
| <div className="flex flex-col gap-3"> | ||
| <div className="text-sm text-vscode-descriptionForeground whitespace-pre-line"> | ||
| Custom Model Configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These UI labels should use the translation system for internationalization. Consider using t('settings:providers.customModelConfiguration') instead of hardcoded English text.
| onInput={handleInputChange("apiModelId")} | ||
| placeholder="claude-3-5-sonnet-20241022" | ||
| className="w-full"> | ||
| <label className="block font-medium mb-1">Model Name</label> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing i18n: Should use translation key instead of hardcoded "Model Name"
| })} | ||
| placeholder="200000" | ||
| className="w-full"> | ||
| <label className="block font-medium mb-1">Context Window Size</label> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing i18n: Should use translation key instead of hardcoded "Context Window Size"
| })} | ||
| placeholder="8192" | ||
| className="w-full"> | ||
| <label className="block font-medium mb-1">Max Output Tokens</label> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing i18n: Should use translation key instead of hardcoded "Max Output Tokens"
| )} | ||
|
|
||
| {selectedProviderModels.length > 0 && ( | ||
| {selectedProviderModels.length > 0 && selectedProvider !== "anthropic-compatible" && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is hiding the model dropdown intentional for anthropic-compatible? Users might want to select from known models before customizing. Consider showing the dropdown but making it optional, or adding a comment explaining why it's hidden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The model dropdown is intentionally hidden for anthropic-compatible since it's meant to be a generic provider where users type custom model names.
…le.tsx Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
|
@daniel-lxs talk to me about this plz |
daniel-lxs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this contribution! I've left some inline comments for your consideration.
| getModel() { | ||
| const modelId = this.options.apiModelId | ||
| let id = modelId && modelId in anthropicModels ? (modelId as AnthropicModelId) : anthropicDefaultModelId | ||
| let info: ModelInfo = anthropicModels[id] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed the custom model info from the UI isn't being used here. Was this intentional, or should it be checking for custom settings first?
| let info: ModelInfo = anthropicModels[id] | |
| let info: ModelInfo = this.options.anthropicCustomModelInfo || anthropicModels[id] |
This would allow the custom context window and capabilities configured in the UI to take effect.
| )} | ||
|
|
||
| {selectedProviderModels.length > 0 && ( | ||
| {selectedProviderModels.length > 0 && selectedProvider !== "anthropic-compatible" && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered adding model fetching from the custom endpoint? It could make the experience smoother by letting users select from a dropdown instead of typing model IDs. Something like:
else if (selectedProvider === "anthropic-compatible" && apiConfiguration?.anthropicBaseUrl) {
vscode.postMessage({
type: "requestAnthropicCompatibleModels",
values: {
baseUrl: apiConfiguration.anthropicBaseUrl,
apiKey: apiConfiguration.apiKey
}
})
}Though I understand if the manual entry is by design for flexibility with different endpoints.
|
Stale, please make new PR of still interested. |
Introduces a new 'anthropic-compatible' provider with schema, API handler, and UI components for custom Anthropic-compatible endpoints. Updates provider selection, model handling, and settings to support custom base URLs, auth tokens, and model configuration.
Related GitHub Issue
Closes: #
Roo Code Task Context (Optional)
Description
Test Procedure
Pre-Submission Checklist
Screenshots / Videos
Documentation Updates
Additional Notes
Get in Touch
Important
Adds
anthropic-compatibleprovider with schema, API handler, and UI components for custom Anthropic-compatible endpoints.anthropic-compatibleprovider toprovider-settings.tsandproviders/anthropic.ts.AnthropicCompatibleHandlerinanthropic-compatible.tsfor handling API requests with custom base URLs and auth tokens.buildApiHandler()inindex.tsto supportanthropic-compatible.AnthropicCompatiblecomponent inAnthropicCompatible.tsxfor UI settings.ApiOptions.tsxto includeanthropic-compatiblein provider selection.constants.tsandproviders/index.tsto registeranthropic-compatible.useSelectedModel.tsto handle model selection foranthropic-compatible.anthropic-compatibleinsettings.json.This description was created by
for 4173863. You can customize this summary. It will automatically update as commits are pushed.