@docupace/pipeline 1.0.0-alpha.61 → 1.0.0-alpha.62
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 +57 -32
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.62",
|
|
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 { Configuration, OpenAIApi } from "openai";
|
|
8
|
+
|
|
7
9
|
|
|
8
10
|
const program = new Command();
|
|
9
11
|
|
|
@@ -143,42 +145,65 @@ program
|
|
|
143
145
|
const summary = jiraTicketData.fields.summary;
|
|
144
146
|
console.log(`Jira ticket summary: ${summary}`);
|
|
145
147
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
additionalProperties: false,
|
|
148
|
+
// Step 4: Call OpenAI API to determine change type
|
|
149
|
+
const openAiConfiguration = new Configuration({
|
|
150
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
151
|
+
});
|
|
152
|
+
const openai = new OpenAIApi(openAiConfiguration);
|
|
153
|
+
|
|
154
|
+
const openAiResponse = await openai.createChatCompletion({
|
|
155
|
+
model: "gpt-4",
|
|
156
|
+
messages: [
|
|
157
|
+
{
|
|
158
|
+
role: "system",
|
|
159
|
+
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`,
|
|
159
160
|
},
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
{
|
|
162
|
+
role: "user",
|
|
163
|
+
content: `Schema:
|
|
164
|
+
{
|
|
165
|
+
"name": "change_request",
|
|
166
|
+
"strict": true,
|
|
167
|
+
"schema": {
|
|
168
|
+
"type": "object",
|
|
169
|
+
"properties": {
|
|
170
|
+
"change_type": {
|
|
171
|
+
"type": "string",
|
|
172
|
+
"description": "The type of change requested, either a patch or minor update.",
|
|
173
|
+
"enum": [
|
|
174
|
+
"patch",
|
|
175
|
+
"minor"
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
"summary": {
|
|
179
|
+
"type": "string",
|
|
180
|
+
"description": "A brief summary of the change being requested."
|
|
181
|
+
},
|
|
182
|
+
"jira_ticket_id": {
|
|
183
|
+
"type": "string",
|
|
184
|
+
"description": "The ID of the related Jira ticket associated with this change request."
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
"required": [
|
|
188
|
+
"change_type",
|
|
189
|
+
"summary",
|
|
190
|
+
"jira_ticket_id"
|
|
191
|
+
],
|
|
192
|
+
"additionalProperties": false
|
|
193
|
+
}
|
|
194
|
+
}`,
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
role: "user",
|
|
198
|
+
content: jiraTicketData,
|
|
199
|
+
},
|
|
200
|
+
],
|
|
162
201
|
});
|
|
163
202
|
|
|
164
|
-
|
|
203
|
+
const assistantResponse = openAiResponse.data.choices[0].message.content;
|
|
204
|
+
const parsedResponse = JSON.parse(assistantResponse);
|
|
165
205
|
|
|
166
|
-
|
|
167
|
-
const openAiApiKey = process.env.OPENAI_API_KEY;
|
|
168
|
-
const openAiResponse = await fetch('https://api.openai.com/v1/assistants/asst_ronjCuCINK5pjLusTB9XCGYG/completions', {
|
|
169
|
-
method: 'POST',
|
|
170
|
-
headers: {
|
|
171
|
-
Authorization: `Bearer ${openAiApiKey}`,
|
|
172
|
-
'Content-Type': 'application/json',
|
|
173
|
-
},
|
|
174
|
-
body,
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
if (!openAiResponse.ok) {
|
|
178
|
-
throw new Error(`Failed to call OpenAI assistant. Status: ${openAiResponse.status}`);
|
|
179
|
-
}
|
|
180
|
-
const openAiData = await openAiResponse.json();
|
|
181
|
-
const { change_type } = openAiData.result;
|
|
206
|
+
const { change_type } = parsedResponse;
|
|
182
207
|
console.log(`Determined change type: ${change_type}`);
|
|
183
208
|
|
|
184
209
|
// Step 5: Create a changeset using pnpm
|