open_ai_bot 0.2.6 → 0.2.7

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: bb11aa4fa04faff58bebc78dd9f5b7205bd7d096e0be1ea1260f44d62eaaf279
4
- data.tar.gz: 79df08164999f67aa37cd1dff5d73d090d9665a38292923c43d9096805275e6c
3
+ metadata.gz: e7d7c3932e590fd3886be9afca2d8a816a61cd897f0d74154d31fc68708bc480
4
+ data.tar.gz: 8473ae837951bab8a8a8b0617ba53445e2098a601d97166e36dc31c8f5287e0f
5
5
  SHA512:
6
- metadata.gz: 4bb4fec967f3d6a1ed50040cac94db80f7fff03740b29ffc07038f1f4de184f95754ce4bc6e159395ee825c71fadeb2a17605b44addbf1b3ba66caa9014e744d
7
- data.tar.gz: 8162ea6493434c0770e4e3aafa91e017fb58a92b4eaaa93fd6feb30f269f18bc223ef80029f44db572d356743f8af9a317956781d845b18b7bd556d7ebf9e9a1
6
+ metadata.gz: 1c8cf3ea9587a13bb85fcdfa42bd10c879aee53e117c036964e3e65d9f922cc60589e80373d6555672df5fd6a10fa3bd39958ae400a2e26d2002f435c0294bf0
7
+ data.tar.gz: 32eb2f96a3d0a773dd809485caa889c3c03f6438989cf8188c0d1a3f2555b69d9c3c129788cff72f87d1340bb414fcf0afbd689317d5148623029516e429b5e1
@@ -7,8 +7,9 @@ module OpenAI
7
7
  @threads ||= {}
8
8
  end
9
9
 
10
- def new_thread(chat_id)
11
- new_thread = ChatThread.new(initial_messages)
10
+ def new_thread(chat_id, model = nil)
11
+ msgs = config.open_at.whitelist.include?(chat_id) ? initial_messages :
12
+ new_thread = ChatThread.new(msgs, model)
12
13
  threads[chat_id] = new_thread
13
14
  end
14
15
 
@@ -56,12 +57,13 @@ module OpenAI
56
57
  end
57
58
  end
58
59
 
60
+
59
61
  def self.included(base)
60
62
  base.extend ClassMethods
61
63
  end
62
64
 
63
65
  def init_session
64
- self.class.new_thread(@chat.id)
66
+ self.class.new_thread(@chat.id, model)
65
67
  send_message(session_restart_message)
66
68
  end
67
69
 
@@ -120,7 +122,7 @@ module OpenAI
120
122
 
121
123
  response = open_ai.chat(
122
124
  parameters: {
123
- model: config.open_ai["chat_gpt_model"],
125
+ model: current_thread.model || config.open_ai["chat_gpt_model"],
124
126
  messages: current_thread.as_json
125
127
  }
126
128
  )
@@ -2,12 +2,14 @@
2
2
 
3
3
  module OpenAI
4
4
  class ChatThread
5
- def initialize(defaults = [])
5
+ def initialize(defaults = [], model = nil)
6
6
  @history ||= defaults
7
+ @model = model
7
8
  puts @history
8
9
  end
9
10
 
10
11
  attr_reader :history
12
+ attr_reader :model
11
13
 
12
14
  alias_method :messages, :history
13
15
 
data/open_ai_bot.gemspec CHANGED
@@ -8,7 +8,7 @@ require_relative "lib/ext/in"
8
8
 
9
9
  Gem::Specification.new do |spec|
10
10
  spec.name = "open_ai_bot"
11
- spec.version = "0.2.6"
11
+ spec.version = "0.2.7"
12
12
  spec.authors = ["bulgakke"]
13
13
  spec.email = ["vvp835@yandex.ru"]
14
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_ai_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - bulgakke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-24 00:00:00.000000000 Z
11
+ date: 2023-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: down