Class: Ruboty::OpenAIChat::Actions::Base
Abstract
- Inherits:
-
Object
- Object
- Ruboty::OpenAIChat::Actions::Base
show all
- Defined in:
- lib/ruboty/openai_chat/actions/base.rb
Overview
Constant Summary
collapse
- NAMESPACE =
"openai-chat-actions-chat"
- PROFILE_KEY =
"profile"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(message) ⇒ Base
Returns a new instance of Base.
14
15
16
|
# File 'lib/ruboty/openai_chat/actions/base.rb', line 14
def initialize(message)
@message = message
end
|
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
11
12
13
|
# File 'lib/ruboty/openai_chat/actions/base.rb', line 11
def message
@message
end
|
Instance Method Details
#client ⇒ OpenAI::Client
19
20
21
22
|
# File 'lib/ruboty/openai_chat/actions/base.rb', line 19
def client
@client ||= OpenAI::Client.new(access_token: ENV.fetch("OPENAI_ACCESS_TOKEN"),
organization_id: ENV.fetch("OPENAI_ORGANIZATION_ID"))
end
|
30
31
32
|
# File 'lib/ruboty/openai_chat/actions/base.rb', line 30
def memory
@memory ||= Memory.new(robot)
end
|
#openai_model ⇒ String
40
41
42
|
# File 'lib/ruboty/openai_chat/actions/base.rb', line 40
def openai_model
ENV["OPENAI_CHAT_MODEL"] || "gpt-3.5-turbo"
end
|
#pretexts ⇒ Array<String>
35
36
37
|
# File 'lib/ruboty/openai_chat/actions/base.rb', line 35
def pretexts
[ENV["OPENAI_CHAT_PRETEXT"], memory.namespace(NAMESPACE)[PROFILE_KEY]].compact
end
|
#robot ⇒ Ruboty::Robot
25
26
27
|
# File 'lib/ruboty/openai_chat/actions/base.rb', line 25
def robot
message.robot
end
|