Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
feat: link the handler to event
Browse files Browse the repository at this point in the history
  • Loading branch information
0xcodercrane committed Nov 6, 2023
1 parent e431c79 commit 950b8a2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/handlers/comment/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ export const handleComment = async (): Promise<void> => {
const callbackComment = response ?? successComment ?? "";
if (callbackComment) await callback(issue.number, callbackComment, payload.action, payload.comment);
} catch (err: unknown) {
// Use failureComment for failed command if it is available
if (failureComment) {
await callback(issue.number, failureComment, payload.action, payload.comment);
for (const comment of [failureComment, ErrorDiff(err)]) {
if (comment) await callback(issue.number, comment, payload.action, payload.comment);
}
await callback(issue.number, ErrorDiff(err), payload.action, payload.comment);
}
} else {
logger.info(`Skipping for a command: ${command}`);
Expand Down
26 changes: 24 additions & 2 deletions src/handlers/issue/embeddings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
import { getAdapters, getBotConfig, getBotContext, getLogger } from "../../bindings";

Check failure on line 1 in src/handlers/issue/embeddings.ts

View workflow job for this annotation

GitHub Actions / build

'getAdapters' is declared but its value is never read.

Check failure on line 1 in src/handlers/issue/embeddings.ts

View workflow job for this annotation

GitHub Actions / build

'getBotConfig' is declared but its value is never read.

Check failure on line 1 in src/handlers/issue/embeddings.ts

View workflow job for this annotation

GitHub Actions / build

'getAdapters' is declared but its value is never read.

Check failure on line 1 in src/handlers/issue/embeddings.ts

View workflow job for this annotation

GitHub Actions / build

'getBotConfig' is declared but its value is never read.
import { Payload } from "../../types";
import { generateEmbeddings } from "../../helpers";
import { upsertEmbeddings } from "../../adapters/supabase";

/**
* Generates an embedding vector for the current issue
*/
export const embeddings = async () => {
const { payload: _payload } = getBotContext();
const logger = getLogger();
const payload = _payload as Payload;
const issue = payload.issue;

if (!issue) {
logger.info(`Skip to generate embeddings because of no issue instance`);
return;
}

if (!issue.body) {
logger.info("Skip to generate embeddings because of empty body");
return;
}

export const generateEmbeddings = async () => {
return;
const embeddings = await generateEmbeddings(issue.body);
if (embeddings.length > 0) {
await upsertEmbeddings(payload.repository.owner.login, payload.repository.name, issue.number, embeddings);
}
};
1 change: 1 addition & 0 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from "./payout";
export * from "./file";
export * from "./similarity";
export * from "./commit";
export * from "./gpt";

0 comments on commit 950b8a2

Please sign in to comment.