fix: first needs to be issue body
All checks were successful
Dependabot Auto-Merge / dependabot (pull_request) Has been skipped
Dependabot Auto-Merge / devopsbot (pull_request) Has been skipped
Dependabot Auto-Merge / rennovatebot (pull_request) Has been skipped
COMMIT LINT / commitlint (pull_request) Successful in 1m40s
Unit Tests / unittest (pull_request) Successful in 48s
All checks were successful
Dependabot Auto-Merge / dependabot (pull_request) Has been skipped
Dependabot Auto-Merge / devopsbot (pull_request) Has been skipped
Dependabot Auto-Merge / rennovatebot (pull_request) Has been skipped
COMMIT LINT / commitlint (pull_request) Successful in 1m40s
Unit Tests / unittest (pull_request) Successful in 48s
This commit is contained in:
38
index.js
38
index.js
@@ -68,6 +68,35 @@ async function issueComments() {
|
||||
}
|
||||
}
|
||||
|
||||
async function issueBody() {
|
||||
if (!repoFullName || !issueNumber) return null;
|
||||
|
||||
const url = `${serverUrl}/api/v1/repos/${repoFullName}/issues/${issueNumber}`;
|
||||
const headers = { Accept: "application/vnd.github+json" };
|
||||
|
||||
if (githubToken) {
|
||||
headers.Authorization = `Bearer ${githubToken}`;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(url, { headers });
|
||||
if (!response.ok) {
|
||||
core.warning(
|
||||
`Failed to fetch issue body (${response.status}): ${response.statusText}`,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
const issue = await response.json();
|
||||
if (!issue?.body) return null;
|
||||
|
||||
return String(issue.body);
|
||||
} catch (error) {
|
||||
core.warning(`Error fetching issue body: ${error}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
@@ -88,7 +117,7 @@ async function run() {
|
||||
);
|
||||
}
|
||||
|
||||
const comments = await issueComments();
|
||||
const [body, comments] = await Promise.all([issueBody(), issueComments()]);
|
||||
if (!comments || comments.length < 1) {
|
||||
if (!debug) {
|
||||
core.setFailed("Unable to determine the task to send to the agent");
|
||||
@@ -99,6 +128,9 @@ async function run() {
|
||||
task = "[debug] empty task";
|
||||
}
|
||||
|
||||
const embedText = body ? body.trim() : String(comments[0]).trim();
|
||||
const storeText = String(comments[comments.length - 1]).trim();
|
||||
|
||||
const requestPayload = {
|
||||
type: "input",
|
||||
route,
|
||||
@@ -110,8 +142,8 @@ async function run() {
|
||||
inputs: {
|
||||
segment_id,
|
||||
document_id,
|
||||
embed_text: String(comments[0]).trim(),
|
||||
store_text: String(comments[comments.length - 1]).trim(),
|
||||
embed_text: embedText,
|
||||
store_text: storeText,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user