open_ai_bot 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 359180ac972111694562d94a4afccd3e90299f08abbfa13d36a05c765af8f6e5
4
- data.tar.gz: 43d9f020391a4166cade19e015d9de007c1a10e9ccce01826779244b350a2a5c
3
+ metadata.gz: 30c76c2d4d679490aeec769f27b4a94411d10457b9671635bac4155137159c4e
4
+ data.tar.gz: da3ecae84c2ae4edd70e763e0ee4934e081bbd50332939c08252d507f69b1b90
5
5
  SHA512:
6
- metadata.gz: fdf1dfdab85f011e4268fdfa29fe204ab40e88b907df142867b7c888ea9450a5eb0c87cc47f39dae8b77a479fba19b8bbf732447771d07ef37016c426491fec2
7
- data.tar.gz: b1e0759c526c80a8b0edd401e23c0326bc779906c1f660c01ed0ed736332c6c0304dfcfd5270e67884aaf38db4e4c8bb3243341dfb548089fbcfa231e684f063
6
+ metadata.gz: 7ef87f990db2fff4d8d679e127a181ffc957dbdd7c9c995aec2bf489d61973d4a2d8acd3f161bcdedb3277cf841e24451d551989cfecaec83a4e7a49ace62f75
7
+ data.tar.gz: ad732c08a12433986d7a2214c3f9cdcaf8704d555960a8ace5bc8c82f835276b216157394d215b38ec3e5426cd11c6273cc416f5a9ad055eba708380d1161421
data/README.md CHANGED
@@ -44,7 +44,7 @@ echo 'ruby 3.2.2' >> ~/.tool-versions
44
44
 
45
45
  2. Require this project as a dependency:
46
46
  - Create a new Ruby project
47
- - In the Gemfile, add `gem "open_ai_bot", github: "bulgakke/open_ai_bot", branch: "main"`
47
+ - In the Gemfile, add `gem "open_ai_bot"`
48
48
  - Inherit your bot class from `OpenAIBot`
49
49
 
50
50
  ## Run
@@ -98,17 +98,25 @@ module ChatGPT
98
98
  if response["error"]
99
99
  error_text = "```#{response["error"]["message"]}```"
100
100
  error_text += "\n\nHint: send /restart command to reset the context." if error_text.match? "tokens"
101
- reply(error_text.strip, parse_mode: "Markdown")
101
+ send_chat_gpt_error(error_text.strip)
102
102
  else
103
103
  text = response.dig("choices", 0, "message", "content")
104
104
  puts "#{Time.now.utc} | Chat ID: #{@chat.id}, tokens used: #{response.dig("usage", "total_tokens")}"
105
105
 
106
- reply(text)
107
- @thread.add!(:assistant, text)
106
+ send_chat_gpt_response(text)
108
107
  end
109
108
  end
110
109
  end
111
110
 
111
+ def send_chat_gpt_error(text)
112
+ reply(text, parse_mode: "Markdown")
113
+ end
114
+
115
+ def send_chat_gpt_response(text)
116
+ reply(text)
117
+ @thread.add!(:assistant, text)
118
+ end
119
+
112
120
  def add_name(name, text)
113
121
  return "" if text.nil? || text.empty?
114
122
 
@@ -26,15 +26,23 @@ module Whisper
26
26
  response = send_whisper_request(file[:file])
27
27
 
28
28
  if response["error"]
29
- reply_code(response["error"])
29
+ send_whisper_error(response["error"])
30
30
  else
31
- reply(response["text"])
31
+ send_whisper_response(response["text"])
32
32
  end
33
33
  ensure
34
34
  FileUtils.rm_rf(file[:names]) if file
35
35
  end
36
36
  end
37
37
 
38
+ def send_whisper_response(text)
39
+ reply(text)
40
+ end
41
+
42
+ def send_whisper_error
43
+ reply_code(text)
44
+ end
45
+
38
46
  def ogg_to_mp3(file)
39
47
  ogg = file.original_filename
40
48
  mp3 = ogg.sub(/og.\z/, "mp3")
data/open_ai_bot.gemspec CHANGED
@@ -5,7 +5,7 @@ require_relative "lib/open_ai_bot"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "open_ai_bot"
8
- spec.version = "0.1.0"
8
+ spec.version = "0.2.1"
9
9
  spec.authors = ["bulgakke"]
10
10
  spec.email = ["vvp835@yandex.ru"]
11
11
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_ai_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - bulgakke