richat 0.2.1 → 0.2.3

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: f1d2620e07b7c772f88b49478da45414f8310dbd68fd6029a3abfb6140cd74b6
4
- data.tar.gz: 53bd0492ac8fc0a3f841eb228c3a51764d3f6151e75b5b1a2c8224142cf9f242
3
+ metadata.gz: f9d0ef493fcedb52399b88baee0ef20c11d90fdf258c5aa4f8df2caca0e2ec23
4
+ data.tar.gz: caf49bffd8f470ba54bcfd27d639899a10068a4a7ba696eab2e3bcba8416a755
5
5
  SHA512:
6
- metadata.gz: d00712292be7c61dc2de2566fd64d7c63550d90fc88fa82a1f94b4ae8f865258f04c9cf407f539d2b4f19bdb3fc1a9b8e874712f69aa42fa0c5314e7068addaa
7
- data.tar.gz: fc9c556892178a6f9b944e5797c0a12547560195e0bcab1a07278761d1eedabbc5f04f12c2ac75c3c160771d0b60d21519f2ca1f345698a04349bf44e25567c6
6
+ metadata.gz: 207d40655ca0be10eb68a2409943206ba1ef42d946a70553d8f0db4260d415486e8922fa9da578eb9b9634622d77b7d68f9c2496a9f3cfaebfcf476759b13e29
7
+ data.tar.gz: 9d4091ce31a3783ddd50cc5f1a00844ac1baa61937e8edcbf5b21f3e03ccfd909854212da22b4d284073104c6894b8472c4ac5ad1ff996117a7fe84f5cb9a697
data/exe/richat CHANGED
@@ -16,6 +16,11 @@ chat_config = {
16
16
  stream: true
17
17
  }
18
18
 
19
+ if chat_config[:api_key].nil? || chat_config[:api_key].empty?
20
+ puts "OpenAI API key not set, refer https://github.com/fzdp/richat#usage for more info."
21
+ exit
22
+ end
23
+
19
24
  if Richat::Config.get("log", "enable")
20
25
  logger = Richat::Logger.new(log_file: "#{log_dir}/#{Time.now.strftime('%Y%m%d')}.md")
21
26
  else
@@ -1,3 +1,3 @@
1
1
  module Richat
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: richat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - fzdp
@@ -10,6 +10,20 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2023-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.7'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -62,17 +76,6 @@ executables:
62
76
  extensions: []
63
77
  extra_rdoc_files: []
64
78
  files:
65
- - ".gitignore"
66
- - ".rspec"
67
- - ".travis.yml"
68
- - CODE_OF_CONDUCT.md
69
- - Gemfile
70
- - Gemfile.lock
71
- - LICENSE.txt
72
- - README.md
73
- - Rakefile
74
- - bin/console
75
- - bin/setup
76
79
  - exe/richat
77
80
  - lib/extension/hash.rb
78
81
  - lib/openai/chat.rb
@@ -83,7 +86,6 @@ files:
83
86
  - lib/richat/logger.rb
84
87
  - lib/richat/shell.rb
85
88
  - lib/richat/version.rb
86
- - richat.gemspec
87
89
  homepage: https://github.com/fzdp/richat
88
90
  licenses:
89
91
  - MIT
@@ -98,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
100
  requirements:
99
101
  - - ">="
100
102
  - !ruby/object:Gem::Version
101
- version: '0'
103
+ version: 2.3.0
102
104
  required_rubygems_version: !ruby/object:Gem::Requirement
103
105
  requirements:
104
106
  - - ">="
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.7
7
- before_install: gem install bundler -v 1.17.3
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at fzdp01@gmail.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
- gem "faraday"
5
- # Specify your gem's dependencies in richat.gemspec
6
- gemspec
data/Gemfile.lock DELETED
@@ -1,41 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- richat (0.2.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- diff-lcs (1.4.4)
10
- faraday (2.7.4)
11
- faraday-net_http (>= 2.0, < 3.1)
12
- ruby2_keywords (>= 0.0.4)
13
- faraday-net_http (3.0.2)
14
- rake (10.5.0)
15
- rspec (3.10.0)
16
- rspec-core (~> 3.10.0)
17
- rspec-expectations (~> 3.10.0)
18
- rspec-mocks (~> 3.10.0)
19
- rspec-core (3.10.1)
20
- rspec-support (~> 3.10.0)
21
- rspec-expectations (3.10.1)
22
- diff-lcs (>= 1.2.0, < 2.0)
23
- rspec-support (~> 3.10.0)
24
- rspec-mocks (3.10.2)
25
- diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.10.0)
27
- rspec-support (3.10.2)
28
- ruby2_keywords (0.0.5)
29
-
30
- PLATFORMS
31
- ruby
32
-
33
- DEPENDENCIES
34
- bundler (~> 1.17)
35
- faraday
36
- rake (~> 10.0)
37
- richat!
38
- rspec (~> 3.0)
39
-
40
- BUNDLED WITH
41
- 1.17.3
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2023 fzdp
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 DELETED
@@ -1,145 +0,0 @@
1
- # Richat
2
-
3
- ## A powerful command-line ChatGPT tool.
4
-
5
- Richat is a command-line ChatGPT tool implemented in Ruby that supports highly customizable configuration. It can save chat logs, performs fuzzy searches on historical inputs, allows for prompt customization and switching at any time.
6
-
7
- https://user-images.githubusercontent.com/6159178/228784846-a31772c0-53a5-4aff-92ae-2e33d9c6fad5.mov
8
-
9
- ## Installation
10
-
11
- ```
12
- gem install richat
13
- ```
14
-
15
- ## Usage
16
-
17
- There are two ways to configure OpenAI API key
18
-
19
- 1. set `OPENAI_API_KEY` env variable
20
- 2. edit `~/.richat/config.json` file and set API key, for example
21
-
22
- ```
23
- {
24
- "chatgpt": {
25
- "api_key": "YOUR OPENAI API KEY"
26
- }
27
- }
28
- ```
29
-
30
- Then run `richat` command to talk with ChatGPT.
31
-
32
- <img width="800" alt="image" src="https://user-images.githubusercontent.com/6159178/228755576-5d76a777-f07e-43f6-8141-4f9e19f15372.png">
33
-
34
- ### Configuration
35
-
36
- Use `/config` command to show current configuration.
37
-
38
- ```
39
- >> /config
40
- Configuration file path is /Users/fzdp/.richat/config.json
41
- {
42
- "chatgpt": {
43
- "api_key": "YOUR_OPENAI_API_KEY",
44
- "model": "gpt-3.5-turbo",
45
- "temperature": 0.7
46
- },
47
- "log": {
48
- "enable": true,
49
- "log_dir": "~/.richat/logs",
50
- "user_role": "USR",
51
- "ai_role": "GPT",
52
- "system_role": "SYS"
53
- },
54
- "shell": {
55
- "save_history": true,
56
- "enable_chat_context": true,
57
- "show_welcome_info": true,
58
- "history_file": "~/.richat/shell_history.txt"
59
- },
60
- "prompt": {
61
- "prompt_dir": "~/.richat/prompts",
62
- "default": ""
63
- }
64
- }
65
- ```
66
-
67
- Edit `~/.richat/config.json` if you need customize configuration.
68
-
69
- ### Chat log
70
-
71
- By default, Richat will log your chat history and log names are in date format.
72
-
73
- Set `log.enable` to false if you don't need log feature.
74
-
75
- <img width="409" alt="" src="https://user-images.githubusercontent.com/6159178/228758657-1dbbe25b-e768-403d-8b42-3b270f53fe2a.png">
76
-
77
- ### Prompt
78
-
79
- You can place prompt files in `~/.richat/prompts` or other directory defined in configure file.
80
-
81
- For example, if you place `emoji`, `linux`, `wikipedia` in the directory, then in Richat shell `/prompt` command will show these prompt files.
82
-
83
- <img width="960" alt="" src="https://user-images.githubusercontent.com/6159178/228761906-4ab74529-3ccb-41b7-badc-98cc0fd9bd72.png">
84
-
85
- #### Change prompt
86
-
87
- You can use `/prompt` command to switch prompt, the argument is prompt file name or prompt file index.
88
-
89
- <img width="960" alt="" src="https://user-images.githubusercontent.com/6159178/228764026-79bbbfef-cd5d-4641-9edf-91f7d71063a5.png">
90
-
91
- #### Set default prompt
92
-
93
- For example if you want to use linux as default prompt, just edit config file
94
-
95
- ```json
96
- {
97
- "prompt": {
98
- "default": "linux"
99
- }
100
- }
101
- ```
102
-
103
- Then Richat shell will use linux prompt when it's run
104
-
105
- <img width="960" alt="" src="https://user-images.githubusercontent.com/6159178/228766064-12230d33-158a-413e-8473-6a7dc60f28bd.png">
106
-
107
- ### Input history
108
-
109
- By default your input history will be saved in `~/.richat/shell_history_file`.
110
-
111
- In Richat shell mode, there are three ways to enhance chat experience.
112
-
113
- 1. press TAB to auto complete input
114
- 2. press Arrow keys to traverse history
115
- 3. press `Control + R` to fuzzy search input
116
-
117
- ### Stream mode
118
-
119
- ChatGPT stream mode is auto enabled in Richat shell mode
120
-
121
- https://user-images.githubusercontent.com/6159178/228770757-c3e1c286-7077-4a00-b376-a491ca280126.mov
122
-
123
- ### Cli
124
-
125
- You can run `richat` with additional chat content directly
126
-
127
- ```
128
- ~ richat hello world
129
- Hello! How can I assist you today?
130
- ```
131
-
132
- ### Chat context
133
-
134
- Chat context is enabled by default, because ChatGPT have no memory of past requests, all relevant information must be supplied via the conversation.
135
-
136
- You can turn it off in config file.
137
-
138
- ## Contributing
139
-
140
- Bug reports and pull requests are welcome on GitHub at https://github.com/fzdp/richat.
141
-
142
- ## License
143
-
144
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
145
-
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "richat"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/richat.gemspec DELETED
@@ -1,38 +0,0 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "richat/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "richat"
8
- spec.version = Richat::VERSION
9
- spec.authors = ["fzdp"]
10
- spec.email = ["fzdp01@gmail.com"]
11
-
12
- spec.summary = %q{Richat is a command-line ChatGPT tool}
13
- spec.description = %q{Richat is a command-line ChatGPT tool implemented in Ruby that supports highly customizable configuration. It can save chat logs, performs fuzzy searches on historical inputs, allows for prompt customization and switching at any time}
14
- spec.homepage = "https://github.com/fzdp/richat"
15
- spec.license = "MIT"
16
-
17
- # to allow pushing to a single host or delete this section to allow pushing to any host.
18
- if spec.respond_to?(:metadata)
19
- spec.metadata["homepage_uri"] = spec.homepage
20
- spec.metadata["source_code_uri"] = "https://github.com/fzdp/richat"
21
- else
22
- raise "RubyGems 2.0 or newer is required to protect against " \
23
- "public gem pushes."
24
- end
25
-
26
- # Specify which files should be added to the gem when it is released.
27
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
29
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
- end
31
- spec.bindir = "exe"
32
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
- spec.require_paths = ["lib"]
34
-
35
- spec.add_development_dependency "bundler", "~> 1.17"
36
- spec.add_development_dependency "rake", "~> 10.0"
37
- spec.add_development_dependency "rspec", "~> 3.0"
38
- end