Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sshivaditya committed Oct 17, 2024
1 parent 9583286 commit baec08a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
14 changes: 1 addition & 13 deletions src/handlers/ask-llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export async function askQuestion(context: Context, question: string) {
repo: context.payload.repository.name,
});
const formattedChat = await formatChatHistory(context, streamlinedComments, specAndBodies);
context.logger.info(`${formattedChat}`);
return await askGpt(context, question, formattedChat);
}

Expand Down Expand Up @@ -61,7 +62,6 @@ export async function askGpt(context: Context, question: string, formattedChat:
// const reRankedChat = formattedChat.length > 0 ? await context.adapters.voyage.reranker.reRankResults(formattedChat.filter(text => text !== ""), question, 300) : [];
similarText = similarText.filter((text) => text !== "");
const rerankedText = similarText.length > 0 ? await context.adapters.voyage.reranker.reRankResults(similarText, question) : [];
rerankedText.forEach((text) => removeUnwantedChars(text));
return context.adapters.openai.completions.createCompletion(
question,
model,
Expand All @@ -71,15 +71,3 @@ export async function askGpt(context: Context, question: string, formattedChat:
UBIQUITY_OS_APP_NAME
);
}

/**
* Removes unwanted characters from the text like emojis, special characters etc.
* @param text
* @returns
*/
function removeUnwantedChars(text: string): string {
if (!text) {
return "";
}
return text.replace(/[^a-zA-Z0-9\s]/g, "");
}
4 changes: 2 additions & 2 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe("Ask plugin tests", () => {
2 ubiquity: ${TEST_QUESTION} [#1](https://www.github.com/ubiquity/test-repo/issues/1)
=== End Current Issue #1 Conversation ===
=== Linked Issue #2 Specification === ubiquity/test-repo/2 ===
,=== Linked Issue #2 Specification === ubiquity/test-repo/2 ===
Related to issue #3
=== End Linked Issue #2 Specification ===
Expand All @@ -155,7 +155,7 @@ describe("Ask plugin tests", () => {
3 ubiquity: ${ISSUE_ID_3_CONTENT} [#3](https://www.github.com/ubiquity/test-repo/issues/3)
=== End Linked Issue #2 Conversation ===
=== Linked Issue #3 Specification === ubiquity/test-repo/3 ===
,=== Linked Issue #3 Specification === ubiquity/test-repo/3 ===
Just another issue
=== End Linked Issue #3 Specification ===
Expand Down

0 comments on commit baec08a

Please sign in to comment.