@docupace/pipeline 1.0.0-alpha.61 → 1.0.0-alpha.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/changeset/cli.js +60 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docupace/pipeline",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.63",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"commander": "^12.1.0",
|
|
18
18
|
"js-yaml": "^4.1.0",
|
|
19
|
+
"openai": "^4.76.3",
|
|
19
20
|
"zx": "^8.2.4"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
package/src/changeset/cli.js
CHANGED
|
@@ -4,6 +4,8 @@ import { $ } from 'zx';
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import {validateChangesets} from "./validate.js";
|
|
6
6
|
import fs from 'fs';
|
|
7
|
+
import openai from "openai";
|
|
8
|
+
|
|
7
9
|
|
|
8
10
|
const program = new Command();
|
|
9
11
|
|
|
@@ -143,42 +145,69 @@ program
|
|
|
143
145
|
const summary = jiraTicketData.fields.summary;
|
|
144
146
|
console.log(`Jira ticket summary: ${summary}`);
|
|
145
147
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
strict: true,
|
|
150
|
-
schema: {
|
|
151
|
-
type: 'object',
|
|
152
|
-
properties: {
|
|
153
|
-
change_type: { type: 'string', enum: ['patch', 'minor'] },
|
|
154
|
-
summary: { type: 'string' },
|
|
155
|
-
jira_ticket_id: { type: 'string' },
|
|
156
|
-
},
|
|
157
|
-
required: ['change_type', 'summary', 'jira_ticket_id'],
|
|
158
|
-
additionalProperties: false,
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
data: jiraTicketData,
|
|
148
|
+
// Step 4: Call OpenAI API to determine change type
|
|
149
|
+
const openAiConfiguration = new Configuration({
|
|
150
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
162
151
|
});
|
|
163
152
|
|
|
164
|
-
console.log(body);
|
|
165
153
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
154
|
+
const openaiClient = new openai.OpenAIApi(new openai.Configuration({
|
|
155
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
156
|
+
}));
|
|
157
|
+
|
|
158
|
+
const openAiResponse = await openaiClient.createChatCompletion({
|
|
159
|
+
model: "gpt-4",
|
|
160
|
+
messages: [
|
|
161
|
+
{
|
|
162
|
+
role: "system",
|
|
163
|
+
content: `Process JSON from a Jira ticket to generate simple maximum 2 sentence release note for the ticket and determine the change type for bug it should be a patch for new feature it should be a minor change`,
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
role: "user",
|
|
167
|
+
content: `Schema:
|
|
168
|
+
{
|
|
169
|
+
"name": "change_request",
|
|
170
|
+
"strict": true,
|
|
171
|
+
"schema": {
|
|
172
|
+
"type": "object",
|
|
173
|
+
"properties": {
|
|
174
|
+
"change_type": {
|
|
175
|
+
"type": "string",
|
|
176
|
+
"description": "The type of change requested, either a patch or minor update.",
|
|
177
|
+
"enum": [
|
|
178
|
+
"patch",
|
|
179
|
+
"minor"
|
|
180
|
+
]
|
|
181
|
+
},
|
|
182
|
+
"summary": {
|
|
183
|
+
"type": "string",
|
|
184
|
+
"description": "A brief summary of the change being requested."
|
|
185
|
+
},
|
|
186
|
+
"jira_ticket_id": {
|
|
187
|
+
"type": "string",
|
|
188
|
+
"description": "The ID of the related Jira ticket associated with this change request."
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"required": [
|
|
192
|
+
"change_type",
|
|
193
|
+
"summary",
|
|
194
|
+
"jira_ticket_id"
|
|
195
|
+
],
|
|
196
|
+
"additionalProperties": false
|
|
197
|
+
}
|
|
198
|
+
}`,
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
role: "user",
|
|
202
|
+
content: jiraTicketData,
|
|
203
|
+
},
|
|
204
|
+
],
|
|
175
205
|
});
|
|
176
206
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
const { change_type } = openAiData.result;
|
|
207
|
+
const assistantResponse = openAiResponse.data.choices[0].message.content;
|
|
208
|
+
const parsedResponse = JSON.parse(assistantResponse);
|
|
209
|
+
|
|
210
|
+
const { change_type } = parsedResponse;
|
|
182
211
|
console.log(`Determined change type: ${change_type}`);
|
|
183
212
|
|
|
184
213
|
// Step 5: Create a changeset using pnpm
|