Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
*
* <p>This class holds both per-request generation parameters (temperature, maxTokens, etc.)
* and connection-level configuration (apiKey, baseUrl, modelName, stream).
Copy link

Copilot AI Jan 3, 2026

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).

Suggested change
* and connection-level configuration (apiKey, baseUrl, modelName, stream).
* and connection-level configuration (apiKey, baseUrl, modelName, stream).
*
* <p>Connection-level configuration is typically shared across many requests, while
* generation parameters may vary per request. A common pattern is to create a reusable
* "base" {@code GenerateOptions} instance that captures all shared configuration (such as
* API key, base URL, model name, and provider capability) and then derive per-request
* variants via the builder when needed.
*
* <p>For example, you can:
* <ul>
* <li>Create a base instance once at application startup with the connection-level
* settings that apply to most calls.</li>
* <li>For each request, use the builder to construct a new {@code GenerateOptions}
* instance that reuses the shared settings and overrides only the request-specific
* generation parameters (such as temperature or max tokens).</li>
* </ul>
*
* <p>This approach replaces the need for a separate configuration object and keeps
* all configuration in a single, immutable value type that can safely be reused.

Copilot uses AI. Check for mistakes.
*
* <p>For connection-level configuration that will be reused across multiple requests,
* consider using {@link OpenAIConfig} to create a configuration context and then use
* {@link OpenAIConfig#toOptions()} to create GenerateOptions instances.
*/
public class GenerateOptions {
// Connection-level configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@
import reactor.core.publisher.Flux;

/**
* Stateless OpenAI Chat Model using native HTTP API.
* OpenAI Chat Model using native HTTP API.
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The class-level documentation has been simplified but now lacks important usage guidance. The removed example showed how to use the stateless API with GenerateOptions, which is crucial for users migrating from the deprecated OpenAIConfig approach. Consider adding a brief usage example showing how to construct GenerateOptions and pass them to the model methods.

Copilot uses AI. Check for mistakes.
*
* <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>
Expand All @@ -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 {

Expand Down Expand Up @@ -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
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The deprecation annotations have been removed from the builder() method and Builder class, but the Builder class documentation still mentions "backward compatibility with the old API" and "wraps the configuration so that calls without explicit options use the builder-provided values." This suggests the Builder is still meant for backward compatibility. If this is no longer deprecated, the documentation should be updated to clarify when to use the Builder versus the stateless approach with GenerateOptions directly, or if it's now the recommended approach, remove the backward compatibility language.

Copilot uses AI. Check for mistakes.
@Deprecated
public static class Builder {
private String apiKey;
private String modelName;
Expand Down

This file was deleted.

Loading