Class: LightTr::ChatGpt
- Inherits:
-
Object
- Object
- LightTr::ChatGpt
- Defined in:
- lib/light_tr/chat_gpt.rb
Constant Summary collapse
- SUPPORTED_LANGUAGES_MAP =
rubocop:disable Layout/LineLength
{ 'af' => 'Afrikaans', 'ga' => 'Irish', 'sq' => 'Albanian', 'it' => 'Italian', 'ar' => 'Arabic', 'ja' => 'Japanese', 'az' => 'Azerbaijani', 'kn' => 'Kannada', 'eu' => 'Basque', 'ko' => 'Korean', 'bn' => 'Bengali', 'la' => 'Latin', 'be' => 'Belarusian', 'lv' => 'Latvian', 'bg' => 'Bulgarian', 'lt' => 'Lithuanian', 'ca' => 'Catalan', 'mk' => 'Macedonian', 'ms' => 'Malay', 'mt' => 'Maltese', 'hr' => 'Croatian', 'no' => 'Norwegian', 'cs' => 'Czech', 'fa' => 'Persian', 'da' => 'Danish', 'pl' => 'Polish', 'nl' => 'Dutch', 'pt' => 'Portuguese', 'en' => 'English', 'ro' => 'Romanian', 'eo' => 'Esperanto', 'ru' => 'Russian', 'et' => 'Estonian', 'sr' => 'Serbian', 'tl' => 'Filipino', 'sk' => 'Slovak', 'fi' => 'Finnish', 'sl' => 'Slovenian', 'fr' => 'French', 'es' => 'Spanish', 'gl' => 'Galician', 'sw' => 'Swahili', 'ka' => 'Georgian', 'sv' => 'Swedish', 'de' => 'German', 'ta' => 'Tamil', 'el' => 'Greek', 'te' => 'Telugu', 'gu' => 'Gujarati', 'th' => 'Thai', 'ht' => 'Haitian Creole', 'tr' => 'Turkish', 'iw' => 'Hebrew', 'uk' => 'Ukrainian', 'hi' => 'Hindi', 'ur' => 'Urdu', 'hu' => 'Hungarian', 'vi' => 'Vietnamese', 'is' => 'Icelandic', 'cy' => 'Welsh', 'id' => 'Indonesian', 'yi' => 'Yiddish', 'zh-CN' => 'Chinese (Simplified)', 'zh-TW' => 'Chinese (Traditional)' }.freeze
Instance Method Summary collapse
-
#initialize(api_key, model = 'gpt-3.5-turbo') ⇒ ChatGpt
constructor
A new instance of ChatGpt.
- #models ⇒ Object
- #translate(query, languages) ⇒ Object
Constructor Details
#initialize(api_key, model = 'gpt-3.5-turbo') ⇒ ChatGpt
Returns a new instance of ChatGpt.
10 11 12 13 |
# File 'lib/light_tr/chat_gpt.rb', line 10 def initialize(api_key, model = 'gpt-3.5-turbo') @api_key = api_key @model = model end |
Instance Method Details
#models ⇒ Object
19 20 21 |
# File 'lib/light_tr/chat_gpt.rb', line 19 def models @models ||= client.get('models').body.data.map(&:id).select { |id| id.include?('gpt') } end |
#translate(query, languages) ⇒ Object
15 16 17 |
# File 'lib/light_tr/chat_gpt.rb', line 15 def translate(query, languages) completion(query, languages) end |