-
Notifications
You must be signed in to change notification settings - Fork 274
refactor(model): remove OpenAIConfig and simplify OpenAIChatModel API #427
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,11 +33,9 @@ | |
| import reactor.core.publisher.Flux; | ||
|
|
||
| /** | ||
| * Stateless OpenAI Chat Model using native HTTP API. | ||
| * OpenAI Chat Model using native HTTP API. | ||
|
||
| * | ||
| * <p>This implementation uses direct HTTP calls to OpenAI-compatible APIs. All configuration | ||
| * (API key, base URL, model name, streaming mode) is passed per-request via {@link GenerateOptions}, | ||
| * making this model stateless and safe to share across multiple threads. | ||
| * <p>This implementation uses direct HTTP calls to OpenAI-compatible APIs. | ||
| * | ||
| * <p>Features: | ||
| * <ul> | ||
|
|
@@ -47,26 +45,6 @@ | |
| * <li>Timeout and retry configuration</li> | ||
| * <li>Multi-provider support (OpenAI, GLM, DeepSeek, Doubao, etc.)</li> | ||
| * </ul> | ||
| * | ||
| * <p><b>Usage example:</b> | ||
| * <pre>{@code | ||
| * // Create a stateless model instance | ||
| * OpenAIChatModel model = new OpenAIChatModel(); | ||
| * | ||
| * // Configure once | ||
| * OpenAIConfig config = OpenAIConfig.builder() | ||
| * .apiKey("sk-xxx") | ||
| * .baseUrl("https://api.openai.com/v1") | ||
| * .stream(true) | ||
| * .build(); | ||
| * | ||
| * // Use with different models | ||
| * GenerateOptions opts1 = config.toOptions().modelName("gpt-4").build(); | ||
| * GenerateOptions opts2 = config.toOptions().modelName("gpt-3.5-turbo").build(); | ||
| * | ||
| * model.stream(messages1, null, opts1); | ||
| * model.stream(messages2, null, opts2); | ||
| * }</pre> | ||
| */ | ||
| public class OpenAIChatModel extends ChatModelBase { | ||
|
|
||
|
|
@@ -368,27 +346,18 @@ public String getModelName() { | |
| /** | ||
| * Creates a new builder for OpenAIChatModel. | ||
| * | ||
| * <p>The builder provides backward compatibility with the old API by creating a model | ||
| * with embedded configuration. The built model wraps the configuration in a way that | ||
| * each call uses the configured values. | ||
| * | ||
| * @return a new Builder instance | ||
| * @deprecated Use {@link OpenAIConfig} with {@link GenerateOptions} for stateless usage | ||
| */ | ||
| @Deprecated | ||
| public static Builder builder() { | ||
| return new Builder(); | ||
| } | ||
|
|
||
| /** | ||
| * Builder for OpenAIChatModel. | ||
| * | ||
| * <p>Provides backward compatibility with the old API. The built model internally wraps | ||
| * the configuration so that calls without explicit options use the builder-provided values. | ||
| * | ||
| * @deprecated Use {@link OpenAIConfig} with {@link GenerateOptions} for stateless usage | ||
| * <p>The built model internally wraps the configuration so that calls without explicit | ||
| * options use the builder-provided values. | ||
| */ | ||
|
Comment on lines
355
to
360
|
||
| @Deprecated | ||
| public static class Builder { | ||
| private String apiKey; | ||
| private String modelName; | ||
|
|
||
This file was deleted.
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.
The removed documentation references to OpenAIConfig are appropriate since that class has been deleted. However, it might be helpful to add guidance on how to reuse common configuration across multiple requests now that OpenAIConfig is removed. Users previously relied on OpenAIConfig for this purpose, and the documentation should clarify the recommended pattern (e.g., creating a base GenerateOptions and using GenerateOptions.builder() to customize per request).