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

Commit

Permalink
fix(ci): build
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Aug 1, 2024
1 parent cd3a6cc commit 30b4da7
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"deploy": "wrangler deploy",
"start": "wrangler dev",
"setup-key": "tsx ./deploy-keys.ts",
"build": "tsx build/esbuild-build.ts",
"build": "tsc --noEmit",
"format": "run-s format:lint format:prettier format:cspell",
"format:lint": "eslint --fix .",
"format:prettier": "prettier --write .",
Expand Down
57 changes: 57 additions & 0 deletions src/helpers/chat-gpt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { ErrorType } from "../types/basic";

Check failure on line 1 in src/helpers/chat-gpt.ts

View workflow job for this annotation

GitHub Actions / build

Cannot find module '../types/basic' or its corresponding type declarations.

Check failure on line 1 in src/helpers/chat-gpt.ts

View workflow job for this annotation

GitHub Actions / build

Cannot find module '../types/basic' or its corresponding type declarations.
import { PROMPT_SYSTEM, PROMPT_USER } from "./prompt";
import { removeNewlinesAndExtractValues } from "./utils";

export async function completeGpt3(messageText: string) {
try {
const apiKey = OPENAI_API_KEY;
const apiUrl = "https://api.openai.com/v1/chat/completions";

const requestBody = {
model: "gpt-3.5-turbo",
messages: [
{
role: "system",
content: PROMPT_SYSTEM,
},
{
role: "user",
content: PROMPT_USER.replace(/{messageText}/g, messageText),
},
],
max_tokens: 1500,
temperature: 0,
stream: false,
};

const response = await fetch(apiUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`,
},
body: JSON.stringify(requestBody),
});

const data = await response.json();

console.log(data); // log raw data

if (data?.error) {
console.log(`ChatGPT Error: ${data?.error}`);
return;
}

return removeNewlinesAndExtractValues(data.choices[0].message.content);
} catch (e) {
console.log((e as ErrorType).message);
return {
issueTitle: null,
timeEstimate: null,
};
}
}

export default {
completeGPT3: completeGpt3,
};
2 changes: 1 addition & 1 deletion src/helpers/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function validateJwt(token: string) {
throw new Error("Invalid JWT");
}

const { payload } = jwt.decode(token);
const { payload } = jwt.decode(token) as { payload: JwtResponse };

if (!payload.group) {
throw new Error("Invalid JWT, group is missing");
Expand Down
2 changes: 1 addition & 1 deletion src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import { BOT_COMMANDS, ENABLE_TOPIC, GITHUB_PATHNAME } from "./constants";
import { completeGpt3 } from "./helpers/chatgpt";
import { completeGpt3 } from "./helpers/chat-gpt";
import { createIssue } from "./helpers/github";
import { onPrivateCallbackQuery } from "./helpers/navigation";
import { oAuthHandler } from "./helpers/oauth-login";
Expand Down

0 comments on commit 30b4da7

Please sign in to comment.