monadic-chat 0.1.1 → 0.1.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: 5ce3030e71a68706d7fe8784f46f2dc940c6a3e08d81ef58bd8d28f60a149063
4
- data.tar.gz: 8ab88aedccb49df837c5d853822d756e6df7b759266e5798bc3791bf31b43452
3
+ metadata.gz: 9949be7f2447dd466b5cfff5b7c13615f1348ca8d2dd9938a28fca68a48cc4e5
4
+ data.tar.gz: 462c1f5af82cb50bd577305a782cad7499f1a7ce05b156491539546b5dfadba2
5
5
  SHA512:
6
- metadata.gz: 52544a1343d7ca4cd10bbaa489e17596238510c635861d1701e62038e5482a1ad24af732a06ed09d13551af9331039488085518017013798d387982ec74adcaa
7
- data.tar.gz: 0c67f03002b7aec1eede094b0a0a96ca342c7a417ca7c8cd09f4f99058afb126e74911edf78c2d9170eac7f201fd2d4401ad2d31a9f8ae7426cb7b275dc5cc87
6
+ metadata.gz: affcd2df90174f9e85678234e11c0b08c3c486d793c87792d2bc676e3f02d4ec846a58e716bb86ec82f5b2e37ed90f14b61aacb3e93c37c0ba6fece31d4fce1c
7
+ data.tar.gz: a4126ffff2679f31bcc000a05620f5914a55188f61e0f35501428888a3445ef6c11775602eed74ee029566b18ea1f8526277a14839b342edb01824fd2b121797
data/CHANGELOG.md CHANGED
@@ -7,3 +7,7 @@
7
7
  ## [0.1.1] - 2023-03-12
8
8
 
9
9
  - Public release
10
+
11
+ ## [0.1.2] - 2023-03-12
12
+
13
+ - Authentication problem fixed
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
- > **Note**
10
- > This software is *under active development*, and the latest version may behave slightly differently than this documentation. The specifications may change in the future.
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
- * [Using RubyGems](#using-rubygems)
20
- * [Clone the GitHub Repository](#clone-the-github-repository)
19
+ * [Using RubyGems](#using-rubygems)
20
+ * [Clone the GitHub Repository](#clone-the-github-repository)
21
21
  * [Usage](#usage)
22
- * [Authentication](#authentication)
23
- * [Select Main Menu Item](#select-main-menu-item)
24
- * [Roles](#roles)
25
- * [System-Wide Functions](#system-wide-functions)
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
- * [Chat](#chat)
28
- * [Code](#code)
29
- * [Novel](#novel)
30
- * [Translate](#translate)
27
+ * [Chat](#chat)
28
+ * [Code](#code)
29
+ * [Novel](#novel)
30
+ * [Translate](#translate)
31
31
  * [Modes](#modes)
32
- * [Normal Mode](#normal-mode)
33
- * [Research Mode](#research-mode)
32
+ * [Normal Mode](#normal-mode)
33
+ * [Research Mode](#research-mode)
34
34
  * [What is Research Mode?](#what-is-research-mode)
35
- * [How Research Mode Works](#how-research-mode-works)
36
- * [Accumulator](#accumulator)
37
- * [Reducer](#reducer)
35
+ * [How Research Mode Works](#how-research-mode-works)
36
+ * [Accumulator](#accumulator)
37
+ * [Reducer](#reducer)
38
38
  * [Creating New App](#creating-new-app)
39
- * [Folder/File Structure](#folderfile-structure)
40
- * [Reducer Code](#reducer-code)
41
- * [Template for `Normal` Mode](#template-for-normal-mode)
42
- * [Template for `Research` Mode](#template-for-research-mode)
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
- * [Unit, Map, and Join](#unit-map-and-join)
45
- * [Discourse Management Object](#discourse-management-object)
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)
@@ -115,8 +115,6 @@ chmod +x ./bin/monadic-chat
115
115
 
116
116
  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
117
 
118
- If the environment variable `OPENAI_API_KEY` is set in the system, its value will be used automatically.
119
-
120
118
  <br />
121
119
 
122
120
  <kbd><img src="./doc/img/input-acess-token.png" width="700px" style="border: thin solid darkgray;"/></kbd>
@@ -389,13 +387,14 @@ The specifications for Monadic Chat's command-line user interface for this app a
389
387
  - Parsed data will be formatted in Penn Treebank format. However, square brackets [ ] are used instead of parentheses ( ).
390
388
  - The parsed data is returned as Markdown inline code enclosed in backticks (` `).
391
389
 
392
- 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.
390
+ > **Note**
391
+ > 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
392
 
394
393
  <img src="./doc/img/syntree-sample.png" width="300px" />
395
394
 
396
395
  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
396
 
398
- ### Folder/File Structure
397
+ ### File Structure
399
398
 
400
399
  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
400
 
data/bin/monadic-chat CHANGED
@@ -54,7 +54,8 @@ module MonadicMenu
54
54
  clear_screen
55
55
  print "\n", banner.strip, "\n"
56
56
 
57
- openai_completion ||= MonadicChat.authenticate
57
+ openai_completion = MonadicChat.authenticate
58
+ exit unless openai_completion
58
59
 
59
60
  parameter = PROMPT_SYSTEM.select(" Current mode: #{print_mode.call(mode)}\n\nSelect item:",
60
61
  per_page: 10,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MonadicChat
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
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
- authenticate(overwrite: true)
132
+ false
133
133
  end
134
134
  end
135
135
 
136
- access_token = ENV["OPENAI_API_KEY"]
136
+ completion = nil
137
+
137
138
  if overwrite
138
- access_token = nil
139
- access_token ||= PROMPT_SYSTEM.ask(" Input your OpenAI access token:")
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
- File.open(CONFIG, "w") do |f|
144
- config = { "access_token" => access_token }
145
- f.write(JSON.pretty_generate(config))
146
- print "New access token has been saved to #{CONFIG}\n"
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
- File.open(CONFIG, "w") do |f|
157
- config = { "access_token" => access_token }
158
- f.write(JSON.pretty_generate(config))
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - yohasebe
@@ -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.1
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