Class: AI::Engine::AssistantThread

Inherits:
ApplicationRecord show all
Includes:
RemoteIdValidatable
Defined in:
app/models/ai/engine/assistant_thread.rb

Constant Summary

Constants included from RemoteIdValidatable

RemoteIdValidatable::REMOTE_ID_PREFIXES

Instance Method Summary collapse

Instance Method Details

#run(assistant_id:, content:) ⇒ Object



12
13
14
15
16
17
18
# File 'app/models/ai/engine/assistant_thread.rb', line 12

def run(assistant_id:, content:)
  # Create the request Message, locally and remotely on OpenAI.
  AI::Engine::Message.create(messageable: self, content: content, role: "user")

  # Run the Thread using the selected Assistant.
  runs.create(ai_engine_assistant_id: assistant_id)
end

#to_partial_pathObject



20
21
22
# File 'app/models/ai/engine/assistant_thread.rb', line 20

def to_partial_path
  "assistant_threads/assistant_thread"
end