zhaohai666 opened a new pull request, #693:
URL: https://github.com/apache/rocketmq-dashboard/pull/693

   # PR: Refactor LlmGateway to Interface\-Based Provider Pattern
   
   ## Overview
   
   Refactor the original monolithic single\-implementation `LlmGateway` and 
reconstruct it into a standard interface\-based provider pattern architecture, 
improving system scalability, testability and maintainability for 
multi\-LLM\-provider access scenarios\.
   
   ## Core Changes
   
   1. **Decouple LLM Gateway Logic**
   Split the original integrated LLM gateway business logic into a unified 
abstract interface and two independent concrete implementations:
   
   
       - `LlmGatewayImpl`: Official HTTP client implementation for production 
environment API requests
   
       - `LlmGatewayStub`: Mock stub implementation for local frontend 
development and unit testing
   
   2. **Unify Configuration Parsing Logic**
   Introduce `LlmSettingsResolver` to take charge of unified LLM configuration 
parsing\. It replaces the standalone `LlmConfigService` and scattered 
configuration parsing logic in `LlmController`\.
   
   3. **Clean Up Redundant Legacy Components**
   Simplify the implementation of `AiController` and `AiService` layers, and 
remove obsolete redundant components including `OpenAiCompatibleLlmClient` and 
`OpenAiCompatibleLlmGateway`\.
   
   4. **Optimize MCP Tool Registration**
   Clean up the entire `tool/` subpackage \(contains 10 independent tool 
handler files\)\. Inline all tool definition logic directly into 
`McpServerImpl` to simplify package structure\.
   
   ## Architecture Design Details
   
   ### 1\. Standardized Core LlmGateway Interface
   
   The abstract `LlmGateway` interface defines three universal standardized 
methods to unify the interaction specification of all LLM providers:
   
   - `chat()`: Process and execute LLM chat completion requests
   
   - `testConnection()`: Verify network connectivity and availability of the 
target LLM provider endpoint
   
   - `listModels()`: Fetch and return the list of available models from the LLM 
provider
   
   ### 2\. Production Implementation \(LlmGatewayImpl\)
   
   Built based on Spring WebClient, supporting multi\-provider standard 
specifications natively\. Compatible with mainstream LLM services including 
OpenAI, Azure OpenAI, DeepSeek, Tongyi Qwen, Ollama and AWS Bedrock, realizing 
unified adaptation of multiple LLM providers\.
   
   ### 3\. Mock Implementation \(LlmGatewayStub\)
   
   Provides static predefined mock response data\. It supports offline local 
development and independent unit testing without relying on real LLM service 
resources, greatly improving development and testing efficiency\.
   
   ### 4\. Unified Configuration Resolution
   
   The newly added `LlmSettingsResolver` loads and parses all LLM\-related 
configurations through `SettingsService`, abandoning the independent 
`LlmConfigService`, realizing centralized management of configuration logic and 
reducing code redundancy\.
   
   ### 5\. Simplified MCP Tool Architecture
   
   Removed all independent standalone `ToolHandler` classes\. All MCP tool 
definition and registration logic is uniformly embedded in `McpServerImpl`, 
optimizing code cohesion and eliminating scattered tool management logic.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to