newsman 0.1.12 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/newsman/assistant.rb +149 -0
- data/lib/newsman/issues.rb +17 -2
- data/lib/newsman/pull_request.rb +8 -1
- data/lib/newsman/report.rb +29 -2
- data/lib/newsman.rb +43 -65
- data/test/test_assistant.rb +33 -0
- data/test/test_report.rb +14 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a68ba87116b71adc25a5983ee3b91cc94414b27edee46781fdec6141988a278
|
4
|
+
data.tar.gz: 02f0cb536bbe01e60578755227a0b0a03eed4c6086bceebcee399f6ae2a53aba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e247fd019a04cc39c3d9bb3e2bc0db202947941cad27e968501f9d355308ee4704b6f8c76267e1b2953f00996e15a2c5c6c5dd03e7712f93e400ab3fd3633e7
|
7
|
+
data.tar.gz: 2d416b5a3476432636e78fe08d18bc3480539ecaea6f896c757a99a85d11b0be47aa7459448c9b3a536f942828d6e2cf512a5cc5c6f1296248b03f33bae8f249
|
data/README.md
CHANGED
@@ -65,4 +65,4 @@ And you should see a welcome message from newsman.
|
|
65
65
|
|
66
66
|
## Examples
|
67
67
|
|
68
|
-
You can find examples of generated reports [here](https://
|
68
|
+
You can find examples of generated reports [here](https://volodya-lombrozo.github.io/newsman/)
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require 'openai'
|
2
|
+
|
3
|
+
class Assistant
|
4
|
+
|
5
|
+
CONTEXT = 'You are a developer tasked with composing a concise report detailing your activities and progress for the previous week, intended for submission to your supervisor.'
|
6
|
+
|
7
|
+
def initialize(token, model: 'gpt-3.5-turbo', temperature: 0.3)
|
8
|
+
@token = token
|
9
|
+
@model = model
|
10
|
+
@temperature = temperature
|
11
|
+
@client = OpenAI::Client.new(access_token: token)
|
12
|
+
end
|
13
|
+
|
14
|
+
def say_hello
|
15
|
+
"I'm an assistant that can work with OpenAI client. Please, use me, if you need any help. I'm using #{@model}, with #{@temperature} temperature."
|
16
|
+
end
|
17
|
+
|
18
|
+
def next_plans(issues)
|
19
|
+
example = "repository-name:\n
|
20
|
+
- To publish ABC package draft [#27]\n
|
21
|
+
- To review first draft of the report [#56]\n
|
22
|
+
- To implement optimization for the class X [#125]"
|
23
|
+
return send("Please compile a summary of the plans for the next week using the following GitHub Issues descriptions. Each issue should be summarized in a single sentence, focusing more on the issue title and less on implementation details. Pay attention, that you didn't loose any issue. Ensure that each sentence includes the corresponding issue number as an integer value. If an issue doesn't mention an issue number, just print [#chore]. Combine all the information from each Issue into a concise and fluent sentences, as if you were a developer reporting on your work. Please strictly adhere to the example template provided: ```#{example}```. List of GitHub issues to aggregate: [#{issues}].")
|
24
|
+
end
|
25
|
+
|
26
|
+
def prev_results(prs)
|
27
|
+
example = "repository-name:\n
|
28
|
+
- Added 100 new files to the Dataset [#168]\n
|
29
|
+
- Fixed the deployment of XYZ [#169]\n
|
30
|
+
- Refined the requirements [#177]\n"
|
31
|
+
return send("Please compile a summary of the work completed in the following Pull Requests (PRs). Each PR should be summarized in a single sentence, focusing more on the PR title and less on implementation details. Pay attention, that you don't lose any PR. Ensure that each sentence includes the corresponding issue number as an integer value. If a PR doesn't mention an issue number, just print [#chore]. Combine all the information from each PR into a concise and fluent sentence, as if you were a developer reporting on your work. Please strictly adhere to the example template provided: ```#{example}```. List of Pull Requests: [#{prs}]")
|
32
|
+
end
|
33
|
+
|
34
|
+
def risks(all)
|
35
|
+
example = "repository-name:\n
|
36
|
+
- The server is weak, we may fail the delivery\n
|
37
|
+
of the dataset, report milestone will be missed [#487].\n
|
38
|
+
- The code in repository is suboptimal, we might have some problems for the future maintainability [#44].\n"
|
39
|
+
return send("Please compile a summary of the risks identified in the repository. If you can't find anything, just answer 'No risks identified'. Developers usually mention some risks in pull request descriptions. They either mention 'risk' or 'issue'. I will give you a list of pull requests. Each risk should be summarized in a single sentence. Ensure that each sentence includes the corresponding PR number as an integer value. If a PR doesn't mention an issue number, just print [#chore]. Combine all the information from each PR into a concise and fluent sentence, as if you were a developer reporting on your work. Please strictly adhere to the example template provided: ```#{example}```. List of Pull Requests: [#{all}]")
|
40
|
+
end
|
41
|
+
|
42
|
+
def old_prev_results(prs)
|
43
|
+
deprecated(__method__)
|
44
|
+
example = "some-repository-name-x:
|
45
|
+
- Added 100 new files to the Dataset [#168]
|
46
|
+
- Fixed the deployment of XYZ [#169]
|
47
|
+
- Refined the requirements [#177]
|
48
|
+
some-repository-name-y:
|
49
|
+
- Removed XYZ class [#57]
|
50
|
+
- Refactored http module [#69]"
|
51
|
+
response = @client.chat(
|
52
|
+
parameters: {
|
53
|
+
model: 'gpt-3.5-turbo',
|
54
|
+
messages: [
|
55
|
+
{ role: 'system',
|
56
|
+
content: 'You are a developer tasked with composing a concise report detailing your activities and progress for the previous week, intended for submission to your supervisor.' },
|
57
|
+
{ role: 'user',
|
58
|
+
content: "Please compile a summary of the work completed in the following Pull Requests (PRs). Each PR should be summarized in a single sentence, focusing more on the PR title and less on implementation details. Group the sentences by repositories, each identified by its name mentioned in the 'repository:[name]' attribute of the PR. Pay attention, that you don't lose any PR. The grouping is important an should be precise. Ensure that each sentence includes the corresponding issue number as an integer value. If a PR doesn't mention an issue number, just print [#chore]. Combine all the information from each PR into a concise and fluent sentence, as if you were a developer reporting on your work. Please strictly adhere to the example template provided. Example of a report: #{example}. List of Pull Requests: [#{prs}]" }
|
59
|
+
],
|
60
|
+
temperature: 0.3
|
61
|
+
}
|
62
|
+
)
|
63
|
+
answer = response.dig('choices', 0, 'message', 'content')
|
64
|
+
return answer
|
65
|
+
end
|
66
|
+
|
67
|
+
def old_next_plans(issues)
|
68
|
+
deprecated(__method__)
|
69
|
+
example_plans = "some-repository-name-x:
|
70
|
+
- To publish ABC package draft [#27]
|
71
|
+
- To review first draft of the report [#56]
|
72
|
+
some-repository-name-y:
|
73
|
+
- To implement optimization for the class X [#125]"
|
74
|
+
issues_response = @client.chat(
|
75
|
+
parameters: {
|
76
|
+
model: 'gpt-3.5-turbo',
|
77
|
+
messages: [
|
78
|
+
{ role: 'system',
|
79
|
+
content: 'You are a developer tasked with composing a concise report detailing your activities and progress for the previous week, intended for submission to your supervisor.' },
|
80
|
+
{ role: 'user',
|
81
|
+
content: "Please compile a summary of the plans for the next week using the following GitHub Issues descriptions. Each issue should be summarized in a single sentence, focusing more on the issue title and less on implementation details. Group the sentences by repositories, each identified by its name mentioned in the 'repository:[name]' attribute of the issue. Pat attention, that you din't loose any issue. The grouping is important an should be precise. Ensure that each sentence includes the corresponding issue number as an integer value. If an issue doesn't mention an issue number, just print [#chore]. Combine all the information from each Issue into a concise and fluent sentences, as if you were a developer reporting on your work. Please strictly adhere to the example template provided: #{example_plans}. List of GitHub issues to aggregate: [#{issues}]." }
|
82
|
+
],
|
83
|
+
temperature: 0.3
|
84
|
+
}
|
85
|
+
)
|
86
|
+
issues_full_answer = issues_response.dig('choices', 0, 'message', 'content')
|
87
|
+
return issues_full_answer
|
88
|
+
end
|
89
|
+
|
90
|
+
def old_risks(all)
|
91
|
+
deprecated(__method__)
|
92
|
+
example_risks = "some-repository-name-x:
|
93
|
+
- The server is weak, we may fail the delivery
|
94
|
+
of the dataset, report milestone will be missed [#487].
|
95
|
+
some-repository-name-y:
|
96
|
+
- The code in repository is suboptimal, we might have some problems for the future maintainability [#44]."
|
97
|
+
return @client.chat(
|
98
|
+
parameters: {
|
99
|
+
model: 'gpt-3.5-turbo',
|
100
|
+
messages: [
|
101
|
+
{ role: 'system',
|
102
|
+
content: 'You are a developer tasked with composing a concise report detailing your activities and progress for the previous week, intended for submission to your supervisor.' },
|
103
|
+
{ role: 'user',
|
104
|
+
content: "Please compile a summary of the risks identified in some repositories. If you can't find anything, just leave answer empty. Add some entries to a report only if you are sure it's a risk. Developers usually mention some risks in pull request descriptions. They either mention 'risk' or 'issue'. I will give you a list of pull requests. Each risk should be summarized in a single sentence. Ensure that each sentence includes the corresponding issue number or PR number as an integer value. If a PR or an issue doesn't mention an issue number, just print [#chore]. Combine all the information from each PR into a concise and fluent sentence, as if you were a developer reporting on your work. Please strictly adhere to the example template provided. Example of a report: #{example_risks}. List of Pull Requests: ```#{all}```.]" }
|
105
|
+
],
|
106
|
+
temperature: 0.3
|
107
|
+
}
|
108
|
+
).dig('choices', 0, 'message', 'content')
|
109
|
+
end
|
110
|
+
|
111
|
+
def send(request)
|
112
|
+
return @client.chat(
|
113
|
+
parameters: {
|
114
|
+
model: @model,
|
115
|
+
messages: [
|
116
|
+
{ role: 'system',
|
117
|
+
content: CONTEXT },
|
118
|
+
{ role: 'user',
|
119
|
+
content: "#{request}" }
|
120
|
+
],
|
121
|
+
temperature: @temperature
|
122
|
+
}
|
123
|
+
).dig('choices', 0, 'message', 'content')
|
124
|
+
end
|
125
|
+
|
126
|
+
def deprecated(method)
|
127
|
+
warn "Warning! '#{method}' is deprecated and will be removed in future versions."
|
128
|
+
end
|
129
|
+
|
130
|
+
def send(request)
|
131
|
+
return @client.chat(
|
132
|
+
parameters: {
|
133
|
+
model: @model,
|
134
|
+
messages: [
|
135
|
+
{ role: 'system',
|
136
|
+
content: CONTEXT },
|
137
|
+
{ role: 'user',
|
138
|
+
content: "#{request}" }
|
139
|
+
],
|
140
|
+
temperature: @temperature
|
141
|
+
}
|
142
|
+
).dig('choices', 0, 'message', 'content')
|
143
|
+
end
|
144
|
+
|
145
|
+
def deprecated(method)
|
146
|
+
warn "Warning! '#{method}' is deprecated and will be removed in future versions."
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
data/lib/newsman/issues.rb
CHANGED
@@ -5,25 +5,35 @@ require 'net/http'
|
|
5
5
|
|
6
6
|
class Issue
|
7
7
|
attr_accessor :title, :body, :repo, :number
|
8
|
+
attr_reader :url
|
8
9
|
|
9
|
-
def initialize(title, body, repo, number)
|
10
|
+
def initialize(title, body, repo, number, url: 'undefined')
|
10
11
|
@title = title
|
11
12
|
@body = body
|
12
13
|
@repo = repo
|
13
14
|
@number = number
|
15
|
+
@url = url
|
14
16
|
end
|
15
17
|
|
16
18
|
def to_s
|
17
19
|
"title: ```#{@title}```,\ndescription: ```#{@body}```,\nrepo: ```#{@repo}```,\nissue number: \##{@number}\n"
|
18
20
|
end
|
21
|
+
|
22
|
+
def detailed_title
|
23
|
+
"title: #{@title}, repo: #{@repo}, number: \##{@number}, url: #{@url}"
|
24
|
+
end
|
25
|
+
|
19
26
|
end
|
20
27
|
|
21
28
|
class PddIssue
|
22
|
-
|
29
|
+
attr_accessor :repo
|
30
|
+
|
31
|
+
def initialize(title, body, repo, number, url: 'undefined')
|
23
32
|
@title = title
|
24
33
|
@body = body
|
25
34
|
@repo = repo
|
26
35
|
@number = number
|
36
|
+
@url = url
|
27
37
|
end
|
28
38
|
|
29
39
|
def extract_real_body
|
@@ -42,4 +52,9 @@ class PddIssue
|
|
42
52
|
def to_s
|
43
53
|
"title: ```#{@title}```,\ndescription: ```#{extract_real_body}```,\nrepo: ```#{@repo}```,\nissue number: \##{@number}\n"
|
44
54
|
end
|
55
|
+
|
56
|
+
def detailed_title
|
57
|
+
"title: #{@title}, repo: #{@repo}, issue number: \##{@number}, url: #{@url}"
|
58
|
+
end
|
59
|
+
|
45
60
|
end
|
data/lib/newsman/pull_request.rb
CHANGED
@@ -2,14 +2,21 @@
|
|
2
2
|
|
3
3
|
class PullRequest
|
4
4
|
attr_accessor :repository, :title, :description
|
5
|
+
attr_reader :url
|
5
6
|
|
6
|
-
def initialize(repository, title, description)
|
7
|
+
def initialize(repository, title, description, url: 'undefined')
|
7
8
|
@repository = repository
|
8
9
|
@title = title
|
9
10
|
@description = description
|
11
|
+
@url = url
|
10
12
|
end
|
11
13
|
|
12
14
|
def to_s
|
13
15
|
"title: ```#{@title}```,\ndescription: ```#{@description}```,\nrepo: ```#{@repository}```\n"
|
14
16
|
end
|
17
|
+
|
18
|
+
def detailed_title
|
19
|
+
"title: #{@title}, repo: #{@repository}, url: #{@url}"
|
20
|
+
end
|
21
|
+
|
15
22
|
end
|
data/lib/newsman/report.rb
CHANGED
@@ -2,15 +2,22 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
class Report
|
5
|
-
def initialize(user, position, title)
|
5
|
+
def initialize(user, position, title, additional: ReportItems.new([],[]))
|
6
6
|
@user = user
|
7
7
|
@position = position
|
8
8
|
@title = title
|
9
|
+
@additional = additional
|
9
10
|
end
|
10
11
|
|
11
12
|
def build(achievements, plans, risks, date)
|
12
|
-
"From: #{@user}\nSubject: #{week_of_a_year(@title,
|
13
|
+
start = "From: #{@user}\nSubject: #{week_of_a_year(@title,
|
13
14
|
date)}\n\nHi all,\n\nLast week achievements:\n#{achievements}\n\nNext week plans:\n#{plans}\n\nRisks:\n#{risks}\n\nBest regards,\n#{@user}\n#{@position}\n#{date}"
|
15
|
+
|
16
|
+
finish = ''
|
17
|
+
if !@additional.empty?
|
18
|
+
finish = "\n------\n" + @additional.to_s
|
19
|
+
end
|
20
|
+
return start + finish;
|
14
21
|
end
|
15
22
|
end
|
16
23
|
|
@@ -18,3 +25,23 @@ def week_of_a_year(project, today)
|
|
18
25
|
number = today.strftime('%U').to_i + 1
|
19
26
|
"WEEK #{number} #{project}"
|
20
27
|
end
|
28
|
+
|
29
|
+
|
30
|
+
class ReportItems
|
31
|
+
|
32
|
+
def initialize(prs, issues)
|
33
|
+
@prs = prs || []
|
34
|
+
@issues = issues || []
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns true if there are no pull requests or issues, false otherwise
|
38
|
+
def empty?
|
39
|
+
@prs.empty? && @issues.empty?
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_s
|
43
|
+
prs_list = @prs.map(&:detailed_title).map { |obj| " - #{obj}\n" }.join
|
44
|
+
issues_list = @issues.map(&:detailed_title).map { |obj| " - #{obj}\n" }.join
|
45
|
+
return "Closed Pull Requests:\n#{prs_list}\nOpen Issues:\n#{issues_list}"
|
46
|
+
end
|
47
|
+
end
|
data/lib/newsman.rb
CHANGED
@@ -11,6 +11,7 @@ require_relative 'newsman/stdout_output'
|
|
11
11
|
require_relative 'newsman/txt_output'
|
12
12
|
require_relative 'newsman/html_output'
|
13
13
|
require_relative 'newsman/report'
|
14
|
+
require_relative 'newsman/assistant'
|
14
15
|
|
15
16
|
def generate
|
16
17
|
# Load all options required
|
@@ -91,10 +92,12 @@ def generate
|
|
91
92
|
repository = pr.repository_url.split('/').last
|
92
93
|
puts "Found PR in #{repository}: #{title}"
|
93
94
|
# Create a new PullRequest object and add it to the list
|
94
|
-
pr = PullRequest.new(repository, title, description)
|
95
|
+
pr = PullRequest.new(repository, title, description, url: pr.html_url)
|
95
96
|
prs << pr
|
96
97
|
end
|
98
|
+
raw_prs = prs
|
97
99
|
prs = prs.map(&:to_s).join("\n\n\n")
|
100
|
+
grouped_prs = raw_prs.group_by { |pr| pr.repository }
|
98
101
|
|
99
102
|
puts "Searching issues using the following query: '#{issues_query}'"
|
100
103
|
issues = []
|
@@ -105,82 +108,57 @@ def generate
|
|
105
108
|
number = issue.number.to_s
|
106
109
|
puts "Found issue in #{repository}:[##{number}] #{title}"
|
107
110
|
issues << if issue.user.login == '0pdd'
|
108
|
-
PddIssue.new(title, body, repository, number)
|
111
|
+
PddIssue.new(title, body, repository, number, url: issue.html_url)
|
109
112
|
else
|
110
|
-
Issue.new(title, body, repository, number)
|
113
|
+
Issue.new(title, body, repository, number, url: issue.html_url)
|
111
114
|
end
|
112
115
|
end
|
116
|
+
raw_issues = issues
|
113
117
|
issues = issues.map(&:to_s).join("\n\n\n")
|
114
|
-
|
118
|
+
grouped_issues = raw_issues.group_by { |iss| iss.repo }
|
115
119
|
|
116
120
|
puts "\nNow lets test some aggregation using OpenAI\n\n"
|
117
121
|
openai_client = OpenAI::Client.new(access_token: openai_token)
|
122
|
+
|
123
|
+
assistant = Assistant.new(openai_token)
|
124
|
+
|
125
|
+
old_way = false
|
126
|
+
if old_way
|
127
|
+
answer = assistant.old_prev_results(prs)
|
128
|
+
issues_full_answer = assistant.old_next_plans(issues)
|
129
|
+
risks_full_answer = assistant.old_risks(prs)
|
130
|
+
else
|
131
|
+
puts "Assistant builds a report using a new approach, using groupping"
|
132
|
+
# Build previous results
|
133
|
+
answer = ""
|
134
|
+
grouped_prs.each do |repository, rprs|
|
135
|
+
puts "Building a results report for the repository: #{repository}"
|
136
|
+
answer = answer + assistant.prev_results(rprs.map(&:to_s).join("\n\n\n"))
|
137
|
+
end
|
138
|
+
# Build next plans
|
139
|
+
issues_full_answer = ""
|
140
|
+
grouped_issues.each do |repository, rissues|
|
141
|
+
puts "Building a future plans report for the repository: #{repository}"
|
142
|
+
issues_full_answer = issues_full_answer + assistant.next_plans(rissues.map(&:to_s).join("\n\n\n"))
|
143
|
+
end
|
144
|
+
# Find risks
|
145
|
+
risks_full_answer = assistant.risks(prs)
|
146
|
+
end
|
118
147
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
- To review first draft of the report [#56]
|
130
|
-
some-repository-name-y:
|
131
|
-
- To implement optimization for the class X [#125]"
|
132
|
-
|
133
|
-
example_risks = "some-repository-name-x:
|
134
|
-
- The server is weak, we may fail the delivery
|
135
|
-
of the dataset, report milestone will be missed [#487].
|
136
|
-
some-repository-name-y:
|
137
|
-
- The code in repository is suboptimal, we might have some problems for the future maintainability [#44].
|
138
|
-
"
|
139
|
-
|
140
|
-
response = openai_client.chat(
|
141
|
-
parameters: {
|
142
|
-
model: 'gpt-3.5-turbo',
|
143
|
-
messages: [
|
144
|
-
{ role: 'system',
|
145
|
-
content: 'You are a developer tasked with composing a concise report detailing your activities and progress for the previous week, intended for submission to your supervisor.' },
|
146
|
-
{ role: 'user',
|
147
|
-
content: "Please compile a summary of the work completed in the following Pull Requests (PRs). Each PR should be summarized in a single sentence, focusing more on the PR title and less on implementation details. Group the sentences by repositories, each identified by its name mentioned in the 'repository:[name]' attribute of the PR. Pay attention, that you don't lose any PR. The grouping is important an should be precise. Ensure that each sentence includes the corresponding issue number as an integer value. If a PR doesn't mention an issue number, just print [#chore]. Combine all the information from each PR into a concise and fluent sentence, as if you were a developer reporting on your work. Please strictly adhere to the example template provided. Example of a report: #{example}. List of Pull Requests: [#{prs}]" }
|
148
|
-
],
|
149
|
-
temperature: 0.3
|
150
|
-
}
|
148
|
+
full_answer = Report.new(
|
149
|
+
reporter,
|
150
|
+
reporter_position,
|
151
|
+
options[:title],
|
152
|
+
additional: ReportItems.new(raw_prs, raw_issues)
|
153
|
+
).build(
|
154
|
+
answer,
|
155
|
+
issues_full_answer,
|
156
|
+
risks_full_answer,
|
157
|
+
Date.today
|
151
158
|
)
|
152
|
-
answer = response.dig('choices', 0, 'message', 'content')
|
153
|
-
issues_response = openai_client.chat(
|
154
|
-
parameters: {
|
155
|
-
model: 'gpt-3.5-turbo',
|
156
|
-
messages: [
|
157
|
-
{ role: 'system',
|
158
|
-
content: 'You are a developer tasked with composing a concise report detailing your activities and progress for the previous week, intended for submission to your supervisor.' },
|
159
|
-
{ role: 'user',
|
160
|
-
content: "Please compile a summary of the plans for the next week using the following GitHub Issues descriptions. Each issue should be summarized in a single sentence, focusing more on the issue title and less on implementation details. Group the sentences by repositories, each identified by its name mentioned in the 'repository:[name]' attribute of the issue. Pat attention, that you din't loose any issue. The grouping is important an should be precise. Ensure that each sentence includes the corresponding issue number as an integer value. If an issue doesn't mention an issue number, just print [#chore]. Combine all the information from each Issue into a concise and fluent sentences, as if you were a developer reporting on your work. Please strictly adhere to the example template provided: #{example_plans}. List of GitHub issues to aggregate: [#{issues}]. Use the same formatting as here \n```#{answer}```\n" }
|
161
|
-
],
|
162
|
-
temperature: 0.3
|
163
|
-
}
|
164
|
-
)
|
165
|
-
issues_full_answer = issues_response.dig('choices', 0, 'message', 'content')
|
166
|
-
|
167
|
-
risks_full_answer = openai_client.chat(
|
168
|
-
parameters: {
|
169
|
-
model: 'gpt-3.5-turbo',
|
170
|
-
messages: [
|
171
|
-
{ role: 'system',
|
172
|
-
content: 'You are a developer tasked with composing a concise report detailing your activities and progress for the previous week, intended for submission to your supervisor.' },
|
173
|
-
{ role: 'user',
|
174
|
-
content: "Please compile a summary of the risks identified in some repositories. If you can't find anything, just leave answer empty. Add some entries to a report only if you are sure it's a risk. Developers usually mention some risks in pull request descriptions. They either mention 'risk' or 'issue'. I will give you a list of pull requests. Each risk should be summarized in a single sentence. Ensure that each sentence includes the corresponding issue number or PR number as an integer value. If a PR or an issue doesn't mention an issue number, just print [#chore]. Combine all the information from each PR into a concise and fluent sentence, as if you were a developer reporting on your work. Please strictly adhere to the example template provided. Example of a report: #{example_risks}. List of Pull Requests: ```#{prs}```.]" }
|
175
|
-
],
|
176
|
-
temperature: 0.3
|
177
|
-
}
|
178
|
-
).dig('choices', 0, 'message', 'content')
|
179
159
|
|
180
160
|
output_mode = options[:output]
|
181
161
|
puts "Output mode is '#{output_mode}'"
|
182
|
-
full_answer = Report.new(reporter, reporter_position, options[:title]).build(answer, issues_full_answer,
|
183
|
-
risks_full_answer, Date.today)
|
184
162
|
if output_mode.eql? 'txt'
|
185
163
|
puts 'Print result to txy file'
|
186
164
|
output = Txtout.new('.')
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Copyright (c) 2024 Volodya Lombrozo
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
|
24
|
+
require 'minitest/autorun'
|
25
|
+
require_relative '../lib/newsman/assistant'
|
26
|
+
|
27
|
+
class TestAssistant < Minitest::Test
|
28
|
+
def test_creates_default_assistant
|
29
|
+
assistant = Assistant::new('test-token');
|
30
|
+
assert_equal "I'm an assistant that can work with OpenAI client. Please, use me, if you need any help. I'm using gpt-3.5-turbo, with 0.3 temperature.", assistant.say_hello
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
data/test/test_report.rb
CHANGED
@@ -23,6 +23,8 @@
|
|
23
23
|
|
24
24
|
require 'minitest/autorun'
|
25
25
|
require_relative '../lib/newsman/report'
|
26
|
+
require_relative '../lib/newsman/issues'
|
27
|
+
require_relative '../lib/newsman/pull_request'
|
26
28
|
|
27
29
|
class TestReport < Minitest::Test
|
28
30
|
def test_report
|
@@ -51,4 +53,16 @@ Developer
|
|
51
53
|
"repository-b:\n - I will do a lot for repository (b)", '- <todo>', Date.new(2024, 3, 14))
|
52
54
|
assert_equal expected, out
|
53
55
|
end
|
56
|
+
|
57
|
+
def test_report_items
|
58
|
+
expected = "Closed Pull Requests:\n - title: title, repo: repo, url: http://some.url.com\n\nOpen Issues:\n - title: title, repo: repo, number: #123, url: http://google.com\n"
|
59
|
+
issues = [ Issue::new('title', 'body', 'repo', '123', url: 'http://google.com')]
|
60
|
+
prs = [ PullRequest::new('repo', 'title', 'body', url: 'http://some.url.com') ]
|
61
|
+
actual = ReportItems.new(prs, issues).to_s
|
62
|
+
|
63
|
+
puts actual
|
64
|
+
assert_equal expected, actual
|
65
|
+
end
|
66
|
+
|
67
|
+
|
54
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newsman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Volodya Lombrozo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -163,12 +163,14 @@ files:
|
|
163
163
|
- README.md
|
164
164
|
- bin/newsman
|
165
165
|
- lib/newsman.rb
|
166
|
+
- lib/newsman/assistant.rb
|
166
167
|
- lib/newsman/html_output.rb
|
167
168
|
- lib/newsman/issues.rb
|
168
169
|
- lib/newsman/pull_request.rb
|
169
170
|
- lib/newsman/report.rb
|
170
171
|
- lib/newsman/stdout_output.rb
|
171
172
|
- lib/newsman/txt_output.rb
|
173
|
+
- test/test_assistant.rb
|
172
174
|
- test/test_htmlout.rb
|
173
175
|
- test/test_pdd_issue.rb
|
174
176
|
- test/test_report.rb
|