-
Notifications
You must be signed in to change notification settings - Fork 0
Refine codebase learning #5
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Empty file.
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
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import { OpenAICompatibleEmbedder } from "./openai-compatible" | ||
| import { IEmbedder, EmbeddingResponse, EmbedderInfo } from "../interfaces/embedder" | ||
| import { GEMINI_MAX_ITEM_TOKENS, MAX_ITEM_TOKENS } from "../constants" | ||
| import { t } from "../../../i18n" | ||
| import { TelemetryEventName } from "@roo-code/types" | ||
| import { TelemetryService } from "@roo-code/telemetry" | ||
|
|
||
| /** | ||
| * MatterAI embedder implementation that wraps the OpenAI Compatible embedder | ||
| * with configuration for MatterAI's embedding API. | ||
| * | ||
| * Supported models: | ||
| * - matterai-embedding-large (dimension: 3072) | ||
| */ | ||
| export class MatterAiEmbedder implements IEmbedder { | ||
| private readonly openAICompatibleEmbedder: OpenAICompatibleEmbedder | ||
| private static readonly MATTERAI_BASE_URL = "https://api.matterai.so/v1/embed" | ||
| private static readonly DEFAULT_MODEL = "matterai-embedding-large" | ||
| private readonly modelId: string | ||
|
|
||
| /** | ||
| * Creates a new MatterAI embedder | ||
| * @param modelId The model ID to use (defaults to matterai-embedding-large) | ||
| */ | ||
| constructor(apiKey: string, modelId?: string) { | ||
| // Use provided model or default | ||
| this.modelId = modelId || MatterAiEmbedder.DEFAULT_MODEL | ||
|
|
||
| // Create an OpenAI Compatible embedder with MatterAI's configuration | ||
| this.openAICompatibleEmbedder = new OpenAICompatibleEmbedder( | ||
| MatterAiEmbedder.MATTERAI_BASE_URL, | ||
| apiKey, | ||
| this.modelId, | ||
| 2048, | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * Creates embeddings for the given texts using Gemini's embedding API | ||
| * @param texts Array of text strings to embed | ||
| * @param model Optional model identifier (uses constructor model if not provided) | ||
| * @returns Promise resolving to embedding response | ||
| */ | ||
| async createEmbeddings(texts: string[], model?: string): Promise<EmbeddingResponse> { | ||
| try { | ||
| // Use the provided model or fall back to the instance's model | ||
| const modelToUse = model || this.modelId | ||
| return await this.openAICompatibleEmbedder.createEmbeddings(texts, modelToUse) | ||
| } catch (error) { | ||
| TelemetryService.instance.captureEvent(TelemetryEventName.CODE_INDEX_ERROR, { | ||
| error: error instanceof Error ? error.message : String(error), | ||
| stack: error instanceof Error ? error.stack : undefined, | ||
| location: "MatterAiEmbedder:createEmbeddings", | ||
| }) | ||
| console.error("MatterAI embedder error in createEmbeddings:", error) // kilocode_change | ||
| throw error | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Validates the MatterAI embedder configuration by delegating to the underlying OpenAI-compatible embedder | ||
| * @returns Promise resolving to validation result with success status and optional error message | ||
| */ | ||
| async validateConfiguration(): Promise<{ valid: boolean; error?: string }> { | ||
| try { | ||
| // Delegate validation to the OpenAI-compatible embedder | ||
| // The error messages will be specific to MatterAI since we're using MatterAI's base URL | ||
| return await this.openAICompatibleEmbedder.validateConfiguration() | ||
| } catch (error) { | ||
| TelemetryService.instance.captureEvent(TelemetryEventName.CODE_INDEX_ERROR, { | ||
| error: error instanceof Error ? error.message : String(error), | ||
| stack: error instanceof Error ? error.stack : undefined, | ||
| location: "MatterAiEmbedder:validateConfiguration", | ||
| }) | ||
| console.error("MatterAI embedder error in validateConfiguration:", error) // kilocode_change | ||
| throw error | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Returns information about this embedder | ||
| */ | ||
| get embedderInfo(): EmbedderInfo { | ||
| return { | ||
| name: "matterai", | ||
| } | ||
| } | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
🔴 Security
Issue: The API key defaults to "not-provided" when
openRouterApiKeyis undefined, which could lead to runtime failures or expose development configuration in production.Fix: Add proper validation to ensure the API key is provided before client initialization, or throw a clear error if missing.
Impact: Prevents runtime errors and ensures proper configuration validation
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.
/matter remember this is by design
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.
Got it — Updated memory for
OpenRouter API Key Validation Design Decision📖