View Source ExOpenAI.Assistants (ex_openai.ex v1.5.1)
Modules for interacting with the assistants
group of OpenAI APIs
API Reference: https://platform.openai.com/docs/api-reference/assistants
Summary
Functions
Create an assistant with a model and instructions.
Delete an assistant.
Delete an assistant file.
Retrieves an assistant.
Retrieves an AssistantFile.
Returns a list of assistant files.
Returns a list of assistants.
Modifies an assistant.
Functions
@spec create_assistant(String.t(), openai_organization_key: String.t(), openai_api_key: String.t(), tools: [map()], name: String.t(), metadata: map(), instructions: String.t(), file_ids: [String.t()], description: String.t(), stream_to: (... -> any()) | pid() ) :: {:ok, ExOpenAI.Components.AssistantObject.t()} | {:error, any()}
Create an assistant with a model and instructions.
Endpoint: https://api.openai.com/v1/assistants
Method: POST
Docs: https://platform.openai.com/docs/api-reference/assistants
Required Arguments:
model
: 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.
Optional Arguments:
stream_to
: PID or function of where to stream content todescription
: The description of the assistant. The maximum length is 512 characters.file_ids
: A list of file IDs attached to this assistant. There can be a maximum of 20 files attached to the assistant. Files are ordered by their creation date in ascending order.instructions
: The system instructions that the assistant uses. The maximum length is 32768 characters.metadata
: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.name
: The name of the assistant. The maximum length is 256 characters.tools
: A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of typescode_interpreter
,retrieval
, orfunction
.openai_api_key
: OpenAI API key to pass directly. If this is specified, it will override theapi_key
config value.openai_organization_key
: OpenAI API key to pass directly. If this is specified, it will override theorganization_key
config value.
@spec create_assistant_file(String.t(), String.t(), openai_organization_key: String.t(), openai_api_key: String.t() ) :: {:ok, ExOpenAI.Components.AssistantFileObject.t()} | {:error, any()}
Create an assistant file by attaching a File to an assistant.
Endpoint: https://api.openai.com/v1/assistants/{assistant_id}/files
Method: POST
Docs: https://platform.openai.com/docs/api-reference/assistants
Required Arguments:
assistant_id
Example: file-AF1WoRqd3aJAHsqc9NY7iL8F
file_id
: A File ID (withpurpose="assistants"
) that the assistant should use. Useful for tools likeretrieval
andcode_interpreter
that can access files.
Optional Arguments:
openai_api_key
: OpenAI API key to pass directly. If this is specified, it will override theapi_key
config value.openai_organization_key
: OpenAI API key to pass directly. If this is specified, it will override theorganization_key
config value.
@spec delete_assistant(String.t(), openai_organization_key: String.t(), openai_api_key: String.t() ) :: {:ok, ExOpenAI.Components.DeleteAssistantResponse.t()} | {:error, any()}
Delete an assistant.
Endpoint: https://api.openai.com/v1/assistants/{assistant_id}
Method: DELETE
Docs: https://platform.openai.com/docs/api-reference/assistants
Required Arguments:
assistant_id
Optional Arguments:
openai_api_key
: OpenAI API key to pass directly. If this is specified, it will override theapi_key
config value.openai_organization_key
: OpenAI API key to pass directly. If this is specified, it will override theorganization_key
config value.
@spec delete_assistant_file(String.t(), String.t(), openai_organization_key: String.t(), openai_api_key: String.t() ) :: {:ok, ExOpenAI.Components.DeleteAssistantFileResponse.t()} | {:error, any()}
Delete an assistant file.
Endpoint: https://api.openai.com/v1/assistants/{assistant_id}/files/{file_id}
Method: DELETE
Docs: https://platform.openai.com/docs/api-reference/assistants
Required Arguments:
assistant_id
file_id
Optional Arguments:
openai_api_key
: OpenAI API key to pass directly. If this is specified, it will override theapi_key
config value.openai_organization_key
: OpenAI API key to pass directly. If this is specified, it will override theorganization_key
config value.
@spec get_assistant(String.t(), openai_organization_key: String.t(), openai_api_key: String.t() ) :: {:ok, ExOpenAI.Components.AssistantObject.t()} | {:error, any()}
Retrieves an assistant.
Endpoint: https://api.openai.com/v1/assistants/{assistant_id}
Method: GET
Docs: https://platform.openai.com/docs/api-reference/assistants
Required Arguments:
assistant_id
Optional Arguments:
openai_api_key
: OpenAI API key to pass directly. If this is specified, it will override theapi_key
config value.openai_organization_key
: OpenAI API key to pass directly. If this is specified, it will override theorganization_key
config value.
@spec get_assistant_file(String.t(), String.t(), openai_organization_key: String.t(), openai_api_key: String.t() ) :: {:ok, ExOpenAI.Components.AssistantFileObject.t()} | {:error, any()}
Retrieves an AssistantFile.
Endpoint: https://api.openai.com/v1/assistants/{assistant_id}/files/{file_id}
Method: GET
Docs: https://platform.openai.com/docs/api-reference/assistants
Required Arguments:
assistant_id
file_id
Optional Arguments:
openai_api_key
: OpenAI API key to pass directly. If this is specified, it will override theapi_key
config value.openai_organization_key
: OpenAI API key to pass directly. If this is specified, it will override theorganization_key
config value.
@spec list_assistant_files(String.t(), openai_organization_key: String.t(), openai_api_key: String.t(), before: String.t(), after: String.t(), order: String.t(), limit: integer(), stream_to: (... -> any()) | pid() ) :: {:ok, ExOpenAI.Components.ListAssistantFilesResponse.t()} | {:error, any()}
Returns a list of assistant files.
Endpoint: https://api.openai.com/v1/assistants/{assistant_id}/files
Method: GET
Docs: https://platform.openai.com/docs/api-reference/assistants
Required Arguments:
assistant_id
Optional Arguments:
stream_to
: PID or function of where to stream content tolimit
order
after
before
openai_api_key
: OpenAI API key to pass directly. If this is specified, it will override theapi_key
config value.openai_organization_key
: OpenAI API key to pass directly. If this is specified, it will override theorganization_key
config value.
@spec list_assistants( openai_organization_key: String.t(), openai_api_key: String.t(), before: String.t(), after: String.t(), order: String.t(), limit: integer(), stream_to: (... -> any()) | pid() ) :: {:ok, ExOpenAI.Components.ListAssistantsResponse.t()} | {:error, any()}
Returns a list of assistants.
Endpoint: https://api.openai.com/v1/assistants
Method: GET
Docs: https://platform.openai.com/docs/api-reference/assistants
Required Arguments:
Optional Arguments:
stream_to
: PID or function of where to stream content tolimit
order
after
before
openai_api_key
: OpenAI API key to pass directly. If this is specified, it will override theapi_key
config value.openai_organization_key
: OpenAI API key to pass directly. If this is specified, it will override theorganization_key
config value.
@spec modify_assistant(String.t(), openai_organization_key: String.t(), openai_api_key: String.t(), tools: [map()], name: String.t(), model: String.t(), metadata: map(), instructions: String.t(), file_ids: [String.t()], description: String.t(), stream_to: (... -> any()) | pid() ) :: {:ok, ExOpenAI.Components.AssistantObject.t()} | {:error, any()}
Modifies an assistant.
Endpoint: https://api.openai.com/v1/assistants/{assistant_id}
Method: POST
Docs: https://platform.openai.com/docs/api-reference/assistants
Required Arguments:
assistant_id
Optional Arguments:
stream_to
: PID or function of where to stream content todescription
: The description of the assistant. The maximum length is 512 characters.file_ids
: A list of File IDs attached to this assistant. There can be a maximum of 20 files attached to the assistant. Files are ordered by their creation date in ascending order. If a file was previosuly attached to the list but does not show up in the list, it will be deleted from the assistant.instructions
: The system instructions that the assistant uses. The maximum length is 32768 characters.metadata
: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.model
: 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.name
: The name of the assistant. The maximum length is 256 characters.tools
: A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of typescode_interpreter
,retrieval
, orfunction
.openai_api_key
: OpenAI API key to pass directly. If this is specified, it will override theapi_key
config value.openai_organization_key
: OpenAI API key to pass directly. If this is specified, it will override theorganization_key
config value.