monadic-chat 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/CHANGELOG.md +2 -1
- data/README.md +33 -28
- data/bin/monadic-chat +1 -0
- data/lib/monadic_chat/version.rb +1 -1
- data/lib/monadic_chat.rb +20 -14
- metadata +3 -3
- data/Gemfile.lock +0 -172
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e590d4e06e923e510110868aaf97e6d00d94452de3711183a44453b5899af59f
|
4
|
+
data.tar.gz: 67e2e4ed103bc0ca06842ad6cd544558a8e0332782b4c2f07468effb6435074f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39c32bbd0728520af652727f0c2d0ef8f0773bee409967bed7071e75dda4b8bff42c8d2eaf4e1ddb777374ef37ab1366e4584cda1ab56472144b6a2a48c7a874
|
7
|
+
data.tar.gz: 7a577baef5a59d20c98ec7978cd7aeb7aed8947c2b3f1b9b8f6dc4b1b91d1acc246b17e13cb8008fc0122d1c29b8660825214642640c3470b2fa449bc3b33ccf
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.0
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
<img src="https://user-images.githubusercontent.com/18207/224493072-9720b341-c70d-43b9-b996-ba7e9a7a6806.gif" width="900" />
|
7
7
|
</p>
|
8
8
|
|
9
|
-
> **
|
10
|
-
> This software is *under active development
|
9
|
+
> **Warning**
|
10
|
+
> This software is *under active development*. It may be unstable, and the latest version may behave slightly differently than this document. Also, specifications may change in the future.
|
11
11
|
|
12
12
|
## Table of Contents
|
13
13
|
|
@@ -16,33 +16,33 @@
|
|
16
16
|
* [Introduction](#introduction)
|
17
17
|
* [Dependencies](#dependencies)
|
18
18
|
* [Installation](#installation)
|
19
|
-
|
20
|
-
|
19
|
+
* [Using RubyGems](#using-rubygems)
|
20
|
+
* [Clone the GitHub Repository](#clone-the-github-repository)
|
21
21
|
* [Usage](#usage)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
* [Authentication](#authentication)
|
23
|
+
* [Select Main Menu Item](#select-main-menu-item)
|
24
|
+
* [Roles](#roles)
|
25
|
+
* [System-Wide Functions](#system-wide-functions)
|
26
26
|
* [Apps](#apps)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
* [Chat](#chat)
|
28
|
+
* [Code](#code)
|
29
|
+
* [Novel](#novel)
|
30
|
+
* [Translate](#translate)
|
31
31
|
* [Modes](#modes)
|
32
|
-
|
33
|
-
|
32
|
+
* [Normal Mode](#normal-mode)
|
33
|
+
* [Research Mode](#research-mode)
|
34
34
|
* [What is Research Mode?](#what-is-research-mode)
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
* [How Research Mode Works](#how-research-mode-works)
|
36
|
+
* [Accumulator](#accumulator)
|
37
|
+
* [Reducer](#reducer)
|
38
38
|
* [Creating New App](#creating-new-app)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
* [File Structure](#file-structure)
|
40
|
+
* [Reducer Code](#reducer-code)
|
41
|
+
* [Template for `Normal` Mode](#template-for-normal-mode)
|
42
|
+
* [Template for `Research` Mode](#template-for-research-mode)
|
43
43
|
* [What is Monadic about Monadic Chat?](#what-is-monadic-about-monadic-chat)
|
44
|
-
|
45
|
-
|
44
|
+
* [Unit, Map, and Join](#unit-map-and-join)
|
45
|
+
* [Discourse Management Object](#discourse-management-object)
|
46
46
|
* [Future Plans](#future-plans)
|
47
47
|
* [Bibliographical Data](#bibliographical-data)
|
48
48
|
* [Acknowledgments](#acknowledgments)
|
@@ -74,12 +74,18 @@ Monadic Chat comes with four apps (`Chat`, `Code`, `Novel`, and `Translate`). Ea
|
|
74
74
|
|
75
75
|
### Using RubyGems
|
76
76
|
|
77
|
-
Execute the following command in an environment where Ruby 2.6 or higher is installed.
|
77
|
+
Execute the following command in an environment where Ruby 2.6.10 or higher is installed.
|
78
78
|
|
79
79
|
```text
|
80
80
|
gem install monadic-chat
|
81
81
|
```
|
82
82
|
|
83
|
+
To update the `monadic-chat` gem installed:
|
84
|
+
|
85
|
+
```text
|
86
|
+
gem update monadic-chat
|
87
|
+
```
|
88
|
+
|
83
89
|
### Clone the GitHub Repository
|
84
90
|
|
85
91
|
Alternatively, clone the code from the GitHub repository and follow the steps below. At this time, you must take this option to create a new app for Monadic Chat.
|
@@ -115,8 +121,6 @@ chmod +x ./bin/monadic-chat
|
|
115
121
|
|
116
122
|
When you start Monadic Chat with the `monadic-chat` command for the first time, you will be asked for an OpenAI access token. If you do not have one, create an account on the [OpenAI](https://platform.openai.com/) website and obtain an access token.
|
117
123
|
|
118
|
-
If the environment variable `OPENAI_API_KEY` is set in the system, its value will be used automatically.
|
119
|
-
|
120
124
|
<br />
|
121
125
|
|
122
126
|
<kbd><img src="./doc/img/input-acess-token.png" width="700px" style="border: thin solid darkgray;"/></kbd>
|
@@ -389,13 +393,14 @@ The specifications for Monadic Chat's command-line user interface for this app a
|
|
389
393
|
- Parsed data will be formatted in Penn Treebank format. However, square brackets [ ] are used instead of parentheses ( ).
|
390
394
|
- The parsed data is returned as Markdown inline code enclosed in backticks (` `).
|
391
395
|
|
392
|
-
|
396
|
+
> **Note**
|
397
|
+
> The use of square brackets (instead of parentheses) in the notation of syntactic analysis here is to conform to the format of [RSyntaxTree](https://yohasebe.com/rsyntaxtree), a tree-drawing program for linguistic research developed by the author of Monadic Chat.
|
393
398
|
|
394
399
|
<img src="./doc/img/syntree-sample.png" width="300px" />
|
395
400
|
|
396
401
|
The sample app we create in this section is stored in the [`sample_app`](https://github.com/yohasebe/monadic-chat/tree/main/sample_app) folder in the repository.
|
397
402
|
|
398
|
-
###
|
403
|
+
### File Structure
|
399
404
|
|
400
405
|
New Monadic Chat apps must be placed inside the `apps` folder. The folders and files for default apps `chat`, `code`, `novel`, and `translate` are also in this folder.
|
401
406
|
|
data/bin/monadic-chat
CHANGED
data/lib/monadic_chat/version.rb
CHANGED
data/lib/monadic_chat.rb
CHANGED
@@ -129,36 +129,42 @@ module MonadicChat
|
|
129
129
|
OpenAI::Completion.new(token, tmp_file: TEMP_JSON)
|
130
130
|
rescue StandardError
|
131
131
|
print "failure.\n"
|
132
|
-
|
132
|
+
false
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
-
|
136
|
+
completion = nil
|
137
|
+
|
137
138
|
if overwrite
|
138
|
-
access_token =
|
139
|
-
|
139
|
+
access_token = PROMPT_SYSTEM.ask(" Input your OpenAI access token:")
|
140
|
+
return false if access_token.to_s == ""
|
140
141
|
|
141
|
-
check.call(access_token)
|
142
|
+
completion = check.call(access_token)
|
142
143
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
144
|
+
if completion
|
145
|
+
File.open(CONFIG, "w") do |f|
|
146
|
+
config = { "access_token" => access_token }
|
147
|
+
f.write(JSON.pretty_generate(config))
|
148
|
+
print "New access token has been saved to #{CONFIG}\n"
|
149
|
+
end
|
147
150
|
end
|
148
151
|
elsif File.exist?(CONFIG)
|
149
152
|
json = File.read(CONFIG)
|
150
153
|
config = JSON.parse(json)
|
151
154
|
access_token = config["access_token"]
|
152
|
-
check.call(access_token)
|
155
|
+
completion = check.call(access_token)
|
153
156
|
else
|
154
157
|
access_token ||= PROMPT_SYSTEM.ask(" Input your OpenAI access token:")
|
155
|
-
check.call(access_token)
|
156
|
-
|
157
|
-
|
158
|
-
|
158
|
+
completion = check.call(access_token)
|
159
|
+
if completion
|
160
|
+
File.open(CONFIG, "w") do |f|
|
161
|
+
config = { "access_token" => access_token }
|
162
|
+
f.write(JSON.pretty_generate(config))
|
163
|
+
end
|
159
164
|
print "Access token has been saved to #{CONFIG}\n"
|
160
165
|
end
|
161
166
|
end
|
167
|
+
completion || authenticate(overwrite: true)
|
162
168
|
end
|
163
169
|
|
164
170
|
def self.prompt_system
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monadic-chat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yohasebe
|
@@ -261,9 +261,9 @@ extensions: []
|
|
261
261
|
extra_rdoc_files: []
|
262
262
|
files:
|
263
263
|
- ".rspec"
|
264
|
+
- ".ruby-version"
|
264
265
|
- CHANGELOG.md
|
265
266
|
- Gemfile
|
266
|
-
- Gemfile.lock
|
267
267
|
- LICENSE.txt
|
268
268
|
- README.md
|
269
269
|
- Rakefile
|
@@ -336,7 +336,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
336
336
|
- !ruby/object:Gem::Version
|
337
337
|
version: '0'
|
338
338
|
requirements: []
|
339
|
-
rubygems_version: 3.4.
|
339
|
+
rubygems_version: 3.4.8
|
340
340
|
signing_key:
|
341
341
|
specification_version: 4
|
342
342
|
summary: Highly configurable CLI client app for OpenAI chat/text-completion API
|
data/Gemfile.lock
DELETED
@@ -1,172 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
monadic-chat (0.1.0)
|
5
|
-
http
|
6
|
-
kramdown
|
7
|
-
launchy
|
8
|
-
oj
|
9
|
-
parallel
|
10
|
-
pastel
|
11
|
-
rouge
|
12
|
-
tty-box
|
13
|
-
tty-cursor
|
14
|
-
tty-markdown
|
15
|
-
tty-progressbar
|
16
|
-
tty-prompt
|
17
|
-
tty-reader
|
18
|
-
tty-screen
|
19
|
-
tty-spinner
|
20
|
-
|
21
|
-
GEM
|
22
|
-
remote: https://rubygems.org/
|
23
|
-
specs:
|
24
|
-
addressable (2.8.1)
|
25
|
-
public_suffix (>= 2.0.2, < 6.0)
|
26
|
-
ast (2.4.2)
|
27
|
-
backport (1.2.0)
|
28
|
-
benchmark (0.2.1)
|
29
|
-
diff-lcs (1.5.0)
|
30
|
-
domain_name (0.5.20190701)
|
31
|
-
unf (>= 0.0.5, < 1.0.0)
|
32
|
-
e2mmap (0.1.0)
|
33
|
-
ffi (1.15.5)
|
34
|
-
ffi-compiler (1.0.1)
|
35
|
-
ffi (>= 1.0.0)
|
36
|
-
rake
|
37
|
-
http (5.1.1)
|
38
|
-
addressable (~> 2.8)
|
39
|
-
http-cookie (~> 1.0)
|
40
|
-
http-form_data (~> 2.2)
|
41
|
-
llhttp-ffi (~> 0.4.0)
|
42
|
-
http-cookie (1.0.5)
|
43
|
-
domain_name (~> 0.5)
|
44
|
-
http-form_data (2.3.0)
|
45
|
-
jaro_winkler (1.5.4)
|
46
|
-
json (2.6.3)
|
47
|
-
kramdown (2.4.0)
|
48
|
-
rexml
|
49
|
-
kramdown-parser-gfm (1.1.0)
|
50
|
-
kramdown (~> 2.0)
|
51
|
-
launchy (2.5.2)
|
52
|
-
addressable (~> 2.8)
|
53
|
-
llhttp-ffi (0.4.0)
|
54
|
-
ffi-compiler (~> 1.0)
|
55
|
-
rake (~> 13.0)
|
56
|
-
mini_portile2 (2.8.1)
|
57
|
-
nokogiri (1.14.2)
|
58
|
-
mini_portile2 (~> 2.8.0)
|
59
|
-
racc (~> 1.4)
|
60
|
-
oj (3.14.2)
|
61
|
-
parallel (1.22.1)
|
62
|
-
parser (3.2.1.1)
|
63
|
-
ast (~> 2.4.1)
|
64
|
-
pastel (0.8.0)
|
65
|
-
tty-color (~> 0.5)
|
66
|
-
public_suffix (5.0.1)
|
67
|
-
racc (1.6.2)
|
68
|
-
rainbow (3.1.1)
|
69
|
-
rake (13.0.6)
|
70
|
-
regexp_parser (2.7.0)
|
71
|
-
reverse_markdown (2.1.1)
|
72
|
-
nokogiri
|
73
|
-
rexml (3.2.5)
|
74
|
-
rouge (3.30.0)
|
75
|
-
rspec (3.12.0)
|
76
|
-
rspec-core (~> 3.12.0)
|
77
|
-
rspec-expectations (~> 3.12.0)
|
78
|
-
rspec-mocks (~> 3.12.0)
|
79
|
-
rspec-core (3.12.1)
|
80
|
-
rspec-support (~> 3.12.0)
|
81
|
-
rspec-expectations (3.12.2)
|
82
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
83
|
-
rspec-support (~> 3.12.0)
|
84
|
-
rspec-mocks (3.12.3)
|
85
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
86
|
-
rspec-support (~> 3.12.0)
|
87
|
-
rspec-support (3.12.0)
|
88
|
-
rubocop (1.48.0)
|
89
|
-
json (~> 2.3)
|
90
|
-
parallel (~> 1.10)
|
91
|
-
parser (>= 3.2.0.0)
|
92
|
-
rainbow (>= 2.2.2, < 4.0)
|
93
|
-
regexp_parser (>= 1.8, < 3.0)
|
94
|
-
rexml (>= 3.2.5, < 4.0)
|
95
|
-
rubocop-ast (>= 1.26.0, < 2.0)
|
96
|
-
ruby-progressbar (~> 1.7)
|
97
|
-
unicode-display_width (>= 2.4.0, < 3.0)
|
98
|
-
rubocop-ast (1.27.0)
|
99
|
-
parser (>= 3.2.1.0)
|
100
|
-
ruby-progressbar (1.13.0)
|
101
|
-
solargraph (0.48.0)
|
102
|
-
backport (~> 1.2)
|
103
|
-
benchmark
|
104
|
-
bundler (>= 1.17.2)
|
105
|
-
diff-lcs (~> 1.4)
|
106
|
-
e2mmap
|
107
|
-
jaro_winkler (~> 1.5)
|
108
|
-
kramdown (~> 2.3)
|
109
|
-
kramdown-parser-gfm (~> 1.1)
|
110
|
-
parser (~> 3.0)
|
111
|
-
reverse_markdown (>= 1.0.5, < 3)
|
112
|
-
rubocop (>= 0.52)
|
113
|
-
thor (~> 1.0)
|
114
|
-
tilt (~> 2.0)
|
115
|
-
yard (~> 0.9, >= 0.9.24)
|
116
|
-
strings (0.2.1)
|
117
|
-
strings-ansi (~> 0.2)
|
118
|
-
unicode-display_width (>= 1.5, < 3.0)
|
119
|
-
unicode_utils (~> 1.4)
|
120
|
-
strings-ansi (0.2.0)
|
121
|
-
thor (1.2.1)
|
122
|
-
tilt (2.1.0)
|
123
|
-
tty-box (0.7.0)
|
124
|
-
pastel (~> 0.8)
|
125
|
-
strings (~> 0.2.0)
|
126
|
-
tty-cursor (~> 0.7)
|
127
|
-
tty-color (0.6.0)
|
128
|
-
tty-cursor (0.7.1)
|
129
|
-
tty-markdown (0.7.1)
|
130
|
-
kramdown (>= 1.16.2, < 3.0)
|
131
|
-
pastel (~> 0.8)
|
132
|
-
rouge (~> 3.14)
|
133
|
-
strings (~> 0.2.0)
|
134
|
-
tty-color (~> 0.5)
|
135
|
-
tty-screen (~> 0.8)
|
136
|
-
tty-progressbar (0.18.2)
|
137
|
-
strings-ansi (~> 0.2)
|
138
|
-
tty-cursor (~> 0.7)
|
139
|
-
tty-screen (~> 0.8)
|
140
|
-
unicode-display_width (>= 1.6, < 3.0)
|
141
|
-
tty-prompt (0.23.1)
|
142
|
-
pastel (~> 0.8)
|
143
|
-
tty-reader (~> 0.8)
|
144
|
-
tty-reader (0.9.0)
|
145
|
-
tty-cursor (~> 0.7)
|
146
|
-
tty-screen (~> 0.8)
|
147
|
-
wisper (~> 2.0)
|
148
|
-
tty-screen (0.8.1)
|
149
|
-
tty-spinner (0.9.3)
|
150
|
-
tty-cursor (~> 0.7)
|
151
|
-
unf (0.1.4)
|
152
|
-
unf_ext
|
153
|
-
unf_ext (0.0.8.2)
|
154
|
-
unicode-display_width (2.4.2)
|
155
|
-
unicode_utils (1.4.0)
|
156
|
-
webrick (1.7.0)
|
157
|
-
wisper (2.0.1)
|
158
|
-
yard (0.9.28)
|
159
|
-
webrick (~> 1.7.0)
|
160
|
-
|
161
|
-
PLATFORMS
|
162
|
-
ruby
|
163
|
-
|
164
|
-
DEPENDENCIES
|
165
|
-
bundler
|
166
|
-
monadic-chat!
|
167
|
-
rake
|
168
|
-
rspec
|
169
|
-
solargraph
|
170
|
-
|
171
|
-
BUNDLED WITH
|
172
|
-
2.4.2
|