open_ai_bot 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/open_ai/chat_gpt.rb +6 -4
- data/lib/open_ai/chat_thread.rb +3 -1
- data/open_ai_bot.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7d7c3932e590fd3886be9afca2d8a816a61cd897f0d74154d31fc68708bc480
|
4
|
+
data.tar.gz: 8473ae837951bab8a8a8b0617ba53445e2098a601d97166e36dc31c8f5287e0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c8cf3ea9587a13bb85fcdfa42bd10c879aee53e117c036964e3e65d9f922cc60589e80373d6555672df5fd6a10fa3bd39958ae400a2e26d2002f435c0294bf0
|
7
|
+
data.tar.gz: 32eb2f96a3d0a773dd809485caa889c3c03f6438989cf8188c0d1a3f2555b69d9c3c129788cff72f87d1340bb414fcf0afbd689317d5148623029516e429b5e1
|
data/lib/open_ai/chat_gpt.rb
CHANGED
@@ -7,8 +7,9 @@ module OpenAI
|
|
7
7
|
@threads ||= {}
|
8
8
|
end
|
9
9
|
|
10
|
-
def new_thread(chat_id)
|
11
|
-
|
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
|
)
|
data/lib/open_ai/chat_thread.rb
CHANGED
@@ -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
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.
|
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-
|
11
|
+
date: 2023-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: down
|