luo 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/luo/error_handle.rb +35 -0
- data/lib/luo/helpers.rb +1 -10
- data/lib/luo/version.rb +1 -1
- data/lib/luo.rb +2 -0
- data/templates/prompts/luo_error_analyze.md.erb +9 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e2f307cd4e0e397dfda5f5a540267d519bfac40dd0f7067948aa6211b6280a1
|
4
|
+
data.tar.gz: 763b3ae18becb12d6546667567406673564ee5016675424986dcfc3bdf288528
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48dbac5c5f6101910faa01d556a29368ef5bc19289ca0021746bd3b6a62e1414b14efb71b63a3791c92ecc4c371b49168bd956cb01b5804309f8b18f6301aa44
|
7
|
+
data.tar.gz: e048e9fa7ab6554a8752acbbeb757633bb149a9e8b24edd9dd023305fecef0b9d9ba32801a4ce9b2f8da35b99fbb0a7c5801b5bc2dc2e3620b68cb72b7b6e477
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Luo
|
4
|
+
module ErrorHandle
|
5
|
+
def raise(err, *args)
|
6
|
+
Luo::ErrorHandle.gpt_error_analyze(err)
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def fail(*args)
|
11
|
+
raise(*args)
|
12
|
+
end
|
13
|
+
|
14
|
+
def gpt_error_analyze(error)
|
15
|
+
if error
|
16
|
+
error_message = error.message
|
17
|
+
backtrace = error.backtrace
|
18
|
+
|
19
|
+
context = {
|
20
|
+
message: error_message,
|
21
|
+
backtrace: backtrace
|
22
|
+
}
|
23
|
+
Helpers.display_md(" **你的代码出错了!正在使用 ChatGPT 分析错误原因,请稍后 ... **")
|
24
|
+
|
25
|
+
messages = Messages.create
|
26
|
+
.system(text: "你是一个ruby专家,根据用户的输入,你需要分析出错误的原因,然后给出解决方案。")
|
27
|
+
.user(prompt: Prompts.luo_error_analyze, context: context)
|
28
|
+
response = OpenAI.new.chat(messages)
|
29
|
+
|
30
|
+
Helpers.display_md(response)
|
31
|
+
puts "\n"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/luo/helpers.rb
CHANGED
@@ -20,16 +20,7 @@ module Luo
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def display_md(text)
|
23
|
-
|
24
|
-
raise "Please install iruby gem first."
|
25
|
-
end
|
26
|
-
|
27
|
-
if gem_exists?('rouge')
|
28
|
-
renderer = HTMLwithRouge.new
|
29
|
-
else
|
30
|
-
renderer = Redcarpet::Render::HTML.new
|
31
|
-
end
|
32
|
-
|
23
|
+
renderer = HTMLwithRouge.new
|
33
24
|
markdown = Redcarpet::Markdown.new(renderer,
|
34
25
|
autolink: true,
|
35
26
|
tables: true,
|
data/lib/luo/version.rb
CHANGED
data/lib/luo.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: luo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MJ
|
@@ -233,6 +233,7 @@ files:
|
|
233
233
|
- lib/luo/cli/init_base.rb
|
234
234
|
- lib/luo/cli/init_notebook.rb
|
235
235
|
- lib/luo/configurable.rb
|
236
|
+
- lib/luo/error_handle.rb
|
236
237
|
- lib/luo/helpers.rb
|
237
238
|
- lib/luo/http_client.rb
|
238
239
|
- lib/luo/init_project._rb
|
@@ -279,6 +280,7 @@ files:
|
|
279
280
|
- templates/prompts/agent_tool_input.md.erb
|
280
281
|
- templates/prompts/luo_commit.md.erb
|
281
282
|
- templates/prompts/luo_error.md.erb
|
283
|
+
- templates/prompts/luo_error_analyze.md.erb
|
282
284
|
- templates/prompts/xinghuo_agent_input.md.erb
|
283
285
|
- templates/prompts/xinghuo_response_error.md.erb
|
284
286
|
- templates/test.yml
|