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
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/open_ai/chat_gpt.rb', line 17 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
39 40 41 42 43 |
# File 'lib/open_ai/chat_gpt.rb', line 39 def BotMessage.new( body: "Good for you!" ) end |
#first_user_message ⇒ Object
32 33 34 35 36 37 |
# File 'lib/open_ai/chat_gpt.rb', line 32 def Message.new( from: "@tyradee", body: "I drank some tea today." ) end |
#initial_messages ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/open_ai/chat_gpt.rb', line 45 def [ default_instruction, , ] end |
#new_thread(chat_id, model = nil) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/open_ai/chat_gpt.rb', line 10 def new_thread(chat_id, model = nil) model ||= config.open_ai["chat_gpt_model"].to_sym 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 |