View Source ExOpenAI.Assistants (ex_openai.ex v1.8.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(ExOpenAI.Components.AssistantSupportedModels.t() | 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: ExOpenAI.Components.Metadata.t() } ] } }, temperature: float(), response_format: ExOpenAI.Components.AssistantsApiResponseFormatOption.t(), reasoning_effort: ExOpenAI.Components.ReasoningEffort.t(), name: String.t(), metadata: ExOpenAI.Components.Metadata.t(), 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 to"description
: "The description of the assistant. The maximum length is 512 characters.\n"instructions
: "The system instructions that the assistant uses. The maximum length is 256,000 characters.\n"metadata
: ""name
: "The name of the assistant. The maximum length is 256 characters.\n"reasoning_effort
: ""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.\n"
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.\n"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
.\n"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.\n\nWe generally recommend altering this or temperature but not both.\n"
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 to"limit
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() ) :: {: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:
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"