Class: OpenAI::AssistantClient
- Defined in:
- lib/openai/assistant_client.rb
Instance Method Summary collapse
-
#get_assistant_by_id(assistant_id) ⇒ Object
Get assistant details by assistant_id.
-
#get_list_assistants(limit = 20, order = SortOrder::ASC, after = nil, before = nil) ⇒ Object
Get list assistants.
-
#get_list_messages_by_thread_id(thread_id, limit = 20, order = SortOrder::DESC, after = nil, before = nil, run_id = nil) ⇒ Object
Returns a list of messages for a given thread.
-
#get_run_status_by_thead_id_and_run_id(thread_id, run_id) ⇒ Object
Retrieves a run status by thread_id and run_id.
-
#initialize(api_key) ⇒ AssistantClient
constructor
A new instance of AssistantClient.
Constructor Details
#initialize(api_key) ⇒ AssistantClient
Returns a new instance of AssistantClient.
10 11 12 |
# File 'lib/openai/assistant_client.rb', line 10 def initialize(api_key) @api_key = api_key end |
Instance Method Details
#get_assistant_by_id(assistant_id) ⇒ Object
Get assistant details by assistant_id
31 32 33 34 |
# File 'lib/openai/assistant_client.rb', line 31 def get_assistant_by_id(assistant_id) api_response = call_get("/assistants/#{assistant_id}") Model::Assistant.new(api_response) end |
#get_list_assistants(limit = 20, order = SortOrder::ASC, after = nil, before = nil) ⇒ Object
Get list assistants
21 22 23 24 25 26 |
# File 'lib/openai/assistant_client.rb', line 21 def get_list_assistants(limit = 20, order = SortOrder::ASC, after = nil, before = nil) api_response = call_get('/assistants', { 'limit' => limit, 'order' => order, 'after' => after, 'before' => before }.select { |_,v| !v.nil? }) Model::ListAssistants.new(api_response) end |
#get_list_messages_by_thread_id(thread_id, limit = 20, order = SortOrder::DESC, after = nil, before = nil, run_id = nil) ⇒ Object
Returns a list of messages for a given thread.
53 54 55 56 57 58 |
# File 'lib/openai/assistant_client.rb', line 53 def (thread_id, limit = 20, order = SortOrder::DESC, after = nil, before = nil, run_id = nil) api_response = call_get("/threads/#{thread_id}/messages", { 'limit' => limit, 'order' => order, 'after' => after, 'before' => before, 'run_id' => run_id }.select { |_,v| !v.nil? }) Model::ListMessages.new(api_response) end |
#get_run_status_by_thead_id_and_run_id(thread_id, run_id) ⇒ Object
Retrieves a run status by thread_id and run_id
40 41 42 43 |
# File 'lib/openai/assistant_client.rb', line 40 def get_run_status_by_thead_id_and_run_id(thread_id, run_id) api_response = call_get("/threads/#{thread_id}/runs/#{run_id}") Model::Run.new(api_response) end |