Skip to content

Conversation

@HY-love-sleep
Copy link
Contributor

@HY-love-sleep HY-love-sleep commented Aug 8, 2025

add ai response transformer

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

@Aias00 Aias00 requested a review from Copilot August 11, 2025 10:29

This comment was marked as outdated.

@Aias00 Aias00 requested a review from Copilot August 12, 2025 05:59

This comment was marked as outdated.

@Aias00 Aias00 requested a review from Copilot August 13, 2025 02:02
Copy link
Contributor

Copilot AI left a 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) {

Copy link

Copilot AI Aug 13, 2025

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.

Suggested change
LOG.error("AiResponseTransformerPluginHandler handle plugin error", e);

Copilot uses AI. Check for mistakes.
if (Objects.nonNull(aiResponseTransformerHandle) && Objects.nonNull(aiResponseTransformerHandle.getProvider())) {
ChatClientCache.getInstance().destroyClient(ruleData.getId() + aiResponseTransformerHandle.getProvider());
}
} catch (Exception e) {
Copy link

Copilot AI Aug 13, 2025

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@Aias00 Aias00 left a comment

Choose a reason for hiding this comment

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

LGTM

@Aias00 Aias00 merged commit 7d971dc into apache:master Aug 13, 2025
43 checks passed
@Aias00 Aias00 added this to the 2.7.0.2 milestone Aug 17, 2025
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