Title: | Streaming Capabilities for 'OpenAI API' Interactions |
---|---|
Description: | Based on the 'httr2' framework, the 'OpenAI' interface supports streaming calls and model training. For more details on the API methods implemented, see the 'OpenAI' platform documentation at <https://platform.openai.com/docs/api-reference>. |
Authors: | Li Gen [aut, cre] |
Maintainer: | Li Gen <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.0 |
Built: | 2024-11-10 02:58:42 UTC |
Source: | https://github.com/libingfei/openaistream |
api_config Class
api_config Class
A R6 class to manage config.
new()
Initialize the api_config object
api_config$new()
set_api_key()
Configure the api_key settings.
api_config$set_api_key(api_key)
api_key
your openai_key
set_proxy()
Configure the proxy settings.
api_config$set_proxy(proxy_ip, proxy_port)
proxy_ip
character Required. The IP address of the proxy.
proxy_port
character Required. The port number of the proxy.
get_proxy()
Configure the proxy gettings.
api_config$get_proxy()
get_api_key()
Api key gettings.
api_config$get_api_key()
get_api_endpoints()
Endpoints gettings.
api_config$get_api_endpoints()
clone()
The objects of this class are cloneable with this method.
api_config$clone(deep = FALSE)
deep
Whether to make a deep clone.
assistants Class
assistants Class
openaistream::openai
-> assistants
create()
Create an assistant with a model and instructions.
assistants$create(model, ..., verbosity = 0)
model
character Required. ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.
...
Additional parameters as required by the OpenAI API.For example:name;description;instructions;tools;file_ids;metadata
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.).
An assistant object.
retrieve()
Retrieves an assistant.
assistants$retrieve(assistant_id, verbosity = 0)
assistant_id
character Required. The ID of the assistant to retrieve.
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.).
The assistant object matching the specified ID.
modify()
Modifies an assistant.
assistants$modify(assistant_id, ..., verbosity = 0)
assistant_id
character Required. The ID of the assistant to modify.
...
Additional parameters as required by the OpenAI API.For example:model;name;description;instructions;tools;file_ids,metadata
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.).
The assistant object matching the specified ID.
delete()
Delete an assistant.
assistants$delete(assistant_id, verbosity = 0)
assistant_id
character Required. The ID of the assistant to delete.
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.).
Deletion status
list()
Returns a list of assistants
assistants$list(..., verbosity = 0)
...
Additional parameters as required by the OpenAI API.For example:limit;order;after;before;
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.).
A list of assistant objects.
file_create()
Create an assistant file by attaching a File to an assistant.
assistants$file_create(assistant_id, file_id, verbosity = 0)
assistant_id
character Required. The ID of the assistant for which to create a File.
file_id
character Required. A File ID (with purpose="assistants") that the assistant should use. Useful for tools like retrieval and code_interpreter that can access files.
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.).
An assistant file object.
file_retrieve()
Retrieves an AssistantFile.
assistants$file_retrieve(assistant_id, file_id, verbosity = 0)
assistant_id
character Required. The ID of the assistant who the file belongs to.
file_id
character Required. The ID of the file we're getting.
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.).
The assistant file object matching the specified ID.
file_delete()
Delete an assistant file.
assistants$file_delete(assistant_id, file_id, verbosity = 0)
assistant_id
character Required. The ID of the assistant who the file belongs to.
file_id
character Required. The ID of the file we're getting.
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.).
Deletion status
file_list()
Retrieve a list of files from OpenAI.
assistants$file_list(assistant_id, ..., verbosity = 0)
assistant_id
character Required. The ID of the assistant who the file belongs to.
...
Additional parameters as required by the OpenAI API.For example:limit,order,after,before
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.).
A list of files.
clone()
The objects of this class are cloneable with this method.
assistants$clone(deep = FALSE)
deep
Whether to make a deep clone.
To turn audio into text or text into audio
openaistream::openai
-> audio
speech()
Generates audio from the input text.
audio$speech( model = "tts-1", input, voice = "alloy", stream = F, num = 100, ..., verbosity = 0 )
model
character Required. One of the available TTS models: tts-1 or tts-1-hd
input
character Required. The text to generate audio for. The maximum length is 4096 characters.
voice
character Required. The voice to use when generating the audio. Supported voices are alloy, echo, fable, onyx, nova, and shimmer.
stream
logical. Using the stream call, it will return raw data of the specified length, which can be saved in the set format such as mp3, etc. For details, please see the examples.
num
The num parameter controls the number of raw 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.
...
Additional parameters as required by the OpenAI API.For example:response_format;speed....
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.).
The audio file content.
transcription()
Transcribes audio into the input language.
audio$transcription(path, model = "whisper-1", ..., verbosity = 0)
path
character Required. The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
model
character Required. ID of the model to use. Only whisper-1 is currently available.
...
Additional parameters as required by the OpenAI API.For example:language;prompt;response_format;temperature....
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.).
The transcribed text.
translation()
Translates audio into English.
audio$translation(path, model = "whisper-1", ..., verbosity = 0)
path
character Required. The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
model
character Required. ID of the model to use. Only whisper-1 is currently available.
...
Additional parameters as required by the OpenAI API.For example:prompt;response_format;temperature....
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.).
The transcribed text.
clone()
The objects of this class are cloneable with this method.
audio$clone(deep = FALSE)
deep
Whether to make a deep clone.
base_api Class
base_api Class
new()
Initialize the OpenAI API interface with the provided API key and other.
base_api$new(etc)
etc
Config.
clone()
The objects of this class are cloneable with this method.
base_api$clone(deep = FALSE)
deep
Whether to make a deep clone.
chat Class
chat Class
openaistream::openai
-> chat
create()
Creates a model response for the given chat conversation.
chat$create(messages, model, stream = F, n = 1, num = 2, verbosity = 0, ...)
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 a chat completion object, or a streamed sequence of chat completion chunk objects if the request is streamed.
clone()
The objects of this class are cloneable with this method.
chat$clone(deep = FALSE)
deep
Whether to make a deep clone.
DataStream Class
DataStream Class
A R6 class to manage data streams.
next_value
The next data value from the DataStream or an error message.
new()
Initialize the DataStream object
DataStream$new(requery, num = 2)
requery
The requery object, usually of class 'curl'
num
Numeric. Defines the number of lines to read from the data source.
close()
Close the DataStream
This method tries to destroy the object, and closes the requery if opened.
DataStream$close()
A character message indicating the status of the close operation.
get_state()
Get the status of the DataStream
DataStream$get_state()
A character string indicating the current status of the DataStream.
clone()
The objects of this class are cloneable with this method.
DataStream$clone(deep = FALSE)
deep
Whether to make a deep clone.
embeddings Class
embeddings Class
openaistream::openai
-> embeddings
create()
Creates an embedding vector representing the input text.
embeddings$create(model, input, ..., verbosity = 0)
model
character Required. ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.
input
character Required. Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for text-embedding-ada-002), cannot be an empty string, and any array must be 2048 dimensions or less.
...
Additional parameters as required by the OpenAI API.For example:encoding_format;user....
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.).
Embeddings for the input data.
clone()
The objects of this class are cloneable with this method.
embeddings$clone(deep = FALSE)
deep
Whether to make a deep clone.
Files Class
Files Class
openaistream::openai
-> files
upload()
Upload a file that can be used across various endpoints. The size of all the files uploaded by one organization can be up to 100 GB.The size of individual files can be a maximum of 512 MB or 2 million tokens for Assistants. See the Assistants Tools guide to learn more about the types of files supported. The Fine-tuning API only supports .jsonl files.
files$upload(path = NULL, verbosity = 0, purpose = "fine-tune")
path
character Required. Path to the file that needs to be uploaded.
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.).
purpose
The intended purpose of the uploaded file. Use "fine-tune" for Fine-tuning and "assistants" for Assistants and Messages. This allows us to validate the format of the uploaded file is correct for fine-tuning.
The uploaded File object.
list()
Returns a list of files that belong to the user's organization.
files$list(..., verbosity = 0)
...
Additional parameters as required by the OpenAI API.For example:purpose
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.).
A list of File objects.
delete()
Delete a file.
files$delete(file_id, verbosity = 0)
file_id
character Required. The ID of the file to use for this request.
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.).
Deletion status.
retrieve()
Returns information about a specific file.
files$retrieve(file_id, verbosity = 0)
file_id
character Required. The ID of the file to retrieve details for.
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.).
The File object matching the specified ID.
retrieve_content()
Returns information about a specific file content.
files$retrieve_content(file_id, verbosity = 0)
file_id
character Required. The ID of the file to retrieve details for.
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.).
The File object matching the specified ID.
clone()
The objects of this class are cloneable with this method.
files$clone(deep = FALSE)
deep
Whether to make a deep clone.
DataStream Class
DataStream Class
openaistream::openai
-> fine_tuning
create()
Creates a job that fine-tunes a specified model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.
fine_tuning$create( model, training_file, hyperparameters = list(n_epochs = 1), ..., verbosity = 0 )
model
character Required. The model ID.
training_file
character Required. The file used for training.
hyperparameters
list. The hyperparameters used for the fine-tuning job. include batch_size;learning_rate_multiplier;n_epochs.
...
Additional parameters as required by the OpenAI API.For example:validation_file......
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.).
Response indicating the success or failure of the fine-tuning job creation.
list()
List your organization's fine-tuning jobs
fine_tuning$list(verbosity = 0, ...)
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:after,limit.
A list of paginated fine-tuning job objects.
retrieve()
Get info about a fine-tuning job.
fine_tuning$retrieve(job_id, verbosity = 0)
job_id
character Required. The ID of the fine-tuning job.
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.).
The fine-tuning object with the given ID.
cancel()
Immediately cancel a fine-tune job.
fine_tuning$cancel(job_id, verbosity = 0)
job_id
character Required. The ID of the fine-tuning job to cancel.
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.).
The cancelled fine-tuning object.
events()
Get status updates for a fine-tuning job.
fine_tuning$events(job_id, ..., verbosity = 0)
job_id
character Required. The ID of the fine-tuning job to get events for.
...
Additional parameters as required by the OpenAI API. For example:after,limit.
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.).
A list of fine-tuning event objects.
clone()
The objects of this class are cloneable with this method.
fine_tuning$clone(deep = FALSE)
deep
Whether to make a deep clone.
images Class
images Class
openaistream::openai
-> images
create()
Creates an image given a prompt.
images$create(prompt, ..., verbosity = 0)
prompt
character Required. A text description of the desired image(s). The maximum length is 1000 characters for dall-e-2 and 4000 characters for dall-e-3
...
Additional parameters as required by the OpenAI API.For example:n;quality;response_format...
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.).
Returns a list of image objects.
edit()
Creates an edited or extended image given an original image and a prompt.
images$edit(image, prompt, ..., verbosity = 0)
image
character Required. The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.
prompt
character Required. A text description of the desired image(s). The maximum length is 1000 characters.
...
Additional parameters as required by the OpenAI API.For example:mask;model;n...
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.).
Returns a list of image objects.
variation()
Creates a variation of a given image.
images$variation(image, ..., verbosity = 0)
image
character Required. The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
...
Additional parameters as required by the OpenAI API.For example:model;n;response_format
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.).
Returns a list of image objects.
clone()
The objects of this class are cloneable with this method.
images$clone(deep = FALSE)
deep
Whether to make a deep clone.
messages Class
messages Class
openaistream::openai
-> messages
create()
Create a message.
messages$create(thread_id, role, content, ..., verbosity = 0)
thread_id
character Required. The ID of the thread to create a message for.
role
character Required. The role of the entity that is creating the message. Currently only user is supported.
content
character Required. The content of the message.
...
Additional parameters as required by the OpenAI API. For example:file_ids,metadata
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.)
A message object.
retrieve()
Retrieve a message.
messages$retrieve(thread_id, message_id, verbosity = 0)
thread_id
character Required. The ID of the thread the message belongs to.
message_id
character Required. The ID of the message to retrieve.
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.)
The message object matching the specified ID.
modify()
Modifies a message.
messages$modify(thread_id, message_id, ..., verbosity = 0)
thread_id
character Required. The ID of the thread the message belongs to.
message_id
character Required. The ID of the message to retrieve.
...
Additional parameters as required by the OpenAI API. For example:metadata
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.)
The modified message object.
list()
Returns a list of messages for a given thread.
messages$list(thread_id, ..., verbosity = 0)
thread_id
character Required. The ID of the thread the messages belong to.
...
Additional parameters as required by the OpenAI API.
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.)
A list of message objects.
file_retrieve()
Retrieves a message file.
messages$file_retrieve(thread_id, message_id, file_id, verbosity = 0)
thread_id
character Required. The ID of the thread the message belongs to.
message_id
character Required. The ID of the message the file belongs to.
file_id
character Required The ID of the file being retrieved.
verbosity
numeric Verbosity level for the API call(0:no output;1:show headers;
The message file object.
file_list()
Returns a list of message files.
messages$file_list(thread_id, message_id, ..., verbosity = 0)
thread_id
character Required. The ID of the thread the message belongs to.
message_id
character Required. The ID of the message the file belongs to.
...
Additional parameters as required by the OpenAI API.
verbosity
numeric Verbosity level for the API call(0:no output;1:show headers;
A list of message file objects.
clone()
The objects of this class are cloneable with this method.
messages$clone(deep = FALSE)
deep
Whether to make a deep clone.
Models Class
Models Class
openaistream::openai
-> models
list()
Lists the currently available models, and provides basic information about each one such as the owner and availability.
models$list(verbosity = 0)
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.).
A list of model objects.
retrieve()
Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
models$retrieve(model, verbosity = 0)
model
character Required. The ID of the model to use for this request
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.).
The model object matching the specified ID.
delete()
Delete a fine-tuned model. You must have the Owner role in your organization to delete a model.
models$delete(model, verbosity = 0)
model
character Required. The model to delete
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.).
Deletion status.
clone()
The objects of this class are cloneable with this method.
models$clone(deep = FALSE)
deep
Whether to make a deep clone.
moderations Class
moderations Class
openaistream::openai
-> moderations
create()
Classifies if text violates OpenAI's Content Policy.
moderations$create(input, ..., verbosity = 0)
input
character Required. The input text to classify.
...
Additional parameters as required by the OpenAI API.For example:model...
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.).
Returns a list of image objects.
clone()
The objects of this class are cloneable with this method.
moderations$clone(deep = FALSE)
deep
Whether to make a deep clone.
Provides methods to interact with OpenAI API including fetching model details, generating completions, managing files, and more. Always ensure that the API key is kept private.
models
class
files
class
fine_tuning
class
chat
class
audio
class
embeddings
class
images
class
moderations
class
assistants
class
threads
class
messages
class
runs
class
new()
Initialize the OpenAI API interface with the provided API key.
openai$new(api_key)
api_key
The OpenAI API key.
set_proxy()
Configure the proxy settings.
openai$set_proxy(proxy_ip, proxy_port)
proxy_ip
character Required. The IP address of the proxy.
proxy_port
character Required. The port number of the proxy.
clone()
The objects of this class are cloneable with this method.
openai$clone(deep = FALSE)
deep
Whether to make a deep clone.
Sys.setenv(OPENAI_KEY="you openai key") aaa <- openai$new(Sys.getenv("OPENAI_KEY")) #if need proxy #aaa$set_proxy("127.0.0.1", 10890) # List model aaa$models$list()
Sys.setenv(OPENAI_KEY="you openai key") aaa <- openai$new(Sys.getenv("OPENAI_KEY")) #if need proxy #aaa$set_proxy("127.0.0.1", 10890) # List model aaa$models$list()
runs Class
runs Class
openaistream::openai
-> runs
create()
Create a run.
runs$create(thread_id, assistant_id, ..., verbosity = 0)
thread_id
character Required. The ID of the thread to run.
assistant_id
character Required. The ID of the assistant to use to execute this run.
...
Additional parameters as required by the OpenAI API.For example:model,instructions,tools,metadata
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.)
A run object.
retrieve()
Retrieves a run.
runs$retrieve(thread_id, run_id, verbosity = 0)
thread_id
character Required The ID of the thread the run belongs to.
run_id
character Required The ID of the run to retrieve.
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.)
The run object matching the specified ID.
modify()
Modifies a run.
runs$modify(thread_id, run_id, ..., verbosity = 0)
thread_id
character Required The ID of the thread the run belongs to.
run_id
character Required The ID of the run to retrieve.
...
Additional parameters as required by the OpenAI API.
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.)
The modified run object matching the specified ID.
list()
Returns a list of runs for a given thread.
runs$list(thread_id, ..., verbosity = 0)
thread_id
character Required The ID of the thread the run belongs to.
...
Additional parameters as required by the OpenAI API.
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.)
A list of run objects.
submit_tool_outputs()
When a run has the status: "requires_action" and required_action.type is submit_tool_outputs, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request.
runs$submit_tool_outputs(thread_id, run_id, tool_outputs, verbosity = 0)
thread_id
character Required The ID of the thread the run belongs to.
run_id
character Required The ID of the run to retrieve.
tool_outputs
character Required. A list of tools for which the outputs are being submitted.
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.)
The modified run object matching the specified ID.
cancel()
Cancels a run that is in_progress.
runs$cancel(thread_id, run_id, verbosity = 0)
thread_id
character Required The ID of the thread the run belongs to.
run_id
character Required The ID of the run to retrieve.
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.)
The modified run object matching the specified ID.
create_tread()
Create a thread and run it in one request.
runs$create_tread(assistant_id, ..., verbosity = 0)
assistant_id
character Required The ID of the assistant to use to execute this run.
...
Additional parameters as required by the OpenAI API.
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.)
A run object.
steps_retrieve()
Retrieves a run step.
runs$steps_retrieve(thread_id, run_id, step_id, verbosity = 0)
thread_id
character Required. The ID of the thread to which the run and run step belongs.
run_id
character Required. The ID of the run the step belongs to.
step_id
character Required. The ID of the step to retrieve.
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.)
The run step object matching the specified ID.
steps_list()
Returns a list of run steps belonging to a run.
runs$steps_list(thread_id, run_id, ..., verbosity = 0)
thread_id
character Required The ID of the thread the run belongs to.
run_id
character Required The ID of the run the step belongs to.
...
Additional parameters as required by the OpenAI API.
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.)
A list of run step objects.
clone()
The objects of this class are cloneable with this method.
runs$clone(deep = FALSE)
deep
Whether to make a deep clone.
threads Class
threads Class
openaistream::openai
-> threads
create()
Create a thread.
threads$create(..., verbosity = 0)
...
Additional parameters as required by the OpenAI API.For example:messages;name;metadata
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.)
A thread object.
retrieve()
Retrieves a thread.
threads$retrieve(thread_id, verbosity = 0)
thread_id
character Required. The ID of the thread to retrieve.
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.)
The thread object matching the specified ID.
modify()
Modifies a thread.
threads$modify(thread_id, ..., verbosity = 0)
thread_id
The ID of the thread to modify. Only the metadata can be modified.
...
Additional parameters as required by the OpenAI API.For example:metadata
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.)
The modified thread object matching the specified ID.
delete()
Delete a thread.
threads$delete(thread_id, verbosity = 0)
thread_id
character Required The ID of the thread to delete.
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.)
Deletion status.
clone()
The objects of this class are cloneable with this method.
threads$clone(deep = FALSE)
deep
Whether to make a deep clone.