-
Notifications
You must be signed in to change notification settings - Fork 3k
[feat]: add ai response transformer #6095
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
[feat]: add ai response transformer #6095
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) { | ||
|
|
Copilot
AI
Aug 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) { |
Copilot
AI
Aug 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exception handling should log the error or provide more specific error information instead of silently returning.
Aias00
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
add ai response transformer
Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true.