monadic-chat 0.3.3 → 0.3.5

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.
data/bin/monadic-chat CHANGED
@@ -54,11 +54,12 @@ module MonadicMenu
54
54
  clear_screen
55
55
  print "\n", banner.strip, "\n"
56
56
 
57
+ print TTY::Cursor.save
57
58
  openai_completion ||= MonadicChat.authenticate
58
59
  exit unless openai_completion
59
60
 
60
61
  max_app_name_width = APPS.reduce(8) { |accum, app| app.length > accum ? app.length : accum } + 2
61
- parameter = PROMPT_SYSTEM.select(" Current mode: #{print_mode.call(mode)}\n\nSelect item:",
62
+ parameter = PROMPT_SYSTEM.select("Current mode: #{print_mode.call(mode)}\n\nSelect item:",
62
63
  per_page: 10,
63
64
  cycle: true,
64
65
  filter: true,
@@ -129,7 +130,7 @@ when 1
129
130
  when "readme", "-h"
130
131
  MonadicChat.open_readme
131
132
  when "version", "-v"
132
- puts MonadicChat::VERSION
133
+ print MonadicChat::PROMPT_SYSTEM.prefix, MonadicChat::VERSION, "\n"
133
134
  else
134
135
  MonadicChat::APPS.each do |app|
135
136
  next unless app == ARGV[0]
@@ -138,16 +139,30 @@ when 1
138
139
  eval(app.capitalize, binding, __FILE__, __LINE__).new(openai_completion, research_mode: false).run
139
140
  exit
140
141
  end
141
- puts "Unknown command"
142
+ print MonadicChat::PROMPT_SYSTEM.prefix, "Unknown command", "\n"
142
143
  end
143
144
  else
144
- MonadicChat::APPS.each do |app|
145
- next unless app == ARGV[0]
145
+ if ARGV[0] == "new"
146
+ if ARGV[1].to_s != "" && !MonadicChat::APPS.include?(ARGV[1])
147
+ MonadicChat.create_app(ARGV[1])
148
+ else
149
+ print MonadicChat::PROMPT_SYSTEM.prefix, "Invalid app name (must be unique)", "\n"
150
+ end
151
+ elsif ARGV[0] == "delete" || ARGV[0] == "del" || ARGV[0] == "remove"
152
+ if MonadicChat::APPS.include?(ARGV[1])
153
+ MonadicChat.delete_app(ARGV[1])
154
+ else
155
+ print MonadicChat::PROMPT_SYSTEM.prefix, "Invalid app name (must exist)", "\n"
156
+ end
157
+ else
158
+ MonadicChat::APPS.each do |app|
159
+ next unless app == ARGV[0]
146
160
 
147
- openai_completion ||= MonadicChat.authenticate(message: false)
148
- app_obj = eval(app.capitalize, binding, __FILE__, __LINE__).new(openai_completion, research_mode: false, params: { "model" => "gpt-4" })
149
- app_obj.bind(ARGV[1..].join(" "), num_retry: 2)
150
- exit
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" })
163
+ app_obj.bind(ARGV[1..].join(" "), num_retrials: 2)
164
+ exit
165
+ end
166
+ print MonadicChat::PROMPT_SYSTEM.prefix, "Unknown command", "\n"
151
167
  end
152
- puts "Unknown command"
153
168
  end