Skip to content

Conversation

@Aias00
Copy link
Contributor

@Aias00 Aias00 commented Mar 30, 2025

refactor ai plugins

  1. add common module
  2. refactor other ai plugins

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 March 31, 2025 04:44
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 refactors the AI plugins by introducing a common module (AiCommonConfig) and updating the configuration and strategy references in the various AI plugin components. Key changes include the replacement of AiProxyConfig with AiCommonConfig, renaming and moving code in the OpenAI strategy and related classes, and updating the AiModel invocation flow.

Reviewed Changes

Copilot reviewed 19 out of 25 changed files in this pull request and generated 1 comment.

File Description
shenyu-plugin-ai-token-limiter Removed unused imports and refactored AiStatisticServerHttpResponse to use AiModel for token extraction
shenyu-plugin-ai-proxy (Handler & Plugin) Replaced AiProxyConfig with AiCommonConfig and updated configuration assignment
shenyu-plugin-ai-common Moved and refactored OpenAI and related strategy interfaces to use common configurations
shenyu-common Added new constants to support token usage tracking
Files not reviewed (6)
  • shenyu-plugin/pom.xml: Language not supported
  • shenyu-plugin/shenyu-plugin-ai/pom.xml: Language not supported
  • shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-common/pom.xml: Language not supported
  • shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-prompt/pom.xml: Language not supported
  • shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/pom.xml: Language not supported
  • shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-token-limiter/pom.xml: Language not supported

Comment on lines 108 to 109
exchange.getAttributes().put(Constants.AI_MODEL, providerEnum);

Copy link

Copilot AI Mar 31, 2025

Choose a reason for hiding this comment

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

The attribute 'Constants.AI_MODEL' is set to a providerEnum instead of the AiModel instance, which can lead to runtime errors in components that expect an AiModel. Set the attribute to 'aiModel' instead.

Suggested change
exchange.getAttributes().put(Constants.AI_MODEL, providerEnum);
exchange.getAttributes().put(Constants.AI_MODEL, aiModel);

Copilot uses AI. Check for mistakes.
@Aias00 Aias00 added this to the 2.7.0.1 milestone Mar 31, 2025
@moremind moremind added the plugin:ai plugin:ai label Apr 14, 2025
@moremind moremind merged commit ae1702b into apache:master Apr 14, 2025
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin:ai plugin:ai

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants