Skip to content

Conversation

@hiudyy
Copy link

@hiudyy hiudyy commented Oct 27, 2025

Add the AI provider Cognima, it"s a Brazilian provider, I used it in openai compatible but I think it would be interesting to have it natively.


Important

Adds support for Cognima AI provider, including handler, model fetching, and provider settings integration.

  • Behavior:
    • Adds CognimaHandler to handle Cognima API requests in index.ts and providers/cognima.ts.
    • Implements createMessage in CognimaHandler to convert messages and handle streaming responses.
    • Adds getCognimaModels in fetchers/cognima.ts to fetch models from Cognima API.
  • Provider Settings:
    • Adds cognima to dynamicProviders and providerNames in provider-settings.ts.
    • Defines cognimaSchema in provider-settings.ts for provider configuration.
    • Updates providerSettingsSchemaDiscriminated and providerSettingsSchema to include cognimaSchema.
  • Misc:
    • Adds cognimaApiKey to SECRET_STATE_KEYS in global-settings.ts.
    • Exports CognimaHandler in providers/index.ts and api/index.ts.
    • Updates MODELS_BY_PROVIDER in provider-settings.ts to include Cognima.

This description was created by Ellipsis for 5e5c5d5. You can customize this summary. It will automatically update as commits are pushed.

Add support for the Cognima AI provider, including API key handling, model fetching, and handler integration across the codebase.
@hiudyy hiudyy requested review from cte, jr and mrubens as code owners October 27, 2025 20:35
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Oct 27, 2025
@roomote
Copy link

roomote bot commented Oct 27, 2025

Review Summary

I've reviewed the Cognima provider implementation. The overall structure follows the established patterns for adding new providers, but there are a few issues that need to be addressed:

Issues Found

  • Add cognimaModelId property to the cognimaSchema in packages/types/src/provider-settings.ts
  • Remove unused parseApiPrice import from src/api/providers/fetchers/cognima.ts
  • Add missing newline at end of packages/types/src/providers/cognima.ts
  • Add Cognima model fetch logic to modelFetchPromises array in src/core/webview/webviewMessageHandler.ts
  • Fix formatting: add space after comma in test expectation on line 224 of src/core/webview/__tests__/webviewMessageHandler.spec.ts

Follow Along on Roo Code Cloud

name: "cognima",
baseURL: "https://cog2.cognima.com.br/openai/v1",
apiKey: options.cognimaApiKey,
modelId: options.cognimaModelId,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cognimaModelId property is referenced here but is not defined in the cognimaSchema in packages/types/src/provider-settings.ts. The schema only includes cognimaApiKey. You need to add cognimaModelId: z.string().optional() to the cognimaSchema (around line 358) to match the pattern used by other providers like Groq.


import type { ModelInfo } from "@roo-code/types"

import { parseApiPrice } from "../../../shared/cost"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import parseApiPrice is not used; please remove it to keep the code clean.

Suggested change
import { parseApiPrice } from "../../../shared/cost"


import type { ModelInfo } from "@roo-code/types"

import { parseApiPrice } from "../../../shared/cost"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parseApiPrice import is unused in this file and should be removed to keep the code clean.


export type CognimaModelId = string

export const cognimaDefaultModelId: CognimaModelId = "gpt-4o" No newline at end of file
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline at end of file. Add a newline after the last line to follow standard conventions.

Copy link

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. Found 3 issues that need to be addressed before approval. Please see the inline comments for details.

Add cognimaModelId to provider settings schema and implement model selection logic in the UI hook for the cognima provider. Remove unused import from cognima fetcher.
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Oct 27, 2025
Copy link

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two of the three issues have been resolved. One issue remains: the missing newline at the end of packages/types/src/providers/cognima.ts.

Add cognima as a new provider in the webview message handler initialization, extending support for additional model sources.
ollama: {},
lmstudio: {},
roo: {},
cognima: {},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cognima: {} entry initializes an empty model record, but there's no corresponding entry in the modelFetchPromises array (around lines 789-820) to actually fetch Cognima models from the API. Since Cognima is defined as a dynamic provider and has a getCognimaModels function in src/api/providers/fetchers/cognima.ts, you should add a fetch entry similar to other dynamic providers like glama or unbound. For example:

{
  key: "cognima",
  options: {
    provider: "cognima",
    apiKey: apiConfiguration.cognimaApiKey,
  },
}

Without this, users won't be able to see or select any Cognima models in the UI.

expect(mockGetModels).toHaveBeenCalledWith({ provider: "requesty", apiKey: "requesty-key" })
expect(mockGetModels).toHaveBeenCalledWith({ provider: "glama" })
expect(mockGetModels).toHaveBeenCalledWith({ provider: "unbound", apiKey: "unbound-key" })
expect(mockGetModels).toHaveBeenCalledWith({ provider: "unbound",apiKey: "unbound-key" })
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after comma. Should be { provider: "unbound", apiKey: "unbound-key" } for consistency with the rest of the codebase.

Suggested change
expect(mockGetModels).toHaveBeenCalledWith({ provider: "unbound",apiKey: "unbound-key" })
expect(mockGetModels).toHaveBeenCalledWith({ provider: "unbound", apiKey: "unbound-key" })

Copy link

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. There are still 2 minor issues to address before approval.

Copy link

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest commit adds proper test coverage for the Cognima provider. No new issues found in this update. There are still 2 minor issues remaining from the previous review that need to be addressed before approval.

@daniel-lxs
Copy link
Member

Thanks for the contribution!. We’re not planning to add new third-party providers at this time, as we’re focusing on maintaining the existing integrations. Closing this for now, but thank you again for the PR and for your interest in improving Roo Code.

@daniel-lxs daniel-lxs closed this Oct 29, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Oct 29, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants