Skip to content

Commit

Permalink
chore: knip fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Oct 25, 2024
1 parent 5ff5b71 commit 359451e
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/handlers/ground-truths/find-ground-truths.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Context } from "../../types";
import { AppParamsHelper, ModelApplications } from "../../types/llm";
import { AppParamsHelper, GroundTruthsSystemMessage, ModelApplications } from "../../types/llm";
import { GROUND_TRUTHS_SYSTEM_MESSAGES } from "./prompts";
import { chatBotPayloadTypeguard, codeReviewPayloadTypeguard } from "../../types/typeguards";
import { validateGroundTruths } from "./validate";
Expand All @@ -13,25 +13,36 @@ export async function findGroundTruths<TApp extends ModelApplications = ModelApp
params: AppParamsHelper<TApp>
): Promise<string[]> {
const systemMsgObj = GROUND_TRUTHS_SYSTEM_MESSAGES[application];
const systemMsg = createGroundTruthSysMsg(systemMsgObj);

// params are deconstructed to show quickly what's being passed to the function

if (chatBotPayloadTypeguard(params)) {
const { dependencies, devDependencies, languages } = params;
return findChatBotTruths(context, { dependencies, devDependencies, languages }, systemMsg);
return findChatBotTruths(context, { dependencies, devDependencies, languages }, systemMsgObj);
} else if (codeReviewPayloadTypeguard(params)) {
const { taskSpecification } = params;
return findCodeReviewTruths(context, { taskSpecification }, systemMsg);
return findCodeReviewTruths(context, { taskSpecification }, systemMsgObj);
} else {
throw logger.error("Invalid payload type for ground truths");
}
}

async function findChatBotTruths(context: Context, params: AppParamsHelper<"chat-bot">, systemMsg: string): Promise<string[]> {
async function findChatBotTruths(
context: Context,
params: AppParamsHelper<"chat-bot">,
systemMsgObj: GroundTruthsSystemMessage<"chat-bot">
): Promise<string[]> {
const systemMsg = createGroundTruthSysMsg(systemMsgObj);
const truths = await createGroundTruthCompletion<"chat-bot">(context, JSON.stringify(params), systemMsg, "o1-mini");
return validateGroundTruths(truths);
}

async function findCodeReviewTruths(context: Context, params: AppParamsHelper<"code-review">, systemMsg: string): Promise<string[]> {
async function findCodeReviewTruths(
context: Context,
params: AppParamsHelper<"code-review">,
systemMsgObj: GroundTruthsSystemMessage<"code-review">
): Promise<string[]> {
const systemMsg = createGroundTruthSysMsg(systemMsgObj);
const truths = await createGroundTruthCompletion<"code-review">(context, params.taskSpecification, systemMsg, "gpt-4o");
return validateGroundTruths(truths);
}

0 comments on commit 359451e

Please sign in to comment.