diff --git a/src/handlers/ground-truths/find-ground-truths.ts b/src/handlers/ground-truths/find-ground-truths.ts index 045cae2..23fd92b 100644 --- a/src/handlers/ground-truths/find-ground-truths.ts +++ b/src/handlers/ground-truths/find-ground-truths.ts @@ -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"; @@ -13,25 +13,36 @@ export async function findGroundTruths ): Promise { 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 { +async function findChatBotTruths( + context: Context, + params: AppParamsHelper<"chat-bot">, + systemMsgObj: GroundTruthsSystemMessage<"chat-bot"> +): Promise { + 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 { +async function findCodeReviewTruths( + context: Context, + params: AppParamsHelper<"code-review">, + systemMsgObj: GroundTruthsSystemMessage<"code-review"> +): Promise { + const systemMsg = createGroundTruthSysMsg(systemMsgObj); const truths = await createGroundTruthCompletion<"code-review">(context, params.taskSpecification, systemMsg, "gpt-4o"); return validateGroundTruths(truths); }