chat {openaistream}R Documentation

chat Class

Description

chat Class

chat Class

Super class

openaistream::openai -> chat

Methods

Public methods

Inherited methods

Method create()

Creates a model response for the given chat conversation.

Usage
chat$create(messages, model, stream = F, n = 1, num = 2, verbosity = 0, ...)
Arguments
messages

list Required. A list of messages comprising the conversation so far.

model

character Required. The model to use for generating chat completions.

stream

logical. Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available.

n

integer. How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs. NOTE: The parameter sometimes fails to work when 'num' is not assigned a value, and the reason for this is currently unclear. When failure occurs, try assigning any integer greater than 0 to the 'num' parameter.

num

The num parameter controls the number of text entries returned by a stream in one go. Note that this is different from the n parameter, which specifies the number of results returned. For detailed information on the n parameter, please refer to OpenAI's API documentation.

verbosity

numeric. Verbosity level for the API call(0:no output;1:show headers; 2:show headers and bodies;3: show headers, bodies, and curl status messages.).

...

Additional parameters as required by the OpenAI API.For example:max_tokens;n;stop;temperature......

Returns

Returns a chat completion object, or a streamed sequence of chat completion chunk objects if the request is streamed.


Method clone()

The objects of this class are cloneable with this method.

Usage
chat$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


[Package openaistream version 0.3.0 Index]