Skip to content

Commit

Permalink
fix: tests and knip
Browse files Browse the repository at this point in the history
  • Loading branch information
sshivaditya committed Oct 12, 2024
1 parent dd4c334 commit e37f585
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const config: KnipConfig = {
ignore: ["src/types/config.ts", "**/__mocks__/**", "**/__fixtures__/**"],
ignoreExportsUsedInFile: true,
// eslint can also be safely ignored as per the docs: https://knip.dev/guides/handling-issues#eslint--jest
ignoreDependencies: ["eslint-config-prettier", "eslint-plugin-prettier", "@mswjs/data"],
ignoreDependencies: ["eslint-config-prettier", "eslint-plugin-prettier"],
eslint: true,
};

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ plugins:
```sh
# OpenAI API key
OPENAI_API_KEY=your-api-key
UBIQUITY_OS_APP_SLUG="UbiquityOS"
UBIQUITY_OS_APP_NAME="UbiquityOS"
```

Expand Down
4 changes: 2 additions & 2 deletions src/handlers/ask-gpt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function askQuestion(context: Context, question: string) {
**/
export async function askGpt(context: Context, question: string, formattedChat: string[]): Promise<CompletionsType> {
const {
env: { UBIQUITY_OS_APP_SLUG },
env: { UBIQUITY_OS_APP_NAME },
config: { model, similarityThreshold },
} = context;
let similarComments: CommentSimilaritySearchResult[] = [];
Expand Down Expand Up @@ -70,7 +70,7 @@ export async function askGpt(context: Context, question: string, formattedChat:
rerankedText,
formattedChat,
["typescript", "github", "cloudflare worker", "actions", "jest", "supabase", "openai"],
UBIQUITY_OS_APP_SLUG
UBIQUITY_OS_APP_NAME
);
}

Expand Down
17 changes: 0 additions & 17 deletions src/helpers/format-chat-history.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ChatCompletionMessageParam } from "openai/resources";
import { Context } from "../types";
import { StreamlinedComment, StreamlinedComments } from "../types/gpt";
import { createKey, streamlineComments } from "../handlers/comments";
Expand Down Expand Up @@ -156,19 +155,3 @@ function createComment(comment: StreamlinedComments) {
function createSpecOrBody(specOrBody: string) {
return `${specOrBody}\n`;
}

/**
* Creates a chat history array from the formatted chat string.
*
* @param formattedChat - The formatted chat string.
* @returns An array of ChatCompletionMessageParam objects representing the chat history.
*/
export function createChatHistory(formattedChat: string) {
const chatHistory: ChatCompletionMessageParam[] = [];
const userMessage: ChatCompletionMessageParam = {
role: "user",
content: formattedChat,
};
chatHistory.push(userMessage);
return chatHistory;
}
4 changes: 2 additions & 2 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export async function plugin(inputs: PluginInputs, env: Env) {
export async function runPlugin(context: Context) {
const {
logger,
env: { UBIQUITY_OS_APP_SLUG },
env: { UBIQUITY_OS_APP_NAME },
} = context;
const question = context.payload.comment.body;
const slugRegex = new RegExp(`@${UBIQUITY_OS_APP_SLUG} `, "gi");
const slugRegex = new RegExp(`@${UBIQUITY_OS_APP_NAME} `, "gi");
if (!question.match(slugRegex)) {
logger.info("Comment does not mention the app. Skipping.");
return;
Expand Down
2 changes: 1 addition & 1 deletion src/types/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dotenv.config();
*/
export const envSchema = T.Object({
OPENAI_API_KEY: T.String(),
UBIQUITY_OS_APP_SLUG: T.String(),
UBIQUITY_OS_APP_NAME: T.String(),
VOYAGEAI_API_KEY: T.String(),
SUPABASE_URL: T.String(),
SUPABASE_KEY: T.String(),
Expand Down
2 changes: 1 addition & 1 deletion tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function createContext(body = TEST_SLASH_COMMAND) {
logger: new Logs("debug"),
config: {},
env: {
UBIQUITY_OS_APP_SLUG: "UbiquityOS",
UBIQUITY_OS_APP_NAME: "UbiquityOS",
OPENAI_API_KEY: "test",
},
adapters: {
Expand Down

0 comments on commit e37f585

Please sign in to comment.