Class: ChatgptAssistant::Config
- Inherits:
-
Object
- Object
- ChatgptAssistant::Config
- Defined in:
- lib/chatgpt_assistant/config.rb
Overview
This class is responsible for the configuration of the Chatgpt Assistant
Instance Attribute Summary collapse
-
#aws_access_key_id ⇒ Object
readonly
Returns the value of attribute aws_access_key_id.
-
#aws_region ⇒ Object
readonly
Returns the value of attribute aws_region.
-
#aws_secret_access_key ⇒ Object
readonly
Returns the value of attribute aws_secret_access_key.
-
#discord_client_id ⇒ Object
readonly
Returns the value of attribute discord_client_id.
-
#discord_prefix ⇒ Object
readonly
Returns the value of attribute discord_prefix.
-
#discord_public_key ⇒ Object
readonly
Returns the value of attribute discord_public_key.
-
#discord_token ⇒ Object
readonly
Returns the value of attribute discord_token.
-
#env_type ⇒ Object
readonly
Returns the value of attribute env_type.
-
#ibm_api_key ⇒ Object
readonly
Returns the value of attribute ibm_api_key.
-
#ibm_url ⇒ Object
readonly
Returns the value of attribute ibm_url.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#openai_api_key ⇒ Object
readonly
Returns the value of attribute openai_api_key.
-
#smtp_address ⇒ Object
readonly
Returns the value of attribute smtp_address.
-
#smtp_authentication ⇒ Object
readonly
Returns the value of attribute smtp_authentication.
-
#smtp_domain ⇒ Object
readonly
Returns the value of attribute smtp_domain.
-
#smtp_enable_starttls_auto ⇒ Object
readonly
Returns the value of attribute smtp_enable_starttls_auto.
-
#smtp_password ⇒ Object
readonly
Returns the value of attribute smtp_password.
-
#smtp_port ⇒ Object
readonly
Returns the value of attribute smtp_port.
-
#smtp_user_name ⇒ Object
readonly
Returns the value of attribute smtp_user_name.
-
#telegram_token ⇒ Object
readonly
Returns the value of attribute telegram_token.
Instance Method Summary collapse
- #create_db ⇒ Object
- #db_connection ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #migrate ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/chatgpt_assistant/config.rb', line 12 def initialize @env_type = ENV.fetch("ENV_TYPE", nil) @language = ENV.fetch("LANGUAGE", nil) @mode = ENV.fetch("MODE", nil) @database_host = ENV.fetch("POSTGRES_HOST", nil) @database_name = ENV.fetch("POSTGRES_DB", nil) @database_username = ENV.fetch("POSTGRES_USER", nil) @database_password = ENV.fetch("POSTGRES_PASSWORD", nil) @openai_api_key = ENV.fetch("OPENAI_API_KEY", nil) @telegram_token = ENV.fetch("TELEGRAM_TOKEN", nil) @discord_token = ENV.fetch("DISCORD_TOKEN", nil) @discord_client_id = ENV.fetch("DISCORD_CLIENT_ID", nil) @ibm_api_key = ENV.fetch("IBM_API_KEY", nil) @ibm_url = ENV.fetch("IBM_URL", nil) @aws_access_key_id = ENV.fetch("AWS_ACCESS_KEY_ID", nil) @aws_secret_access_key = ENV.fetch("AWS_SECRET_ACCESS_KEY", nil) @aws_region = ENV.fetch("AWS_REGION", nil) @discord_prefix = ENV.fetch("DISCORD_PREFIX", nil) end |
Instance Attribute Details
#aws_access_key_id ⇒ Object (readonly)
Returns the value of attribute aws_access_key_id.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def aws_access_key_id @aws_access_key_id end |
#aws_region ⇒ Object (readonly)
Returns the value of attribute aws_region.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def aws_region @aws_region end |
#aws_secret_access_key ⇒ Object (readonly)
Returns the value of attribute aws_secret_access_key.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def aws_secret_access_key @aws_secret_access_key end |
#discord_client_id ⇒ Object (readonly)
Returns the value of attribute discord_client_id.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def discord_client_id @discord_client_id end |
#discord_prefix ⇒ Object (readonly)
Returns the value of attribute discord_prefix.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def discord_prefix @discord_prefix end |
#discord_public_key ⇒ Object (readonly)
Returns the value of attribute discord_public_key.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def discord_public_key @discord_public_key end |
#discord_token ⇒ Object (readonly)
Returns the value of attribute discord_token.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def discord_token @discord_token end |
#env_type ⇒ Object (readonly)
Returns the value of attribute env_type.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def env_type @env_type end |
#ibm_api_key ⇒ Object (readonly)
Returns the value of attribute ibm_api_key.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def ibm_api_key @ibm_api_key end |
#ibm_url ⇒ Object (readonly)
Returns the value of attribute ibm_url.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def ibm_url @ibm_url end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def language @language end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def mode @mode end |
#openai_api_key ⇒ Object (readonly)
Returns the value of attribute openai_api_key.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def openai_api_key @openai_api_key end |
#smtp_address ⇒ Object (readonly)
Returns the value of attribute smtp_address.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def smtp_address @smtp_address end |
#smtp_authentication ⇒ Object (readonly)
Returns the value of attribute smtp_authentication.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def smtp_authentication @smtp_authentication end |
#smtp_domain ⇒ Object (readonly)
Returns the value of attribute smtp_domain.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def smtp_domain @smtp_domain end |
#smtp_enable_starttls_auto ⇒ Object (readonly)
Returns the value of attribute smtp_enable_starttls_auto.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def smtp_enable_starttls_auto @smtp_enable_starttls_auto end |
#smtp_password ⇒ Object (readonly)
Returns the value of attribute smtp_password.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def smtp_password @smtp_password end |
#smtp_port ⇒ Object (readonly)
Returns the value of attribute smtp_port.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def smtp_port @smtp_port end |
#smtp_user_name ⇒ Object (readonly)
Returns the value of attribute smtp_user_name.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def smtp_user_name @smtp_user_name end |
#telegram_token ⇒ Object (readonly)
Returns the value of attribute telegram_token.
32 33 34 |
# File 'lib/chatgpt_assistant/config.rb', line 32 def telegram_token @telegram_token end |
Instance Method Details
#create_db ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/chatgpt_assistant/config.rb', line 50 def create_db db_connection return if database_exists? ActiveRecord::Base.establish_connection( adapter: "postgresql", host: database_host, port: 5432, database: "postgres", username: database_username, password: database_password ) ActiveRecord::Base.logger = Logger.new($stdout) if ENV["ENV_TYPE"] == "development" ActiveRecord::Base.connection.create_database(database_name) end |
#db_connection ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/chatgpt_assistant/config.rb', line 38 def db_connection ActiveRecord::Base.establish_connection( adapter: "postgresql", host: database_host, port: 5432, database: database_name, username: database_username, password: database_password ) ActiveRecord::Base.logger = Logger.new($stdout) if ENV["ENV_TYPE"] == "development" end |
#migrate ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/chatgpt_assistant/config.rb', line 66 def migrate db_connection ActiveRecord::Base.logger = Logger.new($stdout) if ENV["ENV_TYPE"] == "development" VisitorMigration.new.migrate(:up) UserMigration.new.migrate(:up) ChatMigration.new.migrate(:up) MessageMigration.new.migrate(:up) ErrorMigration.new.migrate(:up) end |