-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.rb
52 lines (40 loc) · 1.19 KB
/
cli.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module CLAI
class CLI < Thor
default_task :session
option :persona, type: :string
desc "session", "Start an interactive chat session"
long_desc <<~DESC
Starts a REPL like chat process
> $ clai session
Use a preconfigured persona with --persona
> $ clai chat "Count to 10" --persona ruby
DESC
def session
Commands::Session.new(config).start_session(persona: options['persona'])
end
option :persona, type: :string
desc "chat", "Prompt on the terminal"
long_desc <<~DESC
Send a single prompt to AI
> $ clai chat "Tell me a short story!"
Use a preconfigured persona with --persona
> $ clai chat "Count to 10" --persona ruby
DESC
def chat(prompt)
Commands::Chat.new(config).chat(prompt, persona: options['persona'])
end
option :force, type: :boolean, default: false
desc "setup", "Setup clai on your machine"
long_desc <<~DESC
Setup `clai` on your machine. This will ask you for a api key and create a base config file.
> $ clai setup
DESC
def setup
Commands::Setup.new.run(options[:force])
end
private
def config
@config ||= Config.parse
end
end
end