monadic-chat 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d44ae83c28ccafde3e3b2ea1d486730c2dbf5ff3cc7193dc4c25c97f6a46fbb
4
- data.tar.gz: f69a30f93b4777b70d078b007c3342e212d3deb4bf2cf92d782fb6af6b825f07
3
+ metadata.gz: 840f1afe3ac1bac2709058c004e0181bc35dce391ac2774575cc7da3de5a31af
4
+ data.tar.gz: a7d82295925a59e375c878e90832457e38a3b675e4ee6e952dd641b9053cf972
5
5
  SHA512:
6
- metadata.gz: 31a241cff282c2e98eed745e4e32612dc018793832c38dddd79614479fd8b816a1c94be7ff16dc16b73858eb883d2da42b81109ed3d94e253a7e473526533386
7
- data.tar.gz: eddd1596523564ac1f066b93c762d13b44515990ba1e479b74f6b51cf94e8fc840d45d45763757264a0c1dde21beac1b68c3652a2baf8a08ab6f306e64a818e9
6
+ metadata.gz: 2577863d5326aa6b442906d71fbd0e1478300657597362e4c0bac1e42f8e5fc46ccf9b88ec515df53d96b4b21e7efd43cfa5884daf5ce65713324b0803e8a893
7
+ data.tar.gz: 3b3c673acf3c2c46147dfaf95fd80c5c6a7fd88eaec22ef913816bf3da114f49af9c54bda36e31beff5149ac0ed280812ae42711232661397a2f3f6cb4c4c5c7
data/CHANGELOG.md CHANGED
@@ -51,3 +51,8 @@
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`
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.2)
5
5
  blingfire
6
6
  http
7
7
  kramdown
@@ -20,21 +20,23 @@ 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.6)
27
+ blingfire (0.2.1)
28
+ diff-lcs (1.5.1)
29
+ domain_name (0.6.20240107)
29
30
  ffi (1.16.3)
30
31
  ffi-compiler (1.0.1)
31
32
  ffi (>= 1.0.0)
32
33
  rake
33
- http (5.1.1)
34
+ http (5.2.0)
34
35
  addressable (~> 2.8)
36
+ base64 (~> 0.1)
35
37
  http-cookie (~> 1.0)
36
38
  http-form_data (~> 2.2)
37
- llhttp-ffi (~> 0.4.0)
39
+ llhttp-ffi (~> 0.5.0)
38
40
  http-cookie (1.0.5)
39
41
  domain_name (~> 0.5)
40
42
  http-form_data (2.3.0)
@@ -42,29 +44,30 @@ GEM
42
44
  rexml
43
45
  launchy (2.5.2)
44
46
  addressable (~> 2.8)
45
- llhttp-ffi (0.4.0)
47
+ llhttp-ffi (0.5.0)
46
48
  ffi-compiler (~> 1.0)
47
49
  rake (~> 13.0)
48
- oj (3.16.1)
50
+ oj (3.16.3)
51
+ bigdecimal (>= 3.0)
49
52
  pastel (0.8.0)
50
53
  tty-color (~> 0.5)
51
- public_suffix (5.0.3)
52
- rake (13.0.6)
54
+ public_suffix (5.0.4)
55
+ rake (13.1.0)
53
56
  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)
57
+ rouge (4.2.0)
58
+ rspec (3.13.0)
59
+ rspec-core (~> 3.13.0)
60
+ rspec-expectations (~> 3.13.0)
61
+ rspec-mocks (~> 3.13.0)
62
+ rspec-core (3.13.0)
63
+ rspec-support (~> 3.13.0)
64
+ rspec-expectations (3.13.0)
62
65
  diff-lcs (>= 1.2.0, < 2.0)
63
- rspec-support (~> 3.12.0)
64
- rspec-mocks (3.12.6)
66
+ rspec-support (~> 3.13.0)
67
+ rspec-mocks (3.13.0)
65
68
  diff-lcs (>= 1.2.0, < 2.0)
66
- rspec-support (~> 3.12.0)
67
- rspec-support (3.12.1)
69
+ rspec-support (~> 3.13.0)
70
+ rspec-support (3.13.0)
68
71
  strings (0.2.1)
69
72
  strings-ansi (~> 0.2)
70
73
  unicode-display_width (>= 1.5, < 3.0)
@@ -95,12 +98,9 @@ GEM
95
98
  tty-cursor (~> 0.7)
96
99
  tty-screen (~> 0.8)
97
100
  wisper (~> 2.0)
98
- tty-screen (0.8.1)
101
+ tty-screen (0.8.2)
99
102
  tty-spinner (0.9.3)
100
103
  tty-cursor (~> 0.7)
101
- unf (0.1.4)
102
- unf_ext
103
- unf_ext (0.0.8.2)
104
104
  unicode-display_width (2.5.0)
105
105
  unicode_utils (1.4.0)
106
106
  wisper (2.0.1)
data/README.md CHANGED
@@ -27,6 +27,7 @@
27
27
 
28
28
  **Change Log**
29
29
 
30
+ - [February 9, 2024] Minor update; default model changed to `gpt-3.5-turbo-0125`
30
31
  - [November 10, 2023] Stability improvement; default model changed to `gpt-3.5-turbo`
31
32
  - [October 07, 2023] Stability improvement; default model changed to `gpt-3.5-turbo-0613`
32
33
  - [June 11, 2023] The repository renamed to `monadic-chat-cli`
@@ -304,13 +305,13 @@ Monadic Chat has two modes. The `normal` mode utilizes OpenAI's chat API to achi
304
305
 
305
306
  ### Normal Mode
306
307
 
307
- The current default language model for `normal` mode is `gpt-3.5-turbo`.
308
+ The current default language model for `normal` mode is `gpt-3.5-turbo-0125`.
308
309
 
309
310
  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
311
 
311
312
  ### Research Mode
312
313
 
313
- The current default language model for `research` mode is `gpt-3.5-turbo`.
314
+ The current default language model for `research` mode is `gpt-4-turbo-preview`.
314
315
 
315
316
  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
317
 
@@ -24,6 +24,7 @@ module OpenAI
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",
@@ -72,16 +73,11 @@ module OpenAI
72
73
  if query["stream"]
73
74
  json = nil
74
75
  buffer = ""
75
- # break_flag = false
76
76
 
77
77
  res.body.each do |chunk|
78
78
  break if /\Rdata: [DONE]\R/ =~ chunk
79
79
 
80
- # break if break_flag
81
-
82
80
  buffer << chunk
83
- # break_flag = true if /\Rdata: [DONE]\R/ =~ buffer
84
-
85
81
  scanner = StringScanner.new(buffer)
86
82
  pattern = /data: (\{.*?\})(?=\n|\z)/m
87
83
  until scanner.eos?
@@ -92,16 +88,15 @@ module OpenAI
92
88
  begin
93
89
  res = JSON.parse(json_data)
94
90
  choice = res.dig("choices", 0) || {}
91
+
95
92
  fragment = choice.dig("delta", "content").to_s
93
+ next if !fragment || fragment == ""
96
94
 
97
95
  block&.call fragment
98
96
 
99
- if !json
100
- json = res
101
- else
102
- json["choices"][0]["text"] ||= +""
103
- json["choices"][0]["text"] << fragment
104
- end
97
+ json ||= res
98
+ json["choices"][0]["text"] ||= +""
99
+ json["choices"][0]["text"] << fragment
105
100
 
106
101
  if choice["finish_reason"] == "length" || choice["finish_reason"] == "stop"
107
102
  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.2"
5
5
  end
data/lib/monadic_chat.rb CHANGED
@@ -27,7 +27,7 @@ Oj.mimic_JSON
27
27
 
28
28
  module MonadicChat
29
29
  SETTINGS = {
30
- "normal_model" => "gpt-4",
30
+ "normal_model" => "gpt-3.5-turbo-0125",
31
31
  "research_model" => "gpt-4-turbo-preview",
32
32
  "max_tokens_wiki" => 1000,
33
33
  "num_retrials" => 2,
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.2
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-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler