OpenAICompletion class
OpenAI Text Completion capability implementation
This module handles text completion functionality for OpenAI providers. Note: OpenAI has deprecated the completions endpoint in favor of chat completions.
- Implemented types
Constructors
- OpenAICompletion.new(OpenAIClient client, OpenAIConfig config)
Properties
- client → OpenAIClient
-
final
- config → OpenAIConfig
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
batchComplete(
List< String> prompts, {String? model, int? maxTokens, double? temperature, int? concurrency = 5}) → Future<List< CompletionResponse> > - Batch complete multiple prompts
-
complete(
CompletionRequest request) → Future< CompletionResponse> -
Sends a completion request to generate text
override
-
completeForUseCase(
String prompt, CompletionUseCase useCase) → Future< CompletionResponse> - Complete with best practices for different use cases
-
completeStream(
CompletionRequest request) → Stream< String> - Complete text with streaming support
-
completeWithParams(
{required String prompt, String? model, int? maxTokens, double? temperature, double? topP, List< String> ? stop, double? presencePenalty, double? frequencyPenalty, String? suffix, bool echo = false}) → Future<CompletionResponse> - Complete with custom parameters
-
completeWithRetry(
CompletionRequest request, {int maxRetries = 3, Duration delay = const Duration(seconds: 1)}) → Future< CompletionResponse> - Complete with retry logic for better reliability
-
estimateTokenCount(
String text) → int - Estimate token count for a prompt (rough estimation)
-
generateMultiple(
CompletionRequest request, int count) → Future< List< CompletionResponse> > - Generate multiple completions for the same prompt
-
isPromptWithinLimits(
String prompt, {int? maxTokens}) → bool - Check if prompt is within token limits
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
truncatePrompt(
String prompt, {int? maxTokens}) → String - Truncate prompt to fit within token limits
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited