[feat]: add ai response transformer#6095
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new AI response transformer plugin to the ShenYu gateway, enabling AI-powered transformation of HTTP responses. The plugin leverages AI models to modify response content, headers, and format according to specified prompts.
Key Changes:
- Implementation of AI response transformer plugin with support for OpenAI and DeepSeek providers
- Spring Boot auto-configuration for seamless integration
- Comprehensive test coverage for all plugin components
Reviewed Changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-response-transformer/src/main/java/org/apache/shenyu/plugin/ai/transformer/response/AiResponseTransformerPlugin.java |
Core plugin implementation with response transformation logic |
shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-ai-response-transformer/src/main/java/org/apache/shenyu/springboot/starter/plugin/ai/transformer/response/AiResponseTransformerPluginConfiguration.java |
Spring Boot auto-configuration for the plugin |
shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginEnum.java |
Added plugin enum entry with code 66 |
shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/rule/AiResponseTransformerHandle.java |
Configuration model for rule-level settings |
| Multiple test files | Comprehensive unit tests for plugin components |
| Multiple database files | Schema updates across all supported databases |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| ChatClientCache.getInstance().init("default", factory.createAiModel(convertConfig(aiResponseTransformerConfig))); | ||
| Singleton.INST.single(AiResponseTransformerConfig.class, aiResponseTransformerConfig); | ||
| } catch (Exception e) { | ||
|
|
There was a problem hiding this comment.
Exception handling should log the error or provide more specific error information instead of silently returning.
| LOG.error("AiResponseTransformerPluginHandler handle plugin error", e); |
| if (Objects.nonNull(aiResponseTransformerHandle) && Objects.nonNull(aiResponseTransformerHandle.getProvider())) { | ||
| ChatClientCache.getInstance().destroyClient(ruleData.getId() + aiResponseTransformerHandle.getProvider()); | ||
| } | ||
| } catch (Exception e) { |
There was a problem hiding this comment.
Exception handling should log the error or provide more specific error information instead of silently returning.
add ai response transformer
Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true.