View Source ExOpenAI.Assistants (ex_openai.ex v1.7.0)
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.
Retrieves an assistant.
Returns a list of assistants.
Modifies an assistant.
Functions
@spec create_assistant( (:"gpt-3.5-turbo-16k-0613" | :"gpt-3.5-turbo-0125" | :"gpt-3.5-turbo-1106" | :"gpt-3.5-turbo-0613" | :"gpt-3.5-turbo-16k" | :"gpt-3.5-turbo" | :"gpt-4-32k-0613" | :"gpt-4-32k-0314" | :"gpt-4-32k" | :"gpt-4-0613" | :"gpt-4-0314" | :"gpt-4" | :"gpt-4-vision-preview" | :"gpt-4-1106-preview" | :"gpt-4-turbo-preview" | :"gpt-4-0125-preview" | :"gpt-4-turbo-2024-04-09" | :"gpt-4-turbo" | :"gpt-4o-2024-05-13" | :"gpt-4o") | String.t(), base_url: String.t(), openai_organization_key: String.t(), openai_api_key: String.t(), top_p: float(), tools: [map()], tool_resources: %{ code_interpreter: %{file_ids: [String.t()]}, file_search: %{ vector_store_ids: [String.t()], vector_stores: [ %{ chunking_strategy: %{ static: %{ chunk_overlap_tokens: integer(), max_chunk_size_tokens: integer() }, type: :static } | %{type: :auto}, file_ids: [String.t()], metadata: map() } ] } }, temperature: float(), response_format: ExOpenAI.Components.AssistantsApiResponseFormatOption.t(), name: String.t(), metadata: map(), instructions: 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.instructions
: The system instructions that the assistant uses. The maximum length is 256,000 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.response_format
:temperature
: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
Example: 1
tool_resources
: A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, thecode_interpreter
tool requires a list of file IDs, while thefile_search
tool requires a list of vector store IDs.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
,file_search
, orfunction
.top_p
: An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or temperature but not both.
Example: 1
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.base_url
: Which API endpoint to use as base, defaults to https://api.openai.com/v1
@spec delete_assistant(String.t(), base_url: 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.base_url
: Which API endpoint to use as base, defaults to https://api.openai.com/v1
@spec get_assistant(String.t(), base_url: 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.base_url
: Which API endpoint to use as base, defaults to https://api.openai.com/v1
@spec list_assistants( base_url: 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.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.base_url
: Which API endpoint to use as base, defaults to https://api.openai.com/v1
@spec modify_assistant(String.t(), base_url: String.t(), openai_organization_key: String.t(), openai_api_key: String.t(), top_p: float(), tools: [map()], tool_resources: %{ code_interpreter: %{file_ids: [String.t()]}, file_search: %{vector_store_ids: [String.t()]} }, temperature: float(), response_format: ExOpenAI.Components.AssistantsApiResponseFormatOption.t(), name: String.t(), model: String.t(), metadata: map(), instructions: 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.instructions
: The system instructions that the assistant uses. The maximum length is 256,000 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.response_format
:temperature
: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
Example: 1
tool_resources
: A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, thecode_interpreter
tool requires a list of file IDs, while thefile_search
tool requires a list of vector store IDs.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
,file_search
, orfunction
.top_p
: An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or temperature but not both.
Example: 1
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.base_url
: Which API endpoint to use as base, defaults to https://api.openai.com/v1