chatai 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +46 -0
- data/bin/chatai +38 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 852dbec8f8117f5ee88a215ecd5af4b128d566000519ccc9f0e2855c6f386842
|
4
|
+
data.tar.gz: d4ec144e1a98add31edaeb2a27912e49cc98fe4a4138aacbb183a47d542a1733
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b11c66dd7724dca8fa0dcdbf15db2532f799bd05533956e2aa6962d5becea75bda96c19b5134596ab0371cf08e3889aaf105578350313ff2f5cf8041f940c2bc
|
7
|
+
data.tar.gz: '080b0a7ea97224298d4546f299a18bd68f24a27fb4d333d58e63ca5713ff6f0a707b5bdfd26f0d97ba6e4193a52a78f3a1b0df179da88ee75bf695b26bc9049e'
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Vincent Ollivier
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Chatai
|
2
|
+
|
3
|
+
A simple CLI for ChatGPT written in Ruby
|
4
|
+
|
5
|
+
## Setup
|
6
|
+
|
7
|
+
Run the following commands to setup the CLI:
|
8
|
+
|
9
|
+
$ bundle install
|
10
|
+
$ cp .env.sample .env
|
11
|
+
|
12
|
+
Then edit the `.env` file with your [API key](https://platform.openai.com/account/api-keys)
|
13
|
+
|
14
|
+
You can also install the script to use it everywhere:
|
15
|
+
|
16
|
+
$ sudo cp bin/chatai /usr/local/bin/chatai
|
17
|
+
$ sudo chmod 755 /usr/local/bin/chatai
|
18
|
+
$ cp .env ~/.chatai.env
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
$ chatai
|
23
|
+
> What is Unix?
|
24
|
+
Unix is a multi-user, multi-tasking operating system that was first developed
|
25
|
+
in the 1960s. It is known for its stability, security, and flexibility, and is
|
26
|
+
widely used in servers, workstations, and embedded systems. Unix is based on
|
27
|
+
the concept of a shell, which allows users to interact with the system through
|
28
|
+
a command-line interface or graphical user interface. It also has a rich set of
|
29
|
+
standard utilities and tools that make it easy to perform various tasks such as
|
30
|
+
file management, process management, networking, and more. Unix has many
|
31
|
+
variants, including Linux, FreeBSD, Solaris, and macOS.
|
32
|
+
|
33
|
+
> Who wrote it?
|
34
|
+
Unix was initially written by Ken Thompson, Dennis Ritchie, and others at Bell
|
35
|
+
Labs in the late 1960s and early 1970s.
|
36
|
+
|
37
|
+
> List 5 contributors
|
38
|
+
1. Ken Thompson
|
39
|
+
2. Dennis Ritchie
|
40
|
+
3. Brian Kernighan
|
41
|
+
4. Steve Bourne
|
42
|
+
5. Doug McIlroy
|
43
|
+
|
44
|
+
## License
|
45
|
+
|
46
|
+
ChatGPT CLI is released under MIT
|
data/bin/chatai
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "dotenv"
|
3
|
+
require "openai"
|
4
|
+
require "word_wrap"
|
5
|
+
|
6
|
+
Dotenv.load(".env", "~/.chatai.env")
|
7
|
+
|
8
|
+
OpenAI.configure do |config|
|
9
|
+
config.access_token = ENV.fetch("OPENAI_API_KEY") do |name|
|
10
|
+
print "OpenAI API Key: "
|
11
|
+
gets.chomp
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
client = OpenAI::Client.new
|
16
|
+
|
17
|
+
begin
|
18
|
+
history = []
|
19
|
+
while true
|
20
|
+
print "\x1b[36m>\x1b[0m "
|
21
|
+
history << gets.chomp
|
22
|
+
res = client.chat(parameters: {
|
23
|
+
model: ENV.fetch("OPENAI_MODEL", "gtp-3.5-turbo"),
|
24
|
+
messages: [{ role: "user", content: history.join("\n\n") }],
|
25
|
+
temperature: 0.7,
|
26
|
+
})
|
27
|
+
if (err = res.dig("error", "message"))
|
28
|
+
puts err
|
29
|
+
exit 1
|
30
|
+
end
|
31
|
+
text = res.dig("choices", 0, "message", "content").strip
|
32
|
+
puts WordWrap.ww(text, 80)
|
33
|
+
puts
|
34
|
+
history << text
|
35
|
+
end
|
36
|
+
rescue SignalException
|
37
|
+
puts
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chatai
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vincent Ollivier
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-03-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dotenv
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.8'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.8.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.8'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.8.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: ruby-openai
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3.5'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 3.5.0
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '3.5'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 3.5.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: word_wrap
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.0'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.0.0
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.0'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.0.0
|
73
|
+
description: A simple CLI for ChatGPT
|
74
|
+
email: v@vinc.cc
|
75
|
+
executables:
|
76
|
+
- chatai
|
77
|
+
extensions: []
|
78
|
+
extra_rdoc_files: []
|
79
|
+
files:
|
80
|
+
- LICENSE
|
81
|
+
- README.md
|
82
|
+
- bin/chatai
|
83
|
+
homepage: https://github.com/vinc/chatai
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubygems_version: 3.4.1
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: ChatGPT CLI
|
106
|
+
test_files: []
|