Skip to content

Commit

Permalink
fix: conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
sshivaditya committed Oct 27, 2024
1 parent e0b252a commit 9efaf53
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"knip-ci": "knip --no-exit-code --reporter json --config .github/knip.ts",
"prepare": "husky install",
"test": "jest --setupFiles dotenv/config --coverage",
"worker": "wrangler dev --env dev --port 4000"
"worker": "wrangler dev --env dev --port 5000"
},
"keywords": [
"typescript",
Expand Down
16 changes: 3 additions & 13 deletions src/handlers/ask-llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,15 @@ export async function askGpt(context: Context, question: string, formattedChat:
formattedChat = formattedChat.filter((text) => text !== null);
similarText = similarText.filter((text) => text !== "");
const rerankedText = similarText.length > 0 ? await context.adapters.voyage.reranker.reRankResults(similarText, question) : [];
//Calculate the current context size in tokens
const numTokens = await context.adapters.openai.completions.findTokenLength(question, rerankedText, formattedChat, [
"typescript",
"github",
"cloudflare worker",
"actions",
"jest",
"supabase",
"openai",
]);
context.logger.info(`Number of tokens: ${numTokens}`);

const languages = await fetchRepoLanguageStats(context);
const { dependencies, devDependencies } = await fetchRepoDependencies(context);
const groundTruths = await findGroundTruths(context, "chat-bot", {
languages,
dependencies,
devDependencies,
});

//Calculate the current context size in tokens
const numTokens = await context.adapters.openai.completions.findTokenLength(question, rerankedText, formattedChat, groundTruths);
context.logger.info(`Number of tokens: ${numTokens}`);
return context.adapters.openai.completions.createCompletion(question, model, rerankedText, formattedChat, groundTruths, UBIQUITY_OS_APP_NAME);
}
4 changes: 2 additions & 2 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe("Ask plugin tests", () => {
createComments([transformCommentTemplate(1, 1, TEST_QUESTION, "ubiquity", "test-repo", true)]);
await runPlugin(ctx);

expect(infoSpy).toHaveBeenCalledTimes(4);
expect(infoSpy).toHaveBeenCalledTimes(5);
expect(infoSpy).toHaveBeenNthCalledWith(1, `Asking question: @UbiquityOS ${TEST_QUESTION}`);
expect(infoSpy).toHaveBeenNthCalledWith(4, "Answer: This is a mock answer for the chat", {
caller: LOG_CALLER,
Expand All @@ -131,7 +131,7 @@ describe("Ask plugin tests", () => {

await runPlugin(ctx);

expect(infoSpy).toHaveBeenCalledTimes(4);
expect(infoSpy).toHaveBeenCalledTimes(5);

expect(infoSpy).toHaveBeenNthCalledWith(1, `Asking question: @UbiquityOS ${TEST_QUESTION}`);

Expand Down

0 comments on commit 9efaf53

Please sign in to comment.