Skip to content

add feat. kluster_ai #1082

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 10 commits into from
Jun 11, 2025
Merged

add feat. kluster_ai #1082

merged 10 commits into from
Jun 11, 2025

Conversation

Ajay-Satish-01
Copy link
Contributor

Description

Added Kluster AI integration

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

Related Issues

#1069

Copy link

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter <ask-question>: Chat with your PR with Matter AI Agent
  • /matter remember <recommendation>: Generate AI memories for the PR

Copy link

Code Quality new feature

Summary By MatterAI MatterAI logo

🔄 What Changed

This PR adds support for a new provider called Kluster AI to the system. The implementation includes API configuration, chat completion, embedding, and file upload functionality. The provider is registered in the global constants and added to the list of valid providers.

🔍 Impact of the Change

This change extends the system's capabilities by integrating with Kluster AI's API, allowing users to use Kluster AI models for chat completions and embeddings. The implementation follows the same pattern as other providers in the system, making it consistent with the existing architecture.

📁 Total Files Changed

  • Added 5 new files for Kluster AI implementation:
    • src/providers/kluster-ai/api.ts (API configuration)
    • src/providers/kluster-ai/chatComplete.ts (Chat completion functionality)
    • src/providers/kluster-ai/embed.ts (Embedding functionality)
    • src/providers/kluster-ai/index.ts (Provider configuration)
    • src/providers/kluster-ai/uploadFile.ts (File upload functionality)
  • Modified 1 existing file:
    • src/globals.ts (Added Kluster AI to constants and valid providers)

🧪 Test Added

N/A - No tests were included in this PR.

🔒Security Vulnerabilities

N/A - No security vulnerabilities were identified in the implementation.

Motivation

To expand the platform's capabilities by integrating with Kluster AI's services, providing users with more model options for chat completions and embeddings.

Type of Change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Unit Tests
  • Integration Tests
  • Manual Testing

Screenshots (if applicable)

N/A

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Related Issues

N/A

Sequence Diagram

sequenceDiagram
    participant Client
    participant Provider
    participant KlusterAIConfig
    participant KlusterAIAPIConfig
    participant KlusterAIChatComplete
    participant KlusterAIEmbed
    participant KlusterAIUploadFile
    participant KlusterAI_API

    Client->>Provider: Request with provider=KLUSTER_AI
    Provider->>KlusterAIConfig: Load provider configuration
    KlusterAIConfig->>KlusterAIAPIConfig: Get API configuration
    KlusterAIAPIConfig-->>KlusterAIConfig: Return baseURL, headers, endpoints
    
    alt chatComplete function
        Client->>KlusterAIChatComplete: Request chat completion
        KlusterAIChatComplete->>KlusterAI_API: POST /chat/completions
        Note over KlusterAIChatComplete,KlusterAI_API: Params: model, messages, temperature, etc.
        KlusterAI_API-->>KlusterAIChatComplete: Response
        KlusterAIChatComplete->>KlusterAIResponseTransform: Transform response
        KlusterAIResponseTransform-->>Client: Return formatted response
    else embed function
        Client->>KlusterAIEmbed: Request embeddings
        KlusterAIEmbed->>KlusterAI_API: POST /embeddings
        Note over KlusterAIEmbed,KlusterAI_API: Params: model, input
        KlusterAI_API-->>KlusterAIEmbed: Response
        KlusterAIEmbed->>KlusterAIEmbedResponseTransform: Transform response
        KlusterAIEmbedResponseTransform-->>Client: Return formatted response
    else uploadFile function
        Client->>KlusterAIUploadFile: Upload file
        KlusterAIUploadFile->>KlusterAIRequestTransform: Transform request
        KlusterAIRequestTransform->>KlusterAI_API: POST /files
        KlusterAI_API-->>KlusterAIUploadFile: Response
        KlusterAIUploadFile-->>Client: Return response
    end
Loading

@Ajay-Satish-01 Ajay-Satish-01 marked this pull request as ready for review May 8, 2025 18:29
@Ajay-Satish-01
Copy link
Contributor Author

@VisargD @vrushankportkey is it possible to review this PR?

Copy link

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter <ask-question>: Chat with your PR with Matter AI Agent
  • /matter remember <recommendation>: Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation

Copy link

Code Quality new feature

Summary By MatterAI MatterAI logo

🔄 What Changed

  • Added Kluster AI integration configuration
  • Implemented provider configuration for chat completion and embedding
  • Configured API settings and response/request transformers

🔍 Impact of the Change

  • Enables integration with Kluster AI's language model
  • Supports chat completion and embedding functionalities
  • Provides flexible configuration for AI service interactions

📁 Total Files Changed

  • 1 file added: src/providers/kluster-ai/index.ts

🧪 Test Added

  • No explicit tests added in this PR
  • Recommended to add unit tests for configuration validation

🔒 Security Vulnerabilities

  • No immediate security vulnerabilities detected
  • Recommended to add input validation for configuration parameters

Type of Change

  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my feature works
  • New and existing unit tests pass locally with my changes

Sequence Diagram

sequenceDiagram
participant KlusterAIConfig as Config
participant KlusterAIAPIConfig as API
participant ChatComplete as Chat
participant Embed as EmbedService

Config->>API: Configure API Settings
Config->>Chat: Configure ChatComplete Params
    Chat-->>Config: Set Model 'Meta-Llama-3.1-8B-Instruct-Turbo'
Config->>EmbedService: Configure Embedding
    EmbedService-->>Config: Set Model 'Meta-Llama-3.1-8B-Instruct-Turbo'

Note over Config: Configures Response & Request Transforms
Loading

Copy link

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter <ask-question>: Chat with your PR with Matter AI Agent
  • /matter remember <recommendation>: Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation

Copy link

Code Quality new feature

Summary By MatterAI MatterAI logo

🔄 What Changed

  • Added Kluster AI integration

🔍 Impact of the Change

  • Introduces new AI integration capabilities

📁 Total Files Changed

  • 0 files (No files changed reported)

🧪 Test Added

  • No tests reported

🔒 Security Vulnerabilities

  • No security vulnerabilities detected

Description

Kluster AI Integration Pull Request

Type of Change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Unit Tests
  • Integration Tests
  • Manual Testing

Checklist

  • Code follows project style guidelines
  • Self-review performed
  • Code commented
  • Documentation updated
  • No new warnings generated
  • Tests added
  • Unit tests pass locally

Sequence Diagram

sequenceDiagram
    participant Developer
    participant GitHub
    participant KlusterAI
    Developer->>GitHub: Create Pull Request
    GitHub->>KlusterAI: Trigger Integration
    KlusterAI-->>GitHub: Process Request
    GitHub-->>Developer: Update PR Status
Loading

@Ajay-Satish-01 Ajay-Satish-01 requested a review from VisargD May 14, 2025 19:26
@VisargD
Copy link
Collaborator

VisargD commented May 22, 2025

Hi @Ajay-Satish-01 , sorry for the delay. I have added few more comments. And can you please also resolve the merge conflicts?

Copy link

matter-code-review bot commented May 22, 2025

Code Quality new feature bug detected

Description

Summary By MatterAI MatterAI logo

🔄 What Changed

This pull request introduces the integration of Kluster AI as a new AI provider. Key changes include:

  • src/globals.ts: Added KLUSTER_AI constant and included it in VALID_PROVIDERS list.
  • src/providers/index.ts: Imported KlusterAIConfig and registered it within the main Providers object.
  • src/providers/kluster-ai/api.ts (New File): Defined KlusterAIAPIConfig to specify base URL (https://api.kluster.ai/v1), authentication headers (Bearer token), and endpoint mappings for chatComplete, embed, and uploadFile.
  • src/providers/kluster-ai/chatComplete.ts (New File): Implemented KlusterAIResponseTransform for chat completion responses, leveraging OpenAIErrorResponseTransform for error handling.
  • src/providers/kluster-ai/index.ts (New File): Configured KlusterAIConfig using open-ai-base utilities for chatComplete and embed parameters, linked KlusterAIAPIConfig, and defined responseTransforms and requestTransforms.
  • src/providers/kluster-ai/uploadFile.ts (New File): Provided KlusterAIRequestTransform which currently acts as a passthrough for file upload requests.

🔍 Impact of the Change

This change significantly expands the platform's capabilities by adding support for Kluster AI services, allowing applications to utilize Kluster AI for chat completions, embeddings, and file uploads. It follows the existing provider integration pattern, ensuring consistency. However, a critical bug exists where the uploadFile response transform is incorrectly assigned the KlusterAIResponseTransform (designed for chat completions), which could lead to incorrect processing of file upload API responses. The uploadFile request transform is also a simple passthrough, which might be incomplete depending on Kluster AI's specific file upload requirements.

📁 Total Files Changed

6 files changed.

🧪 Test Added

No explicit unit or integration tests were added in this pull request. The functionality would require manual verification.

🔒Security Vulnerabilities

No new security vulnerabilities were detected in the provided code changes. The API key handling uses a standard Bearer token approach, which is appropriate.

Motivation

Integration of Kluster AI as a new provider to expand supported AI services and offer more options to users.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

How Has This Been Tested?

  • Unit Tests
  • Integration Tests
  • Manual Testing (Inferred, as no automated tests are provided)

Screenshots (if applicable)

N/A

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Related Issues

.

Tip

Quality Recommendations

  1. The responseTransforms.uploadFile in src/providers/kluster-ai/index.ts is incorrectly assigned KlusterAIResponseTransform. This transform is specifically designed for chat completion responses and is likely not suitable for file upload responses. A dedicated response transform for file uploads should be implemented to correctly handle Kluster AI's file upload API responses, including success and error scenarios.

  2. Review the KlusterAIRequestTransform in src/providers/kluster-ai/uploadFile.ts. Currently, it's a simple passthrough. Confirm if this is the final intended behavior or if any specific request body transformations (e.g., multipart form data handling, metadata inclusion) are required for Kluster AI's file upload API. If transformations are needed, implement them.

  3. Add comprehensive unit and integration tests for the new Kluster AI provider. This should cover successful calls for chatComplete, embed, and uploadFile, as well as various error scenarios to ensure robust error handling and correct response transformations across all endpoints.

  4. Enhance the PR description with more details on the motivation, specific functionalities supported, and how the new provider integrates with existing systems. Add internal code comments for any non-obvious logic, especially concerning the uploadFile transforms.

Sequence Diagram

sequenceDiagram
    participant App as Application
    participant Globals as src/globals.ts
    participant ProvidersIndex as src/providers/index.ts
    participant KlusterAIConfig as src/providers/kluster-ai/index.ts
    participant KlusterAIAPI as src/providers/kluster-ai/api.ts
    participant KlusterAIChatTransform as src/providers/kluster-ai/chatComplete.ts
    participant KlusterAIUploadTransform as src/providers/kluster-ai/uploadFile.ts
    participant OpenAIUtils as src/providers/openai/utils.ts
    participant KlusterAIApiEndpoint as Kluster AI API (https://api.kluster.ai/v1)

    App->>ProvidersIndex: Request Kluster AI service (e.g., chatComplete, embed, uploadFile)
    ProvidersIndex-->>KlusterAIConfig: Provides KlusterAIConfig

    KlusterAIConfig->>KlusterAIAPI: Get API config (fn: chatComplete, embed, uploadFile)
    KlusterAIAPI-->>KlusterAIConfig: Returns base URL, headers (Authorization: Bearer apiKey), endpoint (/chat/completions, /embeddings, /files)

    alt For chatComplete or embed
        KlusterAIConfig->>KlusterAIApiEndpoint: HTTP Request (POST /chat/completions or /embeddings)
        KlusterAIApiEndpoint-->>KlusterAIConfig: API Response (ChatCompletionResponse | ErrorResponse)
        KlusterAIConfig->>KlusterAIChatTransform: Transform Response (response, responseStatus)
        KlusterAIChatTransform->>OpenAIUtils: Call OpenAIErrorResponseTransform (if error)
        OpenAIUtils-->>KlusterAIChatTransform: Transformed Error Response
        KlusterAIChatTransform-->>App: Returns ChatCompletionResponse | ErrorResponse
    end

    alt For uploadFile
        App->>KlusterAIUploadTransform: Prepare Request Body (requestBody: ReadableStream)
        KlusterAIUploadTransform-->>KlusterAIConfig: Returns transformed requestBody (currently passthrough)
        KlusterAIConfig->>KlusterAIApiEndpoint: HTTP Request (POST /files)
        KlusterAIApiEndpoint-->>KlusterAIConfig: API Response
        KlusterAIConfig->>KlusterAIChatTransform: Transform Response (response, responseStatus) - Note: This transform is designed for chat completions.
        KlusterAIChatTransform->>OpenAIUtils: Call OpenAIErrorResponseTransform (if error)
        OpenAIUtils-->>KlusterAIChatTransform: Transformed Error Response
        KlusterAIChatTransform-->>App: Returns Upload File Response | ErrorResponse
    end

    Globals->>KlusterAIConfig: Provides KLUSTER_AI constant
    KlusterAIConfig->>Globals: Adds KLUSTER_AI to VALID_PROVIDERS
Loading

Copy link

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

Copy link

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

Copy link

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

Copy link

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

Copy link

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@Ajay-Satish-01 Ajay-Satish-01 requested a review from VisargD May 31, 2025 05:17
Copy link

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@Ajay-Satish-01
Copy link
Contributor Author

@VisargD Please review this PR when you get time :)

Copy link

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@VisargD VisargD merged commit 29d25fb into Portkey-AI:main Jun 11, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants