-
Notifications
You must be signed in to change notification settings - Fork 181
feat: support configurable endpointPath for OpenAI-compatible APIs #488
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: support configurable endpointPath for OpenAI-compatible APIs #488
Conversation
…penAI-compatible-APIs
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 configurable endpointPath support for OpenAI-compatible APIs to address issue #431. Different API providers may use non-standard endpoint paths (e.g., /v4/chat/completions, /api/v1/llm/chat), and this feature enables flexible configuration at both the model level and per-request level.
Key changes:
- Added
endpointPathfield toGenerateOptionswith full builder and merge support - Extended
OpenAIChatModel.Builderto accept endpoint path configuration - Updated
OpenAIClientto use custom endpoint paths with fallback to default - Added Spring Boot and Micronaut configuration support for
endpoint-pathproperty - Included comprehensive unit tests for custom and default endpoint path behavior
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| agentscope-core/src/main/java/io/agentscope/core/model/GenerateOptions.java | Added endpointPath field with getter, builder method, and merge logic to support per-request endpoint configuration |
| agentscope-core/src/main/java/io/agentscope/core/model/OpenAIChatModel.java | Extended Builder with endpointPath() method for model-level endpoint configuration |
| agentscope-core/src/main/java/io/agentscope/core/model/OpenAIClient.java | Modified call() and stream() methods to use custom endpointPath from options with fallback to default |
| agentscope-extensions/agentscope-spring-boot-starters/agentscope-spring-boot-starter/src/main/java/io/agentscope/spring/boot/properties/OpenAIProperties.java | Added endpointPath property with getter/setter for Spring Boot configuration |
| agentscope-extensions/agentscope-spring-boot-starters/agentscope-spring-boot-starter/src/main/java/io/agentscope/spring/boot/model/ModelProviderType.java | Added logic to pass endpointPath from properties to OpenAIChatModel builder |
| agentscope-extensions/agentscope-micronaut-extensions/agentscope-micronaut-extension/src/main/java/io/agentscope/micronaut/properties/OpenAIProperties.java | Added endpointPath property with getter/setter for Micronaut configuration |
| agentscope-extensions/agentscope-micronaut-extensions/agentscope-micronaut-extension/src/main/java/io/agentscope/micronaut/model/ModelProviderType.java | Added logic to pass endpointPath from properties to OpenAIChatModel builder |
| agentscope-core/src/test/java/io/agentscope/core/model/OpenAIClientTest.java | Added unit tests for custom endpoint path and default endpoint path scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…gentscope-ai#488) ⏺ ## AgentScope-Java Version 1.0.7 ## Description ### Background Issue agentscope-ai#431 requests support for configuring the `endpointPath` parameter for OpenAI-compatible APIs. Different providers may use different endpoint paths (e.g., `/v1/chat/completions`, `/v4/chat/completions`, `/api/v1/llm/chat`), but the current code has a hardcoded endpoint path. ### Purpose Enable flexible configuration of the API endpoint path to support various OpenAI-compatible providers with non-standard endpoint structures. ### Changes Made - **GenerateOptions**: Added `endpointPath` field with getter, Builder setter, and merge support - **OpenAIClient**: Modified `call()` and `stream()` methods to use custom endpointPath from options, with fallback to default `/v1/chat/completions` - **OpenAIChatModel.Builder**: Added `endpointPath()` method for model-level configuration - **Properties (Spring Boot & Micronaut)**: Added `endpoint-path` configuration property - **ModelProviderType (Spring Boot & Micronaut)**: Updated to pass `endpointPath` to model builder - **Tests**: Added unit tests for custom and default endpoint path behavior ### How to Test **Java API:** ```java // Via GenerateOptions (per-request) GenerateOptions options = GenerateOptions.builder() .endpointPath("/v4/chat/completions") .build(); model.generate(messages, options); // Via OpenAIChatModel.Builder (model-level) OpenAIChatModel model = OpenAIChatModel.builder() .apiKey("sk-xxx") .modelName("gpt-4") .endpointPath("/v4/chat/completions") .build(); Spring Boot: agentscope: model: provider: openai openai: api-key: ${OPENAI_API_KEY} model-name: gpt-4 endpoint-path: /v4/chat/completions Micronaut: agentscope: model: provider: openai openai: api-key: ${OPENAI_API_KEY} model-name: gpt-4 endpoint-path: /v4/chat/completions Unit Tests: mvn test -Dtest=OpenAIClientTest#testCustomEndpointPathFromOptions mvn test -Dtest=OpenAIClientTest#testDefaultEndpointPathWhenNotSpecified Checklist - Code has been formatted with mvn spotless:apply - All tests are passing (mvn test) - Javadoc comments are complete and follow project conventions - Related documentation has been updated (configuration examples in Properties classes) - Code is ready for review --- Closes agentscope-ai#431 ```
⏺ ## AgentScope-Java Version
1.0.7
Description
Background
Issue #431 requests support for configuring the
endpointPathparameter for OpenAI-compatible APIs. Different providers may use different endpoint paths (e.g.,/v1/chat/completions,/v4/chat/completions,/api/v1/llm/chat), but the current code has a hardcoded endpoint path.Purpose
Enable flexible configuration of the API endpoint path to support various OpenAI-compatible providers with non-standard endpoint structures.
Changes Made
endpointPathfield with getter, Builder setter, and merge supportcall()andstream()methods to use custom endpointPath from options, with fallback to default/v1/chat/completionsendpointPath()method for model-level configurationendpoint-pathconfiguration propertyendpointPathto model builderHow to Test
Java API: