Skip to content

Commit

Permalink
chore: remove logs, formatting, prompt tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Oct 25, 2024
1 parent a145b34 commit 49c9dcd
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@
"@commitlint/config-conventional"
]
}
}
}
3 changes: 0 additions & 3 deletions src/handlers/ask-llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,5 @@ export async function askGpt(context: Context, question: string, formattedChat:
devDependencies,
});

console.log("languages: ", languages);
console.log("Ground Truths: ", groundTruths);

return context.adapters.openai.completions.createCompletion(question, model, rerankedText, formattedChat, groundTruths, UBIQUITY_OS_APP_NAME);
}
22 changes: 12 additions & 10 deletions src/handlers/ground-truths/create-ground-truth-completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ export async function createGroundTruthCompletion<TApp extends ModelApplications
...(openAiBaseUrl && { baseURL: openAiBaseUrl }),
});

const msgs = [
{
role: "system",
content: systemMsg,
},
{
role: "user",
content: groundTruthSource,
},
] as OpenAI.Chat.Completions.ChatCompletionMessageParam[];

const res = await openAi.chat.completions.create({
messages: [
{
role: "system",
content: systemMsg,
},
{
role: "user",
content: groundTruthSource,
},
],
messages: msgs,
model: model,
});

Expand Down
2 changes: 1 addition & 1 deletion src/handlers/ground-truths/create-system-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Each ground truth should:
Example:
${example.join("\n")}
${conditions ? `Conditions:\n${conditions}` : ""}
${conditions ? `Conditions:\n${conditions.join("\n")}` : ""}
Generate similar ground truths adhering to a maximum of 10.
Expand Down
6 changes: 4 additions & 2 deletions src/handlers/ground-truths/find-ground-truths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ export async function findGroundTruths<TApp extends ModelApplications = ModelApp
const systemMsg = createGroundTruthSysMsg(systemMsgObj);

if (chatBotPayloadTypeguard(params)) {
return findChatBotTruths(context, params, systemMsg);
const { dependencies, devDependencies, languages } = params;
return findChatBotTruths(context, { dependencies, devDependencies, languages }, systemMsg);
} else if (codeReviewPayloadTypeguard(params)) {
return findCodeReviewTruths(context, params, systemMsg);
const { taskSpecification } = params;
return findCodeReviewTruths(context, { taskSpecification }, systemMsg);
} else {
throw logger.error("Invalid payload type for ground truths");
}
Expand Down
3 changes: 2 additions & 1 deletion src/handlers/ground-truths/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ const CHAT_BOT_GROUND_TRUTHS_SYSTEM_MESSAGE = {
"Assume your output builds the foundation for a chatbot to understand the repository when asked an arbitrary query.",
"Do not list every language or dependency, focus on the most prevalent ones.",
"Focus on what is essential to understand the repository at a high level.",
"Brevity is key.",
"Brevity is key. Use zero formatting. Do not wrap in quotes, backticks, or other characters.",
`response === ["some", "array", "of", "strings"]`,
],
};

Expand Down
1 change: 1 addition & 0 deletions src/handlers/ground-truths/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export function validateGroundTruths(truthsString: string | null): string[] {
if (!truthsString) {
throw logger.error("Failed to generate ground truths");
}

try {
truths = JSON.parse(truthsString);
} catch (err) {
Expand Down
10 changes: 5 additions & 5 deletions src/types/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ type CodeReviewAppParams = {
export type AppParamsHelper<TApp extends ModelApplications> = TApp extends "code-review"
? CodeReviewAppParams
: TApp extends "chat-bot"
? ChatBotAppParams
: never;
? ChatBotAppParams
: never;

export type CompletionsModelHelper<TApp extends ModelApplications> = TApp extends "code-review" ? "gpt-4o" : TApp extends "chat-bot" ? "o1-mini" : never;

export type GroundTruthsSystemMessage<TApp extends ModelApplications = ModelApplications> = TApp extends "code-review"
? typeof GROUND_TRUTHS_SYSTEM_MESSAGES["code-review"]
? (typeof GROUND_TRUTHS_SYSTEM_MESSAGES)["code-review"]
: TApp extends "chat-bot"
? typeof GROUND_TRUTHS_SYSTEM_MESSAGES["chat-bot"]
: never;
? (typeof GROUND_TRUTHS_SYSTEM_MESSAGES)["chat-bot"]
: never;

export type GroundTruthsSystemMessageTemplate = {
truthRules: string[];
Expand Down
2 changes: 1 addition & 1 deletion src/types/typeguards.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AppParamsHelper } from "./llm";

export function chatBotPayloadTypeguard(payload: unknown): payload is AppParamsHelper<"chat-bot"> {
return typeof payload === "object" && payload !== null && "repoLanguages" in payload && "repoDependencies" in payload && "chatBotPrompt" in payload;
return typeof payload === "object" && payload !== null && "languages" in payload && "dependencies" in payload;
}

export function codeReviewPayloadTypeguard(payload: unknown): payload is AppParamsHelper<"code-review"> {
Expand Down

0 comments on commit 49c9dcd

Please sign in to comment.