-
-
Extension Settings:
-
- {Object.keys(settingsConfig).map((settingName) => (
-
- ))}
-
+ Coming Soon
diff --git a/src/utils/ai-utils/configurationReducer.ts b/src/utils/ai-utils/configurationReducer.ts
deleted file mode 100644
index e8e71a2..0000000
--- a/src/utils/ai-utils/configurationReducer.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import {
- DescriptionConfig,
- getDefaultDescriptionConfig,
-} from "./descriptionconfig";
-
-export const configurationReducer = (
- state: DescriptionConfig,
- action: { type: string; value: any },
-) => {
- let newState: DescriptionConfig = { ...state };
-
- switch (action.type) {
- case "SET":
- newState = action.value;
- break;
- case "SET_LENGTH":
- newState.config.length = action.value;
- break;
- case "SET_TEMPERATURE":
- newState.config.temperature = action.value;
- break;
- case "SET_MAX_INPUT_LENGTH":
- newState.config.maxInputLength = action.value;
- break;
- case "SET_LANGUAGE":
- newState.config.language = action.value;
- break;
- case "SET_SOURCE":
- newState.config.source = action.value;
- break;
- case "SET_TONE":
- newState.config.tone = action.value;
- break;
- case "CLEAR":
- newState = getDefaultDescriptionConfig();
- break;
- default:
- return newState;
- }
- return newState;
-};
diff --git a/src/utils/ai-utils/descriptionconfig.ts b/src/utils/ai-utils/descriptionconfig.ts
deleted file mode 100644
index af9536a..0000000
--- a/src/utils/ai-utils/descriptionconfig.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-import { AI_PR_DESCRIPTION_CONFIG_KEY } from "../../constants";
-
-export type DescriptionTone =
- | "exciting"
- | "persuasive"
- | "informative"
- | "humorous"
- | "formal";
-export type DescriptionSource = "diff" | "commitMessage" | "both";
-export type DescriptionLanguage =
- | "english"
- | "spanish"
- | "french"
- | "german"
- | "italian"
- | "portuguese"
- | "dutch"
- | "russian"
- | "chinese"
- | "korean";
-
-export interface DescriptionConfig {
- config: {
- length: number;
- maxInputLength: number;
- temperature: number;
- language: DescriptionLanguage;
- tone: DescriptionTone;
- source: DescriptionSource;
- };
- [key: string]: any;
-}
-
-export const getAIDescriptionConfig = async (): Promise<
- DescriptionConfig | undefined
-> => {
- const response: DescriptionConfig | undefined = (
- await chrome.storage.local.get(AI_PR_DESCRIPTION_CONFIG_KEY)
- )[AI_PR_DESCRIPTION_CONFIG_KEY];
-
- return response;
-};
-
-export const setAIDescriptionConfig = async (
- data: DescriptionConfig,
-): Promise
=> {
- await chrome.storage.local.set({ [AI_PR_DESCRIPTION_CONFIG_KEY]: data });
-};
-
-export const getDefaultDescriptionConfig = (): DescriptionConfig => ({
- config: {
- length: 500,
- maxInputLength: 3900,
- temperature: 7,
- language: "english",
- tone: "formal",
- source: "diff",
- },
-});
-
-export const setDefaultDescriptionConfig = () => {
- const defaultConfig = getDefaultDescriptionConfig();
-
- void setAIDescriptionConfig(defaultConfig);
-};
diff --git a/src/utils/ai-utils/openai.ts b/src/utils/ai-utils/openai.ts
deleted file mode 100644
index 37e60d0..0000000
--- a/src/utils/ai-utils/openai.ts
+++ /dev/null
@@ -1,144 +0,0 @@
-import {
- OPEN_SAUCED_AI_PR_DESCRIPTION_ENDPOINT,
- OPEN_SAUCED_AI_CODE_REFACTOR_ENDPOINT,
- OPEN_SAUCED_AI_CODE_TEST_ENDPOINT,
- OPEN_SAUCED_AI_CODE_EXPLANATION_ENDPOINT,
-} from "../../constants";
-import type { DescriptionConfig, DescriptionTone } from "./descriptionconfig";
-
-export const generateDescription = async (
- apiKey: string,
- language: string,
- descriptionLength: number,
- temperature: number,
- tone: DescriptionTone,
- diff?: string,
- commitMessages?: string[],
-): Promise => {
- try {
- const response = await fetch(OPEN_SAUCED_AI_PR_DESCRIPTION_ENDPOINT, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${apiKey}`,
- },
- body: JSON.stringify({
- descriptionLength,
- temperature,
- tone,
- language,
- diff,
- commitMessages,
- }),
- });
-
- if (response.status === 201) {
- const { description } = await response.json();
-
- return description;
- }
- } catch (error: unknown) {
- if (error instanceof Error) {
- console.error("OpenAI error: ", error.message);
- }
- }
- return undefined;
-};
-
-export const generateCodeSuggestion = async (
- apiKey: string,
- code: string,
- { config: { length, temperature, language } }: DescriptionConfig,
-): Promise => {
- try {
- const response = await fetch(OPEN_SAUCED_AI_CODE_REFACTOR_ENDPOINT, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${apiKey}`,
- },
- body: JSON.stringify({
- descriptionLength: length,
- temperature,
- language,
- code,
- }),
- });
-
- if (response.status === 201) {
- const { suggestion } = await response.json();
-
- return suggestion;
- }
- } catch (error: unknown) {
- if (error instanceof Error) {
- console.error("OpenAI error: ", error.message);
- }
- }
- return undefined;
-};
-
-export const generateCodeTest = async (
- apiKey: string,
- code: string,
- { config: { length, temperature } }: DescriptionConfig,
-): Promise => {
- try {
- const response = await fetch(OPEN_SAUCED_AI_CODE_TEST_ENDPOINT, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${apiKey}`,
- },
- body: JSON.stringify({
- descriptionLength: length,
- temperature,
- code,
- }),
- });
-
- if (response.status === 201) {
- const { suggestion } = await response.json();
-
- return suggestion;
- }
- } catch (error: unknown) {
- if (error instanceof Error) {
- console.error("OpenAI error: ", error.message);
- }
- }
- return undefined;
-};
-
-export const generateCodeExplanation = async (
- apiKey: string,
- code: string,
- { config: { length, temperature, language } }: DescriptionConfig,
-): Promise => {
- try {
- const response = await fetch(OPEN_SAUCED_AI_CODE_EXPLANATION_ENDPOINT, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${apiKey}`,
- },
- body: JSON.stringify({
- descriptionLength: length,
- temperature,
- language,
- code,
- }),
- });
-
- if (response.status === 201) {
- const { suggestion } = await response.json();
-
- return suggestion;
- }
- } catch (error: unknown) {
- if (error instanceof Error) {
- console.error("OpenAI error: ", error.message);
- }
- }
- return undefined;
-};
diff --git a/src/utils/dom-utils/addDescriptionGenerator.ts b/src/utils/dom-utils/addDescriptionGenerator.ts
deleted file mode 100644
index 14634e0..0000000
--- a/src/utils/dom-utils/addDescriptionGenerator.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { DescriptionGeneratorButton } from "../../content-scripts/components/GenerateAIDescription/DescriptionGeneratorButton";
-import { isPublicRepository } from "../fetchGithubAPIData";
-import { SettingsConfig } from "../../popup/pages/settings";
-
-const injectDescriptionGeneratorButton = async () => {
- if (
- document.getElementById("ai-description-button") ||
- !(await isPublicRepository(window.location.href))
- ) {
- return;
- }
-
- const settingsConfig = await new Promise((resolve) => {
- chrome.storage.sync.get("osSettingsConfig", (result) => {
- resolve(result.osSettingsConfig);
- });
- });
-
- if (settingsConfig) {
- const { aiPrDescription } = settingsConfig as SettingsConfig;
-
- if (!aiPrDescription) {
- return;
- }
- }
-
- const firstPrDescription = document.querySelectorAll(
- ".ActionBar-item-container",
- );
-
- firstPrDescription.forEach((item, index) => {
- if (!item.querySelector(`#ai-description-button-${index}`)) {
- const addGeneratorButton = DescriptionGeneratorButton(index);
-
- item.insertBefore(addGeneratorButton, item.firstChild);
- }
- });
-};
-
-export default injectDescriptionGeneratorButton;
diff --git a/src/utils/dom-utils/changeSuggestorButton.ts b/src/utils/dom-utils/changeSuggestorButton.ts
index f789a31..28a6ced 100644
--- a/src/utils/dom-utils/changeSuggestorButton.ts
+++ b/src/utils/dom-utils/changeSuggestorButton.ts
@@ -1,4 +1,3 @@
-import { AICodeReviewButton } from "../../content-scripts/components/AICodeReview/AICodeReviewButton";
import { GITHUB_REVIEW_SUGGESTION_CLASS } from "../../constants";
import { isPublicRepository } from "../fetchGithubAPIData";
import { SettingsConfig } from "../../popup/pages/settings";
@@ -21,19 +20,6 @@ const injectChangeSuggestorButton = async (commentNode: HTMLElement) => {
return;
}
}
-
- const suggestChangesIcon = commentNode.getElementsByClassName(
- GITHUB_REVIEW_SUGGESTION_CLASS,
- )[0];
- const changeSuggestorButton = AICodeReviewButton(commentNode);
-
- if (suggestChangesIcon.querySelector("#os-ai-change-gen")) {
- return;
- }
- suggestChangesIcon.insertBefore(
- changeSuggestorButton,
- suggestChangesIcon.firstChild,
- );
};
export default injectChangeSuggestorButton;
diff --git a/src/utils/fetchGithubAPIData.ts b/src/utils/fetchGithubAPIData.ts
index 525314d..af764f4 100644
--- a/src/utils/fetchGithubAPIData.ts
+++ b/src/utils/fetchGithubAPIData.ts
@@ -1,4 +1,3 @@
-import { DescriptionSource } from "./ai-utils/descriptionconfig";
import { isWithinTokenLimit } from "gpt-tokenizer";
type DescriptionContextPromise = Promise<
@@ -44,29 +43,7 @@ export const getPRCommitMessages = async (url: string) => {
);
};
-export const getDescriptionContext = async (
- url: string,
- source: DescriptionSource,
-): DescriptionContextPromise => {
- let promises: [Promise, Promise] =
- [Promise.resolve(undefined), Promise.resolve(undefined)];
-
- if (source === "diff") {
- promises = [getPRDiff(url), Promise.resolve(undefined)];
- } else if (source === "commitMessage") {
- promises = [Promise.resolve(undefined), getPRCommitMessages(url)];
- } else {
- promises = [getPRDiff(url), getPRCommitMessages(url)];
- }
- const response = await Promise.all(promises);
-
- return response;
-};
-
-export const isOutOfContextBounds = (
- context: DescriptionContext,
- limit: number,
-): boolean => {
+export const isOutOfContextBounds = (context: DescriptionContext, limit: number): boolean => {
let text = "";
if (context[0]) {
diff --git a/src/worker/background.ts b/src/worker/background.ts
index 9695e33..e8fec0f 100644
--- a/src/worker/background.ts
+++ b/src/worker/background.ts
@@ -1,10 +1,7 @@
import { LINKEDIN_PROJECT_FORM_SELECTOR } from "../constants";
import { Message, MessageType } from "../ts/types";
-import { setDefaultDescriptionConfig } from "../utils/ai-utils/descriptionconfig";
import { getRepoAPIURL } from "../utils/urlMatchers";
-chrome.runtime.onInstalled.addListener(setDefaultDescriptionConfig);
-
chrome.runtime.onMessage.addListener(async (message: Message) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (message.type === MessageType.LinkedInProject) {