resquirrel 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/README.md +7 -5
- metadata +6 -11
- data/lib/client/notion.rb +0 -41
- data/lib/client/openai.rb +0 -40
- data/lib/main.rb +0 -5
- data/lib/resquirrel/version.rb +0 -5
- data/lib/resquirrel.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7e1ffeaf1f7ec104553dabc0f016a0ae3d67a6b34638a81d26d0cca0072c1a7
|
4
|
+
data.tar.gz: fd3b10b5c35ddaf4399541f99d828b321a68ca396b46128436cd8965a853bca5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20b0e5df45f8dad12622dc5b2ff09a6485ca502ff09867ac7930981b17ef51c1f25cfbf412b56a0129196ff116a844b0ef63181f14bda9252bb28f42bdfc63c2
|
7
|
+
data.tar.gz: 0b7c49d458c503666b44da267497ab279fd078e77d8d779a1060008b2c4aaa175654dc9980e4292195204bc5bdb7fb6b10e0ff228ae8668308c8bb36b4eb8a68
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -10,7 +10,7 @@ RubyGems that automatically create release notes for Notion DB using Open AI API
|
|
10
10
|
Add this line to your application's Gemfile:
|
11
11
|
|
12
12
|
```Gemfile
|
13
|
-
gem '
|
13
|
+
gem 'resquirrel'
|
14
14
|
```
|
15
15
|
|
16
16
|
And then execute:
|
@@ -85,8 +85,9 @@ jobs:
|
|
85
85
|
```
|
86
86
|
|
87
87
|
```rb
|
88
|
-
resquirrel
|
89
|
-
|
88
|
+
require 'resquirrel'
|
89
|
+
|
90
|
+
Resquirrel.generate_release_note
|
90
91
|
```
|
91
92
|
それぞれのenvは必須です。
|
92
93
|
|
@@ -151,8 +152,9 @@ jobs:
|
|
151
152
|
```
|
152
153
|
|
153
154
|
```rb
|
154
|
-
resquirrel
|
155
|
-
|
155
|
+
require 'resquirrel'
|
156
|
+
|
157
|
+
Resquirrel.generate_release_note
|
156
158
|
```
|
157
159
|
Each env is required.
|
158
160
|
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resquirrel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yuki-snow1823
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04
|
11
|
+
date: 2024-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: RubyGems that automatically create release notes for Notion DB using
|
14
|
+
Open AI API when PR merge.
|
14
15
|
email:
|
15
16
|
- y.horikoshi.pg@gmail.com
|
16
17
|
executables: []
|
@@ -24,11 +25,6 @@ files:
|
|
24
25
|
- LICENSE.txt
|
25
26
|
- README.md
|
26
27
|
- Rakefile
|
27
|
-
- lib/client/notion.rb
|
28
|
-
- lib/client/openai.rb
|
29
|
-
- lib/main.rb
|
30
|
-
- lib/resquirrel.rb
|
31
|
-
- lib/resquirrel/version.rb
|
32
28
|
homepage: https://github.com/yuki-snow1823/resquirrel
|
33
29
|
licenses:
|
34
30
|
- MIT
|
@@ -54,6 +50,5 @@ requirements: []
|
|
54
50
|
rubygems_version: 3.5.3
|
55
51
|
signing_key:
|
56
52
|
specification_version: 4
|
57
|
-
summary:
|
58
|
-
AI API.
|
53
|
+
summary: The library to support the creation of release notes
|
59
54
|
test_files: []
|
data/lib/client/notion.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "net/http"
|
4
|
-
require "json"
|
5
|
-
|
6
|
-
class NotionClient
|
7
|
-
def initialize(api_key, database_id)
|
8
|
-
@api_key = api_key
|
9
|
-
@database_id = database_id
|
10
|
-
end
|
11
|
-
|
12
|
-
def create_release_note(summary, url)
|
13
|
-
uri = URI("https://api.notion.com/v1/pages")
|
14
|
-
request = Net::HTTP::Post.new(uri)
|
15
|
-
request["Authorization"] = "Bearer #{@api_key}"
|
16
|
-
request["Notion-Version"] = "2022-06-28"
|
17
|
-
request.content_type = "application/json"
|
18
|
-
request.body = {
|
19
|
-
parent: { type: "database_id", database_id: @database_id },
|
20
|
-
properties: {
|
21
|
-
title: {
|
22
|
-
title: [
|
23
|
-
{
|
24
|
-
type: "text",
|
25
|
-
text: {
|
26
|
-
content: summary
|
27
|
-
}
|
28
|
-
}
|
29
|
-
]
|
30
|
-
},
|
31
|
-
URL: {
|
32
|
-
url: url
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}.to_json
|
36
|
-
|
37
|
-
Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
38
|
-
http.request(request)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/lib/client/openai.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "net/http"
|
4
|
-
require "json"
|
5
|
-
|
6
|
-
class OpenAiClient
|
7
|
-
BASE_URL = "https://api.openai.com/v1"
|
8
|
-
|
9
|
-
def initialize(api_key, model: "gpt-3.5-turbo")
|
10
|
-
@api_key = api_key
|
11
|
-
@model = model
|
12
|
-
end
|
13
|
-
|
14
|
-
def summary_pr(title, body, max_tokens: 200)
|
15
|
-
uri = URI("#{BASE_URL}/chat/completions")
|
16
|
-
request = Net::HTTP::Post.new(uri)
|
17
|
-
request["Authorization"] = "Bearer #{@api_key}"
|
18
|
-
request.content_type = "application/json"
|
19
|
-
request.body = {
|
20
|
-
model: @model,
|
21
|
-
messages: [{ "role": "user",
|
22
|
-
"content":
|
23
|
-
"これからGitHub PRのタイトルと内容を送ります。
|
24
|
-
この内容を、プログラミングやウェブ技術にそれほど詳しくない人のために要約してください。
|
25
|
-
日本語で必ず返答してください。
|
26
|
-
要約の文章はタイトル:本文:のようにせず、文章だけでお願いします。
|
27
|
-
タイトルと本文を踏まえて、どのような変更があったのか文章にわかりやすくまとめてください。
|
28
|
-
以下がPRの内容です。
|
29
|
-
タイトル: #{title}
|
30
|
-
本文: #{body}" }],
|
31
|
-
max_tokens: max_tokens
|
32
|
-
}.to_json
|
33
|
-
|
34
|
-
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
35
|
-
http.request(request)
|
36
|
-
end
|
37
|
-
|
38
|
-
JSON.parse(response.body)
|
39
|
-
end
|
40
|
-
end
|
data/lib/main.rb
DELETED
data/lib/resquirrel/version.rb
DELETED
data/lib/resquirrel.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "resquirrel/version"
|
4
|
-
require_relative "client/openai"
|
5
|
-
require_relative "client/notion"
|
6
|
-
require "json"
|
7
|
-
require "logger"
|
8
|
-
|
9
|
-
module Resquirrel
|
10
|
-
def self.generate_release_note
|
11
|
-
openai_client = OpenAiClient.new(ENV["OPENAI_API_KEY"])
|
12
|
-
notion_client = NotionClient.new(ENV["NOTION_API_KEY"], ENV["NOTION_DATABASE_ID"])
|
13
|
-
logger = Logger.new($stdout)
|
14
|
-
|
15
|
-
logger.info "Getting PR information..."
|
16
|
-
pr_data = JSON.parse(File.read(ENV["GITHUB_EVENT_PATH"]))["pull_request"]
|
17
|
-
|
18
|
-
title = pr_data["title"]
|
19
|
-
body = pr_data["body"]
|
20
|
-
|
21
|
-
logger.info "Summarizing PR with OpenAI..."
|
22
|
-
response = openai_client.summary_pr(title, body)
|
23
|
-
|
24
|
-
summary = response["choices"].first["message"]["content"]
|
25
|
-
url = pr_data["html_url"]
|
26
|
-
|
27
|
-
logger.info "Updating Notion database..."
|
28
|
-
notion_client.create_release_note(summary, url)
|
29
|
-
end
|
30
|
-
end
|