chat_gpt_error_handler 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -12
- data/lib/chat_gpt_error_handler/error_handler.rb +4 -7
- data/lib/chat_gpt_error_handler/version.rb +1 -1
- data/lib/chat_gpt_error_handler.rb +4 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ff5d23745282dc3a2d6b01cd67e998e89f73074ae16ceb3e1ee63988b5361e0
|
4
|
+
data.tar.gz: 32ede69316cc4964c2497baab47e244d8e5fb8de13db2ff68d808edc71c589b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33d465f4944e318d13766a19d9328cb8bdd914c3eb98aca2e491b02a94df38cff4bfa345ad68f157f3e3c8df3e81bb5d6b887cc70adf3427302ebfff91a08a7f
|
7
|
+
data.tar.gz: e1913f58570b9ac5e3f88dbb145bfcc89ff91f58929b25235a88c6f9ba8770c29e190ba5f4877bb45436ddb9db405beab964d477e2ab48f0e3fb77737a776af8
|
data/README.md
CHANGED
@@ -1,28 +1,25 @@
|
|
1
1
|
# ChatGptErrorHandler
|
2
|
-
|
2
|
+
|
3
|
+
This gem pops a little helpful ChatGPT message before your error stacktrace.
|
4
|
+
|
5
|
+
![example](images/example.png)
|
3
6
|
|
4
7
|
## Usage
|
5
|
-
How to use my plugin.
|
6
8
|
|
7
|
-
## Installation
|
8
9
|
Add this line to your application's Gemfile:
|
9
10
|
|
10
11
|
```ruby
|
11
12
|
gem "chat_gpt_error_handler"
|
12
13
|
```
|
13
14
|
|
14
|
-
|
15
|
-
```bash
|
16
|
-
$ bundle
|
17
|
-
```
|
15
|
+
Set your [OpenAI API Token](https://openai.com/product#made-for-developers) in an initializer:
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
```ruby
|
18
|
+
# config/initializers/chat_gpt_error_handler.rb
|
19
|
+
ChatGptErrorHandler.openai_access_token = 'your_openai_access_token_here'
|
22
20
|
```
|
23
21
|
|
24
|
-
|
25
|
-
Contribution directions go here.
|
22
|
+
And you're off!
|
26
23
|
|
27
24
|
## License
|
28
25
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -6,7 +6,7 @@ module ChatGptErrorHandler
|
|
6
6
|
def initialize(app)
|
7
7
|
@app = app
|
8
8
|
OpenAI.configure do |config|
|
9
|
-
config.access_token = ENV.fetch('OPENAI_ACCESS_TOKEN')
|
9
|
+
config.access_token = ChatGptErrorHandler.openai_access_token || ENV.fetch('OPENAI_ACCESS_TOKEN')
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -61,15 +61,12 @@ module ChatGptErrorHandler
|
|
61
61
|
end
|
62
62
|
shortened_response_text = shortened_response_text.join("\n")
|
63
63
|
rescue => e
|
64
|
-
|
65
|
-
puts e.message
|
66
|
-
puts "*" * 100
|
64
|
+
# The formatting does not always work, so if it fails, just use the original response text
|
67
65
|
shortened_response_text = response_text
|
68
66
|
end
|
69
67
|
|
70
68
|
print_error_and_solution(error, shortened_response_text.strip)
|
71
69
|
rescue => gpt_error
|
72
|
-
require 'debug'; debugger
|
73
70
|
puts "\e[31mAn error occurred while communicating with GPT:\e[0m"
|
74
71
|
puts gpt_error.message
|
75
72
|
puts gpt_error.backtrace
|
@@ -77,9 +74,9 @@ module ChatGptErrorHandler
|
|
77
74
|
end
|
78
75
|
|
79
76
|
def print_error_and_solution(error, response_text)
|
80
|
-
puts "\e[31;1mOriginal
|
77
|
+
puts "\e[31;1mOriginal error message:\e[0m\n\n"
|
81
78
|
puts error.message
|
82
|
-
puts "\n\n\e[34;
|
79
|
+
puts "\n\n\e[34;1mChatGPT's best guess to remedy the error:\e[0m"
|
83
80
|
puts "\n"
|
84
81
|
puts response_text
|
85
82
|
puts "\n\n\e[34;1mFull stacktrace:\e[0m"
|
@@ -2,5 +2,8 @@ require "chat_gpt_error_handler/version"
|
|
2
2
|
require "chat_gpt_error_handler/engine"
|
3
3
|
|
4
4
|
module ChatGptErrorHandler
|
5
|
-
|
5
|
+
mattr_accessor :openai_access_token
|
6
|
+
|
7
|
+
# Default value for the openai_access_token, used when not explicitly set by the user
|
8
|
+
@@openai_access_token = nil
|
6
9
|
end
|
metadata
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chat_gpt_error_handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Schwaderer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '7.0'
|
17
20
|
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
22
|
version: 7.0.4.3
|
@@ -21,6 +24,9 @@ dependencies:
|
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '7.0'
|
24
30
|
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
32
|
version: 7.0.4.3
|