feat: add Forge as LLM provider for ACE-Step-1.5#944
feat: add Forge as LLM provider for ACE-Step-1.5#944Yiiii0 wants to merge 1 commit intoace-step:mainfrom
Conversation
## Changes - Add Forge as LLM provider for ACE-Step-1.5 Files modified: .env.example acestep/text_tasks/external_ai_request_helpers.py acestep/text_tasks/external_ai_request_helpers_test.py acestep/text_tasks/external_lm_providers.py acestep/text_tasks/external_lm_providers_test.py
📝 WalkthroughWalkthroughThe changes add support for a new Forge external language model provider. Configuration entries are added to Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
acestep/text_tasks/external_lm_providers.py (1)
56-69: Consider aligning env var naming convention with other providers.The Forge profile uses
FORGE_API_KEYfor the API key env var, while other providers use theACESTEP_prefix (e.g.,ACESTEP_OPENAI_API_KEY,ACESTEP_GLM_API_KEY). Interestingly,secret_path_envdoes use the prefix (ACESTEP_FORGE_SECRET_PATH).This inconsistency may be intentional (perhaps to match Forge's own documentation), but consider standardizing to
ACESTEP_FORGE_API_KEYfor internal consistency, or documenting why Forge uses a different convention.🔧 Optional: Standardize env var naming
"forge": ExternalProviderProfile( provider_id="forge", label="Forge", protocol="openai_chat", default_model="OpenAI/gpt-4o-mini", default_base_url="https://api.forge.tensorblock.co/v1/chat/completions", - api_key_env="FORGE_API_KEY", + api_key_env="ACESTEP_FORGE_API_KEY", api_key_required=True, secret_path_env="ACESTEP_FORGE_SECRET_PATH", secret_file_name="forge_api_key.enc",If you apply this change, also update
.env.exampleaccordingly.Note: The static analysis warnings (S106) on lines 64-65 are false positives—these are configuration key names, not hardcoded secrets.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@acestep/text_tasks/external_lm_providers.py` around lines 56 - 69, The Forge ExternalProviderProfile uses api_key_env="FORGE_API_KEY" which is inconsistent with other providers; change the api_key_env field on the "forge" ExternalProviderProfile to "ACESTEP_FORGE_API_KEY" to match the ACESTEP_ prefix (leave secret_path_env="ACESTEP_FORGE_SECRET_PATH" as-is), and update .env.example to reflect the new ACESTEP_FORGE_API_KEY variable so examples and runtime config stay consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.env.example:
- Line 63: The .env.example entry FORGE_API_BASE is misleading because the app
uses profile.default_base_url; either remove the FORGE_API_BASE line from
.env.example, or implement support by reading process.env.FORGE_API_BASE where
the base URL is resolved (replace or override profile.default_base_url). Update
the code path that computes the base URL (the place referencing
profile.default_base_url) to prefer process.env.FORGE_API_BASE when set, and
adjust .env.example accordingly if you choose to implement support.
---
Nitpick comments:
In `@acestep/text_tasks/external_lm_providers.py`:
- Around line 56-69: The Forge ExternalProviderProfile uses
api_key_env="FORGE_API_KEY" which is inconsistent with other providers; change
the api_key_env field on the "forge" ExternalProviderProfile to
"ACESTEP_FORGE_API_KEY" to match the ACESTEP_ prefix (leave
secret_path_env="ACESTEP_FORGE_SECRET_PATH" as-is), and update .env.example to
reflect the new ACESTEP_FORGE_API_KEY variable so examples and runtime config
stay consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1af35bd7-b251-4ef4-be84-4a1d7d51829d
📒 Files selected for processing (5)
.env.exampleacestep/text_tasks/external_ai_request_helpers.pyacestep/text_tasks/external_ai_request_helpers_test.pyacestep/text_tasks/external_lm_providers.pyacestep/text_tasks/external_lm_providers_test.py
|
|
||
| # Forge external LM settings (optional) | ||
| # FORGE_API_KEY=your-forge-api-key | ||
| # FORGE_API_BASE=https://api.forge.tensorblock.co/v1 |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Search for FORGE_API_BASE usage in the codebase
# Expected: Find code that reads FORGE_API_BASE env var, or confirm it's unused
echo "=== Searching for FORGE_API_BASE usage ==="
rg -n "FORGE_API_BASE" --type py
echo ""
echo "=== Searching for os.getenv/environ patterns with FORGE ==="
rg -n "getenv.*FORGE|environ.*FORGE" --type pyRepository: ace-step/ACE-Step-1.5
Length of output: 168
Remove FORGE_API_BASE from .env.example or implement support for it.
FORGE_API_BASE is documented in this file but is not consumed by the application. The code defaults to profile.default_base_url instead of checking this environment variable, making this documentation misleading to users.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.env.example at line 63, The .env.example entry FORGE_API_BASE is misleading
because the app uses profile.default_base_url; either remove the FORGE_API_BASE
line from .env.example, or implement support by reading
process.env.FORGE_API_BASE where the base URL is resolved (replace or override
profile.default_base_url). Update the code path that computes the base URL (the
place referencing profile.default_base_url) to prefer process.env.FORGE_API_BASE
when set, and adjust .env.example accordingly if you choose to implement
support.
Summary
Adds Forge as a supported LLM provider by extending the external language model provider configuration and request handling logic to include Forge's OpenAI-compatible API.
Changes
.env.example: AddedFORGE_API_KEYandFORGE_API_BASEenvironment variable examples for Forge configuration.acestep/text_tasks/external_ai_request_helpers.py: Updated request-building logic to support Forge's OpenAI-compatible JSON output format.acestep/text_tasks/external_ai_request_helpers_test.py: Added tests for Forge-specific request payloads, including JSON output handling.acestep/text_tasks/external_lm_providers.py: Added Forge to_EXTERNAL_PROVIDER_PROFILESwith default settings and API endpoint details.acestep/text_tasks/external_lm_providers_test.py: Added validation tests for Forge provider configuration.Usage
Set the following environment variables:
FORGE_API_KEY: Your Forge API key.FORGE_API_BASE(optional): Base URL for Forge API, defaulting tohttps://api.forge.tensorblock.co/v1.Configure Forge as the provider in your code:
Example model name format:
"forge/OpenAI/gpt-4o-mini".Test Evidence
pytest tests/:acestep/text_tasks/external_ai_request_helpers_test.py: Added tests for Forge request payloads, all passed.acestep/text_tasks/external_lm_providers_test.py: Validated Forge provider configuration, all tests passed.About Forge
Forge is an open-source middleware service for unified AI model provider management. It routes requests across 40+ AI providers with access to thousands of models through a single OpenAI-compatible API.
I work at TensorBlock and will help maintain this integration.
References
Summary by CodeRabbit
Release Notes
New Features
Chores
Tests