monadic-chat 0.3.6 → 0.3.7

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: 3e2cd88bc8efbeb6fcc338449160fd6d100c42b44fa8d178816023fac853926c
4
- data.tar.gz: e8ebe92f6b1ba1a4d583ce1d58469bcac453b0633ca5303a0f98cab53bc679ee
3
+ metadata.gz: 2256497e5cedc7850024f7ed9a8b8ec7d9b6cef546d2d20fea7feac024689012
4
+ data.tar.gz: 288b0fa1ceb0367d8c0758b98d1397f307a4926add65ab532867b131968f89d1
5
5
  SHA512:
6
- metadata.gz: 401e24445a672a6fd451a80a225235d36cd520186918bc34dc9b7c86d9753e1ea0dddab5ecec319c7f1bca99c52024c95052264715715ab7bf54b3c36c9426ac
7
- data.tar.gz: cb9e6c76f4086e72f58fbcec7e3c28b5106053c64659e3f7fe6997ceec44e6dfc7f8f07ef5dd5f092580822e84987389f75294f27704815cd48d70cbba87aefb
6
+ metadata.gz: cfae3022ccca777f643a122d73e14044963392044bbf26f4833010296fb73d12f86d960d349e480089aa3c734d91ef1ee2415be592a2aa3fa11360e5c90ade23
7
+ data.tar.gz: 58347893d5ae84aa9374acef3e52421e0f6abf06e9fde78ed9ebbbd8ef57dfb5d6da705b3348a56fc90d4903dbc33c50e3e5330c2c275e5da083bf61705cb982
data/CHANGELOG.md CHANGED
@@ -32,5 +32,10 @@
32
32
 
33
33
  ## [0.3.5] - 2023-04-05
34
34
 
35
- - `Wikipedia` app added (experimental, requires GPT-4)
35
+ - `Wikipedia` app added (experimental)
36
36
  - `monadic-chat new/del app_name` command added
37
+
38
+ ## [0.3.7] - 2023-10-08
39
+
40
+ - Default model changed to `gpt-3.5-turbo-0613`
41
+ - Stability improvement
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- monadic-chat (0.3.5)
4
+ monadic-chat (0.3.7)
5
5
  blingfire
6
6
  http
7
7
  kramdown
@@ -20,13 +20,13 @@ PATH
20
20
  GEM
21
21
  remote: https://rubygems.org/
22
22
  specs:
23
- addressable (2.8.4)
23
+ addressable (2.8.5)
24
24
  public_suffix (>= 2.0.2, < 6.0)
25
- blingfire (0.1.8)
25
+ blingfire (0.2.0)
26
26
  diff-lcs (1.5.0)
27
27
  domain_name (0.5.20190701)
28
28
  unf (>= 0.0.5, < 1.0.0)
29
- ffi (1.15.5)
29
+ ffi (1.16.3)
30
30
  ffi-compiler (1.0.1)
31
31
  ffi (>= 1.0.0)
32
32
  rake
@@ -45,26 +45,26 @@ GEM
45
45
  llhttp-ffi (0.4.0)
46
46
  ffi-compiler (~> 1.0)
47
47
  rake (~> 13.0)
48
- oj (3.14.3)
48
+ oj (3.16.1)
49
49
  pastel (0.8.0)
50
50
  tty-color (~> 0.5)
51
- public_suffix (5.0.1)
51
+ public_suffix (5.0.3)
52
52
  rake (13.0.6)
53
- rexml (3.2.5)
54
- rouge (4.1.0)
53
+ rexml (3.2.6)
54
+ rouge (4.1.3)
55
55
  rspec (3.12.0)
56
56
  rspec-core (~> 3.12.0)
57
57
  rspec-expectations (~> 3.12.0)
58
58
  rspec-mocks (~> 3.12.0)
59
- rspec-core (3.12.1)
59
+ rspec-core (3.12.2)
60
60
  rspec-support (~> 3.12.0)
61
- rspec-expectations (3.12.2)
61
+ rspec-expectations (3.12.3)
62
62
  diff-lcs (>= 1.2.0, < 2.0)
63
63
  rspec-support (~> 3.12.0)
64
- rspec-mocks (3.12.5)
64
+ rspec-mocks (3.12.6)
65
65
  diff-lcs (>= 1.2.0, < 2.0)
66
66
  rspec-support (~> 3.12.0)
67
- rspec-support (3.12.0)
67
+ rspec-support (3.12.1)
68
68
  strings (0.2.1)
69
69
  strings-ansi (~> 0.2)
70
70
  unicode-display_width (>= 1.5, < 3.0)
@@ -101,7 +101,7 @@ GEM
101
101
  unf (0.1.4)
102
102
  unf_ext
103
103
  unf_ext (0.0.8.2)
104
- unicode-display_width (2.4.2)
104
+ unicode-display_width (2.5.0)
105
105
  unicode_utils (1.4.0)
106
106
  wisper (2.0.1)
107
107
 
@@ -116,4 +116,4 @@ DEPENDENCIES
116
116
  rspec
117
117
 
118
118
  BUNDLED WITH
119
- 2.4.10
119
+ 2.4.17
data/README.md CHANGED
@@ -27,8 +27,9 @@
27
27
 
28
28
  **Change Log**
29
29
 
30
+ - [October 07, 2023] Stability improvement; default model changed to `gpt-3.5-turbo-0613`
30
31
  - [June 11, 2023] The repository renamed to `monadic-chat-cli`
31
- - [April 05, 2023] `Wikipedia` app added (experimental, requires GPT-4)
32
+ - [April 05, 2023] `Wikipedia` app added (experimental)
32
33
  - [April 05, 2023] `monadic-chat new/del app_name` command
33
34
  - [April 02, 2023] Architecture refined here and there
34
35
  - [March 26, 2023] Command line options to directly run individual apps
@@ -302,13 +303,13 @@ Monadic Chat has two modes. The `normal` mode utilizes OpenAI's chat API to achi
302
303
 
303
304
  ### Normal Mode
304
305
 
305
- The current default language model for `normal` mode is `gpt-3.5-turbo`.
306
+ The current default language model for `normal` mode is `gpt-3.5-turbo-613`.
306
307
 
307
308
  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).
308
309
 
309
310
  ### Research Mode
310
311
 
311
- The current default language model for `research` mode is `gpt-3.5-turbo`.
312
+ The current default language model for `research` mode is `gpt-3.5-turbo-0613`.
312
313
 
313
314
  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).
314
315
 
data/apps/chat/chat.md CHANGED
@@ -12,9 +12,9 @@ JSON:
12
12
 
13
13
  ```json
14
14
  {
15
+ "mode": "chat",
15
16
  "response": "Sure!",
16
17
  "summary": "",
17
- "mode": "chat",
18
18
  "language": "English",
19
19
  "topics": [],
20
20
  "confidence": 1.00,
@@ -33,6 +33,7 @@ Make sure the following content requirements are all fulfilled: ###
33
33
  - update the value of the "ambiguity" property based on the clarity of the user input, ranging from 0.00 (not at all ambiguous, clearly stated) to 1.00 (fully ambiguous, nonsensical)
34
34
  - avoid giving a response that is the same or similar to one of the previous responses in MESSAGES
35
35
  - program code in the response must be embedded in a code block in the markdown text
36
+ - the output JSON object must contain "mode", "response", "summary", "language", "topics", "confidence", and "ambiguity"
36
37
  ###
37
38
 
38
39
  Make sure the following formal requirements are all fulfilled: ###
data/apps/code/code.md CHANGED
@@ -10,9 +10,9 @@ JSON:
10
10
 
11
11
  ```json
12
12
  {
13
+ "mode": "chat",
13
14
  "response": "Sure!",
14
15
  "summary": "",
15
- "mode": "chat",
16
16
  "language": "English",
17
17
  "topics": []
18
18
  }
@@ -27,6 +27,7 @@ Make sure the following content requirements are all fulfilled: ###
27
27
  - summarize the user's messages so far and update the "summary" property with a text of fewer than 100 words
28
28
  - avoid giving a response that is the same or similar to one of the previous responses in "MESSAGES"
29
29
  - program code in the response must be embedded in a code block in the markdown text
30
+ - the output JSON object must contain "mode", "response", "summary", "language", and "topics"
30
31
  ###
31
32
 
32
33
  Make sure the following formal requirements are all fulfilled: ###
data/apps/novel/novel.md CHANGED
@@ -10,9 +10,9 @@ JSON:
10
10
 
11
11
  ```json
12
12
  {
13
+ "mode": "novel",
13
14
  "response": "What follows is a story that an AI assistant tells. It is guaranteed that this will be an incredibly realistic and interesting novel.",
14
- "summary": "",
15
- "mode": "novel"
15
+ "summary": ""
16
16
  }
17
17
  ```
18
18
 
@@ -22,6 +22,7 @@ Make sure the following content requirements are all fulfilled: ###
22
22
  - do not repeat in your response what is already told in "MESSAGES"
23
23
  - make your response as detailed as possible within the maximum limit of 200 words
24
24
  - summarize the user's messages so far and update the "summary" property with a text of fewer than 100 words
25
+ - the output JSON object must contain "mode", "response", and "summary"
25
26
  ###
26
27
 
27
28
  Make sure the following formal requirements are all fulfilled: ###
@@ -11,9 +11,9 @@ JSON:
11
11
  ```json
12
12
  {
13
13
  "mode": "translate",
14
+ "target_lang": "English",
14
15
  "response": "This is a sentence in Japanese.",
15
- "dictioanry": {"日本語": "Japanese", "文": "sentence"},
16
- "target_lang": "English"
16
+ "dictioanry": {"日本語": "Japanese", "文": "sentence"}
17
17
  }
18
18
  ```
19
19
 
@@ -22,6 +22,7 @@ Make sure the following requirements are all fulfilled: ###
22
22
  - translate the new prompt text to the language specified in the "target_lang" set it to "response" and set the translation to the "response" property
23
23
  - update the "dictionary" property with translation suggested by the user (using parentheses) for specific expressions
24
24
  - add user-suggested translations (translations in parentheses) to the "dictionary" property
25
+ - the output JSON object must contain "mode", "target_lang", "response", and "dictionary"
25
26
  ###
26
27
 
27
28
  Make sure the following formal requirements are all fulfilled: ###
data/bin/monadic-chat CHANGED
@@ -159,7 +159,7 @@ else
159
159
  next unless app == ARGV[0]
160
160
 
161
161
  openai_completion ||= MonadicChat.authenticate(message: false)
162
- app_obj = eval(app.capitalize, binding, __FILE__, __LINE__).new(openai_completion, research_mode: false, params: { "model" => "gpt-4" })
162
+ app_obj = eval(app.capitalize, binding, __FILE__, __LINE__).new(openai_completion, research_mode: false, params: {})
163
163
  app_obj.bind(ARGV[1..].join(" "), num_retrials: 2)
164
164
  exit
165
165
  end
@@ -12,15 +12,15 @@ Oj.mimic_JSON
12
12
  module OpenAI
13
13
  def self.default_model(research_mode: false)
14
14
  if research_mode
15
- "gpt-3.5-turbo"
15
+ "gpt-3.5-turbo-0613"
16
16
  else
17
- "gpt-3.5-turbo"
17
+ "gpt-3.5-turbo-0613"
18
18
  end
19
19
  end
20
20
 
21
21
  def self.model_to_method(model)
22
22
  {
23
- "text-davinci-003" => "completions",
23
+ "gpt-3.5-turbo-instruct" => "completions",
24
24
  "gpt-4" => "chat/completions",
25
25
  "gpt-4-0613" => "chat/completions",
26
26
  "gpt-4-32K" => "chat/completions",
@@ -51,11 +51,16 @@ module OpenAI
51
51
  if query["stream"]
52
52
  json = nil
53
53
  res.body.each do |chunk|
54
- chunk.split("\n\n").each do |data|
55
- content = data.strip[6..]
54
+ chunk.scan(/data: (\{.*\})/i).flatten.each do |data|
55
+ content = data.strip
56
56
  break if content == "[DONE]"
57
57
 
58
- stream = JSON.parse(content)
58
+ begin
59
+ stream = JSON.parse(content)
60
+ rescue JSON::ParserError
61
+ next
62
+ end
63
+
59
64
  fragment = case method
60
65
  when "completions"
61
66
  stream["choices"][0]["text"]
@@ -74,11 +79,23 @@ module OpenAI
74
79
  json["choices"][0]["text"] << fragment
75
80
  end
76
81
  end
82
+ rescue JSON::ParserError
83
+ res = { "type" => "error", "content" => "Error: JSON Parsing" }
84
+ pp res
85
+ block&.call res
86
+ res
77
87
  end
78
88
  end
79
89
  json
80
90
  else
81
- JSON.parse res.body
91
+ begin
92
+ JSON.parse res.body
93
+ rescue JSON::ParserError
94
+ res = { "type" => "error", "content" => "Error: JSON Parsing" }
95
+ pp res
96
+ block&.call res
97
+ res
98
+ end
82
99
  end
83
100
  end
84
101
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MonadicChat
4
- VERSION = "0.3.6"
4
+ VERSION = "0.3.7"
5
5
  end
data/lib/monadic_chat.rb CHANGED
@@ -27,8 +27,8 @@ Oj.mimic_JSON
27
27
 
28
28
  module MonadicChat
29
29
  SETTINGS = {
30
- "normal_model" => "gpt-3.5-turbo",
31
- "research_model" => "gpt-3.5-turbo",
30
+ "normal_model" => "gpt-3.5-turbo-0613",
31
+ "research_model" => "gpt-3.5-turbo-0613",
32
32
  "max_tokens_wiki" => 1000,
33
33
  "num_retrials" => 2,
34
34
  "min_query_size" => 5,
@@ -3,7 +3,7 @@
3
3
  require_relative "../../lib/monadic_app"
4
4
 
5
5
  class Wikipedia < MonadicApp
6
- DESC = "Searches Wikipedia for you (experimental, requires GPT-4)"
6
+ DESC = "Searches Wikipedia for you (experimental)"
7
7
  COLOR = "white"
8
8
 
9
9
  attr_accessor :template, :config, :params, :completion
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.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - yohasebe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-04 00:00:00.000000000 Z
11
+ date: 2023-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler