Class: Richat::Cli
- Inherits:
-
Object
- Object
- Richat::Cli
- Defined in:
- lib/richat/cli.rb
Instance Attribute Summary collapse
-
#chat_client ⇒ Object
readonly
Returns the value of attribute chat_client.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#user_content ⇒ Object
readonly
Returns the value of attribute user_content.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(options = {}) ⇒ Cli
constructor
A new instance of Cli.
Constructor Details
#initialize(options = {}) ⇒ Cli
Returns a new instance of Cli.
5 6 7 8 9 |
# File 'lib/richat/cli.rb', line 5 def initialize( = {}) @chat_client = [:chat_client] @logger = [:logger] @user_content = [:user_content] end |
Instance Attribute Details
#chat_client ⇒ Object (readonly)
Returns the value of attribute chat_client.
3 4 5 |
# File 'lib/richat/cli.rb', line 3 def chat_client @chat_client end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
3 4 5 |
# File 'lib/richat/cli.rb', line 3 def logger @logger end |
#user_content ⇒ Object (readonly)
Returns the value of attribute user_content.
3 4 5 |
# File 'lib/richat/cli.rb', line 3 def user_content @user_content end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/richat/cli.rb', line 11 def call logger.call(role: Config.get("log", "user_role"), content: user_content) response = chat_client.call([{ role: 'user', content: user_content }]) if !response.nil? && !response.empty? logger.call(role: Config.get("log", "ai_role"), content: response) puts response end end |