monadic-chat 0.4.1 → 0.4.3

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: 9d44ae83c28ccafde3e3b2ea1d486730c2dbf5ff3cc7193dc4c25c97f6a46fbb
4
- data.tar.gz: f69a30f93b4777b70d078b007c3342e212d3deb4bf2cf92d782fb6af6b825f07
3
+ metadata.gz: b82fdd0aca3e154e238309f1e76468c6c7e48c45a2406386c11adf12397e279d
4
+ data.tar.gz: 3411bcfbfc03f740746d923b00d488cd89eb4667a536163e9542b30a268864d1
5
5
  SHA512:
6
- metadata.gz: 31a241cff282c2e98eed745e4e32612dc018793832c38dddd79614479fd8b816a1c94be7ff16dc16b73858eb883d2da42b81109ed3d94e253a7e473526533386
7
- data.tar.gz: eddd1596523564ac1f066b93c762d13b44515990ba1e479b74f6b51cf94e8fc840d45d45763757264a0c1dde21beac1b68c3652a2baf8a08ab6f306e64a818e9
6
+ metadata.gz: c348023d61cd2899b2aa684cd26c999d85d67145cad4ef7d6dab98b07789cac0f9702eb6ec9601daf3cce59e4f9288a3c96bb7453caab3f878cd4d2fbde4f0f2
7
+ data.tar.gz: 85491c0aff6147b130998c73ce699f049784be9c14c26553119b2f19b98e3a1af0c4f8a0c846817b29c7f2a17de57130ed760431e3db3d6de089042f9cd8ca8b
data/CHANGELOG.md CHANGED
@@ -51,3 +51,12 @@
51
51
 
52
52
  - New models of January 2024 supported
53
53
  - Default model changed to `gpt-4`
54
+
55
+ ## [0.4.2] - 2024-02-09
56
+
57
+ - Issue of redundant token addition addressed
58
+ - Default model changed to `gpt-3.5-turbo-0125`
59
+
60
+ ## [0.4.3] - 2024-5-13
61
+
62
+ - `gpt-4o` set as default model for both `normal` and `research` modes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- monadic-chat (0.4.0)
4
+ monadic-chat (0.4.3)
5
5
  blingfire
6
6
  http
7
7
  kramdown
@@ -20,51 +20,56 @@ PATH
20
20
  GEM
21
21
  remote: https://rubygems.org/
22
22
  specs:
23
- addressable (2.8.5)
23
+ addressable (2.8.6)
24
24
  public_suffix (>= 2.0.2, < 6.0)
25
- blingfire (0.2.0)
26
- diff-lcs (1.5.0)
27
- domain_name (0.5.20190701)
28
- unf (>= 0.0.5, < 1.0.0)
25
+ base64 (0.2.0)
26
+ bigdecimal (3.1.8)
27
+ blingfire (0.2.1)
28
+ childprocess (5.0.0)
29
+ diff-lcs (1.5.1)
30
+ domain_name (0.6.20240107)
29
31
  ffi (1.16.3)
30
- ffi-compiler (1.0.1)
31
- ffi (>= 1.0.0)
32
+ ffi-compiler (1.3.2)
33
+ ffi (>= 1.15.5)
32
34
  rake
33
- http (5.1.1)
35
+ http (5.2.0)
34
36
  addressable (~> 2.8)
37
+ base64 (~> 0.1)
35
38
  http-cookie (~> 1.0)
36
39
  http-form_data (~> 2.2)
37
- llhttp-ffi (~> 0.4.0)
40
+ llhttp-ffi (~> 0.5.0)
38
41
  http-cookie (1.0.5)
39
42
  domain_name (~> 0.5)
40
43
  http-form_data (2.3.0)
41
44
  kramdown (2.4.0)
42
45
  rexml
43
- launchy (2.5.2)
46
+ launchy (3.0.1)
44
47
  addressable (~> 2.8)
45
- llhttp-ffi (0.4.0)
48
+ childprocess (~> 5.0)
49
+ llhttp-ffi (0.5.0)
46
50
  ffi-compiler (~> 1.0)
47
51
  rake (~> 13.0)
48
- oj (3.16.1)
52
+ oj (3.16.3)
53
+ bigdecimal (>= 3.0)
49
54
  pastel (0.8.0)
50
55
  tty-color (~> 0.5)
51
- public_suffix (5.0.3)
52
- rake (13.0.6)
56
+ public_suffix (5.0.5)
57
+ rake (13.2.1)
53
58
  rexml (3.2.6)
54
- rouge (4.1.3)
55
- rspec (3.12.0)
56
- rspec-core (~> 3.12.0)
57
- rspec-expectations (~> 3.12.0)
58
- rspec-mocks (~> 3.12.0)
59
- rspec-core (3.12.2)
60
- rspec-support (~> 3.12.0)
61
- rspec-expectations (3.12.3)
59
+ rouge (4.2.1)
60
+ rspec (3.13.0)
61
+ rspec-core (~> 3.13.0)
62
+ rspec-expectations (~> 3.13.0)
63
+ rspec-mocks (~> 3.13.0)
64
+ rspec-core (3.13.0)
65
+ rspec-support (~> 3.13.0)
66
+ rspec-expectations (3.13.0)
62
67
  diff-lcs (>= 1.2.0, < 2.0)
63
- rspec-support (~> 3.12.0)
64
- rspec-mocks (3.12.6)
68
+ rspec-support (~> 3.13.0)
69
+ rspec-mocks (3.13.1)
65
70
  diff-lcs (>= 1.2.0, < 2.0)
66
- rspec-support (~> 3.12.0)
67
- rspec-support (3.12.1)
71
+ rspec-support (~> 3.13.0)
72
+ rspec-support (3.13.1)
68
73
  strings (0.2.1)
69
74
  strings-ansi (~> 0.2)
70
75
  unicode-display_width (>= 1.5, < 3.0)
@@ -95,12 +100,9 @@ GEM
95
100
  tty-cursor (~> 0.7)
96
101
  tty-screen (~> 0.8)
97
102
  wisper (~> 2.0)
98
- tty-screen (0.8.1)
103
+ tty-screen (0.8.2)
99
104
  tty-spinner (0.9.3)
100
105
  tty-cursor (~> 0.7)
101
- unf (0.1.4)
102
- unf_ext
103
- unf_ext (0.0.8.2)
104
106
  unicode-display_width (2.5.0)
105
107
  unicode_utils (1.4.0)
106
108
  wisper (2.0.1)
data/README.md CHANGED
@@ -27,6 +27,8 @@
27
27
 
28
28
  **Change Log**
29
29
 
30
+ - [May 13, 2024] `gpt-4o` set as the default model for both `normal` and `research` modes
31
+ - [February 9, 2024] Minor update; default model changed to `gpt-3.5-turbo-0125`
30
32
  - [November 10, 2023] Stability improvement; default model changed to `gpt-3.5-turbo`
31
33
  - [October 07, 2023] Stability improvement; default model changed to `gpt-3.5-turbo-0613`
32
34
  - [June 11, 2023] The repository renamed to `monadic-chat-cli`
@@ -304,13 +306,13 @@ Monadic Chat has two modes. The `normal` mode utilizes OpenAI's chat API to achi
304
306
 
305
307
  ### Normal Mode
306
308
 
307
- The current default language model for `normal` mode is `gpt-3.5-turbo`.
309
+ The current default language model for `normal` mode is `gpt-4o`.
308
310
 
309
311
  In the default configuration, the dialogue messages are reduced after ten turns by deleting the oldest ones (but not the messages that the `system` role has given as instructions).
310
312
 
311
313
  ### Research Mode
312
314
 
313
- The current default language model for `research` mode is `gpt-3.5-turbo`.
315
+ The current default language model for `research` mode is `gpt-4o`.
314
316
 
315
317
  In `research` mode, the conversation between the user and the large-scale language model is accomplished with a mechanism that tracks the conversation history in a monadic structure. In the default configuration, the dialogue messages are reduced after ten turns by deleting the oldest ones (but not the messages that the `system` role has given as instructions).
316
318
 
@@ -16,17 +16,20 @@ RETRY_WAIT_TIME_SEC = 1
16
16
  module OpenAI
17
17
  def self.default_model(research_mode: false)
18
18
  if research_mode
19
- "gpt-4-turbo-preview"
20
- else
21
- "gpt-4"
19
+ "gpt-4o"
20
+ else # normal mode
21
+ "gpt-4o"
22
22
  end
23
23
  end
24
24
 
25
25
  def self.model_to_method(model)
26
26
  res = {
27
+ "gpt-3.5-turbo-0125" => "chat/completions",
27
28
  "gpt-3.5-turbo-1106" => "chat/completions",
28
29
  "gpt-3.5-turbo" => "chat/completions",
29
30
  "gpt-3.5-turbo-16k" => "chat/completions",
31
+ "gpt-4o" => "chat/completions",
32
+ "gpt-4o-2024-05-13" => "chat/completions",
30
33
  "gpt-4-0125-preview" => "chat/completions",
31
34
  "gpt-4-turbo-preview" => "chat/completions",
32
35
  "gpt-4-1106-preview" => "chat/completions",
@@ -72,16 +75,11 @@ module OpenAI
72
75
  if query["stream"]
73
76
  json = nil
74
77
  buffer = ""
75
- # break_flag = false
76
78
 
77
79
  res.body.each do |chunk|
78
80
  break if /\Rdata: [DONE]\R/ =~ chunk
79
81
 
80
- # break if break_flag
81
-
82
82
  buffer << chunk
83
- # break_flag = true if /\Rdata: [DONE]\R/ =~ buffer
84
-
85
83
  scanner = StringScanner.new(buffer)
86
84
  pattern = /data: (\{.*?\})(?=\n|\z)/m
87
85
  until scanner.eos?
@@ -92,16 +90,15 @@ module OpenAI
92
90
  begin
93
91
  res = JSON.parse(json_data)
94
92
  choice = res.dig("choices", 0) || {}
93
+
95
94
  fragment = choice.dig("delta", "content").to_s
95
+ next if !fragment || fragment == ""
96
96
 
97
97
  block&.call fragment
98
98
 
99
- if !json
100
- json = res
101
- else
102
- json["choices"][0]["text"] ||= +""
103
- json["choices"][0]["text"] << fragment
104
- end
99
+ json ||= res
100
+ json["choices"][0]["text"] ||= +""
101
+ json["choices"][0]["text"] << fragment
105
102
 
106
103
  if choice["finish_reason"] == "length" || choice["finish_reason"] == "stop"
107
104
  finish = { "type" => "message", "content" => "DONE" }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MonadicChat
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.3"
5
5
  end
data/lib/monadic_chat.rb CHANGED
@@ -27,9 +27,9 @@ Oj.mimic_JSON
27
27
 
28
28
  module MonadicChat
29
29
  SETTINGS = {
30
- "normal_model" => "gpt-4",
31
- "research_model" => "gpt-4-turbo-preview",
32
- "max_tokens_wiki" => 1000,
30
+ "normal_model" => "gpt-4o",
31
+ "research_model" => "gpt-4o",
32
+ "max_tokens_wiki" => 1600,
33
33
  "num_retrials" => 2,
34
34
  "min_query_size" => 5,
35
35
  "timeout_sec" => 120
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monadic-chat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - yohasebe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-26 00:00:00.000000000 Z
11
+ date: 2024-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler