Completion API
All the following functions, types, interfaces are exported by the library.
complete function
Gets the completion for a piece of text.
Signature:
function complete(options: CompletionOptions): Promise<Result<{
completion: string;
}, RequestError>>;
Parameters
Parameter | Type |
---|---|
options | CompletionOptions |
Returns:
Promise<Result<{ completion: string; }
, RequestError>>
completeStream function
Gets a stream of completions for a piece of text.
Signature:
function completeStream(options: CompletionOptions): Promise<Result<AsyncGenerator<{
completion: string;
}>, RequestError>>;
Parameters
Parameter | Type |
---|---|
options | CompletionOptions |
Returns:
Promise<Result<AsyncGenerator<{ completion: string; }
>, RequestError>>
completeMultipleChoices function
Gets multiple completions for a piece of text.
Signature:
declare function completeMultipleChoices(options: CompletionMultipleChoicesOptions): Promise<Result<{
choices: Array<{
completion: string;
}>;
}, RequestError>>;
Parameters
Parameter | Type | Description |
---|---|---|
options | CompletionMultipleChoicesOptions |
Returns:
Promise<Result<{ choices: Array<{ completion: string; }>; }
, RequestError>>
CompletionOptions
Options for completion request
Signature:
interface CompletionOptions
Properties
Property | Type | Description |
---|---|---|
extraParams? | Record<string, unknown> | (Optional) Allows extra model specific parameters. Consult with the documentation for which parameters are available for each model. |
maxOutputTokens? | number | (Optional) The maximum number of tokens generated in the completion. The absolute maximum value is limited by model's context size. |
model | CompletionModel | Specifies the model to use |
prompt | string | The string/text to complete |
temperature? | number | (Optional) Sampling temperature between 0 and 1. The higher the value, the more likely the model will produce a completion that is more creative and imaginative. |
CompletionMultipleChoicesOptions
Signature:
interface CompletionMultipleChoicesOptions extends CompletionOptions
Extends: CompletionOptions
Properties
Property | Type | Description |
---|---|---|
choicesCount | number | Number of completions to generate. Minimum 1, the maximum depends on the model, the returned choices will be automatically adjusted to fit the model. You should not treat this as a guarantee, what you will get is a number of choices upto choicesCount . |
CompletionModel
Available models for text completion
Signature:
type CompletionModel = 'text-bison';