chat_gpt_error_handler 0.1.0 → 0.1.1
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 -6
- 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: 1fd24aab4edf0e7e07a010bcc31ebed6f8777b2762ba32a017864841a0a7293c
|
4
|
+
data.tar.gz: 48e0f9e6947492ea28f24d20a338b6d943f7db9726c8659c0347789b914170b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77e2d20c1720bef22f47b5e7bb64e7737b8b0e3ecf8f9def63dccbe1901b12fdbdcc276cdecc9d704256954c247deaab3a15dc63081b311dc886cedd8fff471f
|
7
|
+
data.tar.gz: f9fe79b6e1302b5ae071a7e3df15f037b3fc30273a1ea7dd9e35c141d8e59f819f35ae1039783ec9e12e31363213ad5da35b42b9c75b74a14519563084589d67
|
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,9 +61,7 @@ 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
|
|
@@ -77,9 +75,9 @@ module ChatGptErrorHandler
|
|
77
75
|
end
|
78
76
|
|
79
77
|
def print_error_and_solution(error, response_text)
|
80
|
-
puts "\e[31;1mOriginal
|
78
|
+
puts "\e[31;1mOriginal error message:\e[0m\n\n"
|
81
79
|
puts error.message
|
82
|
-
puts "\n\n\e[34;
|
80
|
+
puts "\n\n\e[34;1mChatGPT's best guess to remedy the error:\e[0m"
|
83
81
|
puts "\n"
|
84
82
|
puts response_text
|
85
83
|
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.1
|
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
|