Skip to content

feat: sglang provider added#164

Merged
akshaydeo merged 1 commit into07-16-feat_groq_provider_addedfrom
07-16-feat_sglang_provider_added
Jul 16, 2025
Merged

feat: sglang provider added#164
akshaydeo merged 1 commit into07-16-feat_groq_provider_addedfrom
07-16-feat_sglang_provider_added

Conversation

@Pratham-Mishra04
Copy link
Copy Markdown
Collaborator

No description provided.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 16, 2025

Summary by CodeRabbit

  • New Features

    • Added support for the SGLang (SGL) AI provider, including synchronous and streaming chat completion capabilities.
    • SGL provider can be configured without an API key and requires a base URL.
  • Bug Fixes

    • Updated validation and configuration logic to properly handle SGL as a keyless provider in both backend and UI.
  • Documentation

    • Updated provider documentation and UI guides to include SGLang as a supported provider.
  • Tests

    • Introduced comprehensive automated tests for SGL provider integration.
  • Style

    • Minor formatting and whitespace adjustments in static HTML and documentation files.
  • Chores

    • Updated internal constants and types to recognize SGL as a provider.

Summary by CodeRabbit

  • New Features

    • Added support for the SGLang (SGL) AI provider, including chat completion and streaming chat capabilities.
    • SGLang provider can be configured without an API key and requires a base URL.
    • SGLang is now available for selection and management in the UI dashboard and configuration forms.
  • Documentation

    • Updated documentation to list SGLang as a supported provider.
  • Tests

    • Introduced comprehensive automated tests for the SGLang provider integration.
  • Style/Chores

    • Minor updates to static asset references, internal identifiers, and formatting for consistency.

Walkthrough

This change introduces support for the "SGLang" (SGL) AI provider throughout the codebase, including core logic, provider implementation, configuration, validation, documentation, and UI. It adds the SGL provider integration, updates provider handling logic, and incorporates SGL into testing, documentation, and user interface components.

Changes

Files/Paths Change Summary
core/providers/sgl.go New SGL provider implementation with chat and streaming support; error on unsupported operations.
core/bifrost.go, core/schemas/bifrost.go, core/utils.go Add SGL provider key; update provider creation and key requirements logic.
transports/bifrost-http/handlers/providers.go Allow SGL as a provider that does not require API keys in add/update logic.
docs/usage/providers.md, transports/README.md, ui/README.md Add SGLang to supported provider documentation.
tests/core-providers/config/account.go, tests/core-providers/sgl_test.go Add SGL to test provider list and create comprehensive SGL test configuration and test case.
ui/components/config/provider-form.tsx, ui/lib/constants/logs.ts Add SGL to provider selection, labels, and initial state logic; require base URL for SGL.
ui/lib/types/config.ts Add 'sgl' and 'groq' to ModelProvider type.
transports/bifrost-http/ui/_next/static/chunks/app/providers/page-*.js Replace provider management UI module with updated version supporting SGL.
transports/bifrost-http/ui/providers/index.html, index.txt Update chunk references and highlight Providers menu as active.
transports/bifrost-http/ui/index.html, index.txt Update JS chunk references.
transports/bifrost-http/ui/config/index.html, index.txt Whitespace and serialization updates only.
transports/bifrost-http/ui/docs/index.txt, plugins/index.txt Serialization or identifier updates; no content changes.
transports/bifrost-http/ui/mcp-clients/index.html, index.txt Whitespace and identifier updates only.
transports/bifrost-http/ui/404.html, 404/index.html Whitespace-only changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant Bifrost Core
    participant SGLProvider
    participant SGL API

    User->>UI: Selects SGL as provider and configures it
    UI->>Bifrost Core: Sends provider config (with/without API key, base URL)
    Bifrost Core->>SGLProvider: Initializes SGLProvider with config
    User->>UI: Initiates chat completion
    UI->>Bifrost Core: Sends chat completion request (provider=SGL)
    Bifrost Core->>SGLProvider: Calls ChatCompletion method
    SGLProvider->>SGL API: Sends formatted request
    SGL API-->>SGLProvider: Returns response
    SGLProvider-->>Bifrost Core: Returns parsed response
    Bifrost Core-->>UI: Returns chat completion result
    UI-->>User: Displays chat completion
Loading

Suggested reviewers

  • danpiths
  • akshaydeo

Poem

In the garden of code where new features grow,
SGLang joins the party, with a bright, eager glow!
Now chat flows through SGL, both sync and in stream,
UI and docs updated, fulfilling the dream.
With tests and configs set,
This bunny’s not done yet—
Onward to more providers, with a hop and a beam! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 07-16-feat_sglang_provider_added

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Collaborator Author

Pratham-Mishra04 commented Jul 16, 2025

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🔭 Outside diff range comments (3)
core/schemas/bifrost.go (1)

39-50: Minor ordering nit

The enum is roughly alphabetical; inserting SGL after Groq breaks that pattern. Consider keeping the sequence sorted for readability.

transports/bifrost-http/ui/404.html (1)

118-122: Whitespace-only change to a generated/minified file adds pointless churn

This newline tweak doesn’t affect rendering, yet it bloats the diff for a 900-line minified artifact. Whenever possible, keep build artifacts out of version control or run a formatter that strips trailing-whitespace deltas before commit.

transports/bifrost-http/ui/404/index.html (1)

118-122: Same no-op whitespace diff as sibling file

Identical observation: the change is noise only. Consider excluding these compiled/static assets or normalising them in CI to avoid needless diffs.

Comment thread ui/README.md
Comment thread transports/README.md
Comment thread docs/usage/providers.md
Comment thread core/utils.go
Comment thread core/providers/sgl.go Outdated
@Pratham-Mishra04 Pratham-Mishra04 force-pushed the 07-16-feat_sglang_provider_added branch from 0f92c4e to 2ab6aae Compare July 16, 2025 15:13
@Pratham-Mishra04 Pratham-Mishra04 marked this pull request as ready for review July 16, 2025 15:14
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🔭 Outside diff range comments (3)
transports/bifrost-http/ui/mcp-clients/index.html (1)

1-122: Consider dropping generated UI build artifacts from VCS

This file looks like a minified/serialized Next .js build output. Committing such artefacts clutters the diff, makes code-review noise (e.g. this change is just an extra newline) and often causes merge conflicts. Prefer generating them in CI/CD or as part of your release pipeline instead of tracking them in Git.

transports/bifrost-http/ui/_next/static/chunks/app/providers/page-b25fa0ce16423da1.js (2)

1-30: Remove redundant "use strict" wrapper & avoid this inside static helpers

Biome flags two real issues at the very top of the bundle:

  1. "use strict" is injected although ES-modules are strict by default.
  2. this.pattern is referenced inside other static methods of class Dr; in a static context this equals the class, but it’s clearer and less error-prone to call the method via the class name itself (Dr.pattern).
- "use strict";
+ /* eslint-disable */ // generated bundle – strict mode already implied

static email(e,msg="Must be a valid email"){
-   return this.pattern(e, /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i, msg)
+   return Dr.pattern(e, /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i, msg)
}

Net effect: smaller bundle, removes minor visual debt, and future-proofs the helpers if they’re ever copy-pasted outside the class.


24-26: Edge-case: arrayUnique() silently breaks on non-arrays

arrayUnique does new Set(e) unconditionally; when e is null/undefined the constructor still returns an empty set, but you also compare against e.length which is undefined, yielding false and an error message that may confuse users (“Must have unique items” even though the field is empty).

Consider short-circuiting to true when the value is falsy:

static arrayUnique(arr,msg="Must have unique items"){
-  return {isValid:(arr?.length)===new Set(arr).size, message:msg}
+  if (!arr || arr.length===0) return {isValid:true, message:msg};
+  return {isValid:arr.length===new Set(arr).size, message:msg};
}
♻️ Duplicate comments (5)
ui/README.md (1)

93-93: Maintain alphabetical order in provider list

For consistency with other docs and quicker scanning, keep provider names sorted alphabetically.

- **Supported Providers**: OpenAI, Azure OpenAI, Anthropic, AWS Bedrock, Cohere, Google Vertex AI, Mistral, Ollama, Groq, SGLang
+ **Supported Providers**: Anthropic, AWS Bedrock, Azure OpenAI, Cohere, Google Vertex AI, Groq, Mistral, Ollama, OpenAI, SGLang
transports/README.md (1)

56-56: Alphabetise provider names in feature table

The list is now out of order; re-ordering improves readability and matches other docs.

-| **🔄 Multi-Provider Support** | OpenAI, Anthropic, Azure, Bedrock, Vertex, Cohere, Mistral, Ollama, Groq, SGLang |
+| **🔄 Multi-Provider Support** | Anthropic, Azure, Bedrock, Cohere, Groq, Mistral, Ollama, OpenAI, SGLang, Vertex |
docs/usage/providers.md (1)

17-18: Keep table rows in alphabetical order

Same nit as before – move “SGLang” after “Ollama” and before “Vertex”, and tidy the column spacing.

-| **Groq**           | Mixtral, Llama, Gemma                  | Enterprise AI platform              | ✅         |
-| **SGLang**         | Qwen                 | Enterprise AI platform              | ✅         |
+| **Groq**           | Mixtral, Llama, Gemma                  | Enterprise AI platform              | ✅         |
+| **SGLang**         | Qwen                                   | Enterprise AI platform              | ✅         |
core/utils.go (1)

15-15: Update comment to reflect SGL provider.

The function logic correctly adds schemas.SGL as a keyless provider, but the comment should be updated to mention SGL alongside Vertex and Ollama.

Apply this diff to update the comment:

-// Some providers like Vertex and Ollama are keyless and don't require API keys.
+// Some providers like Vertex, Ollama, and SGL are keyless and don't require API keys.
core/providers/sgl.go (1)

85-88: Fix the incorrect comment referencing "Ollama".

The comment should reference "SGL" instead of "Ollama".

-	// BaseURL is required for Ollama
+	// BaseURL is required for SGL
 	if config.NetworkConfig.BaseURL == "" {
 		return nil, fmt.Errorf("base_url is required for sgl provider")
 	}

Comment thread transports/bifrost-http/ui/mcp-clients/index.txt
Comment thread transports/bifrost-http/ui/config/index.txt
Comment thread ui/lib/types/config.ts
@Pratham-Mishra04 Pratham-Mishra04 force-pushed the 07-16-feat_sglang_provider_added branch from 2ab6aae to ebb8ad6 Compare July 16, 2025 15:24
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🔭 Outside diff range comments (1)
transports/bifrost-http/integrations/utils.go (1)

567-577: validProviders array forgot to include the newly-added schemas.SGL

ParseModelString relies on validProviders for prefix validation.
With the current map, model strings such as "sgl/my-model" will silently fall back to “no provider” and the request will be routed to the default (openai) provider – very hard to debug.

Add the missing entry:

 var validProviders = map[schemas.ModelProvider]bool{
     schemas.OpenAI:    true,
     schemas.Azure:     true,
     schemas.Anthropic: true,
     schemas.Bedrock:   true,
     schemas.Cohere:    true,
     schemas.Vertex:    true,
     schemas.Mistral:   true,
     schemas.Ollama:    true,
+    schemas.SGL:       true,
 }
♻️ Duplicate comments (10)
transports/bifrost-http/ui/mcp-clients/index.txt (1)

20-20: Generated bundle diff still clutters the PR

The change is just a new hydration key. Please exclude these serialized .txt bundle artifacts (or gate them behind a build flag) to keep diffs readable.

transports/bifrost-http/ui/docs/index.txt (1)

19-19: Generated bundle diff still clutters the PR

Same as earlier feedback: internal hydration-key churn adds no reviewable value. Consider removing these files from version control or generating them conditionally.

transports/README.md (1)

56-56: Provider list still not alphabetised

The provider list order is inconsistent with other docs (see previous review). Alphabetical ordering improves scan-ability.

ui/README.md (1)

93-93: Provider list still not alphabetised

Same nit as before – keeping the list alphabetical helps quick scanning.

docs/usage/providers.md (1)

17-18: Table alignment and alphabetical ordering issues persist

The SGLang entry should be placed alphabetically between Ollama and Vertex AI, and the table alignment inconsistency still needs to be addressed.

core/utils.go (1)

15-15: Consider updating the comment to reflect SGL provider inclusion.

The comment mentions "Some providers like Vertex and Ollama are keyless" but the function now also includes SGL. While this was noted in a previous review, the comment could be updated for accuracy.

transports/bifrost-http/handlers/providers.go (1)

253-255: Same duplication in UpdateProvider

See previous comment – the validation branch here should reuse the same helper.

ui/lib/types/config.ts (1)

4-4: Keep union members alphabetically sorted

'sgl' was appended at the very end; inserting it before 'vertex' keeps diffs tidier.

-export type ModelProvider = 'openai' | 'azure' | 'anthropic' | 'bedrock' | 'cohere' | 'vertex' | 'mistral' | 'ollama' | 'groq' | 'sgl'
+export type ModelProvider = 'openai' | 'azure' | 'anthropic' | 'bedrock' | 'cohere' | 'mistral' | 'ollama' | 'sgl' | 'vertex' | 'groq'
transports/bifrost-http/ui/providers/index.txt (1)

11-12: Generated bundle – recommend excluding from git

Only hashed file names changed; committing these bloats diffs.

transports/bifrost-http/ui/config/index.txt (1)

20-21: Generated bundle – recommend excluding from git

Same reasoning as above; no functional value in source control.

Comment thread transports/bifrost-http/ui/plugins/index.txt
Comment thread transports/bifrost-http/handlers/providers.go
Copy link
Copy Markdown
Contributor

akshaydeo commented Jul 16, 2025

Merge activity

@akshaydeo akshaydeo merged commit ccdc619 into 07-16-feat_groq_provider_added Jul 16, 2025
1 of 2 checks passed
@akshaydeo akshaydeo deleted the 07-16-feat_sglang_provider_added branch August 31, 2025 17:28
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