Module: OpenAI::ChatGPT::ClassMethods
- Defined in:
- lib/open_ai/chat_gpt.rb
Instance Method Summary collapse
- #default_instruction ⇒ Object
- #first_bot_message ⇒ Object
- #first_user_message ⇒ Object
- #initial_messages ⇒ Object
- #new_thread(chat_id, model = nil) ⇒ Object
- #threads ⇒ Object
Instance Method Details
#default_instruction ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/open_ai/chat_gpt.rb', line 16 def default_instruction msg = <<~MSG You are in a group chat. In the first line of the message, you will receive the name of the user who sent that message. Do not sign your messages this way Do not use users' names without need (for example, if you are replying to @foo, do not add "@foo" to your message) You can still use names to mention other users you're not replying to directly. Different languages can be used. MSG SystemMessage.new( body: msg ) end |
#first_bot_message ⇒ Object
38 39 40 41 42 |
# File 'lib/open_ai/chat_gpt.rb', line 38 def BotMessage.new( body: "Good for you!" ) end |
#first_user_message ⇒ Object
31 32 33 34 35 36 |
# File 'lib/open_ai/chat_gpt.rb', line 31 def Message.new( from: "@tyradee", body: "I drank some tea today." ) end |
#initial_messages ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/open_ai/chat_gpt.rb', line 44 def [ default_instruction, , ] end |
#new_thread(chat_id, model = nil) ⇒ Object
10 11 12 13 14 |
# File 'lib/open_ai/chat_gpt.rb', line 10 def new_thread(chat_id, model = nil) msgs = config.open_ai["whitelist"].include?(chat_id) ? : [] new_thread = ChatThread.new(msgs, model) threads[chat_id] = new_thread end |
#threads ⇒ Object
6 7 8 |
# File 'lib/open_ai/chat_gpt.rb', line 6 def threads @threads ||= {} end |