From cc8d907af50e718139fe0f102de2b966e6c19309 Mon Sep 17 00:00:00 2001 From: Zaran Lalvani Date: Thu, 2 May 2024 15:23:12 -0400 Subject: [PATCH] fix: separate imports from block to avoid LLM confusion --- .../bumpgen-core/src/services/llm/openai.ts | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/packages/bumpgen-core/src/services/llm/openai.ts b/packages/bumpgen-core/src/services/llm/openai.ts index 2bbcf88..5e56726 100644 --- a/packages/bumpgen-core/src/services/llm/openai.ts +++ b/packages/bumpgen-core/src/services/llm/openai.ts @@ -29,21 +29,19 @@ const makePlanNodeMessage = ( role: "user" as const, content: [ `I'm upgrading the package '${bumpedPackage}' and my code is failing. You might need to modify the code or the imports. Look at the errors below and think step-by-step about what the errors mean and how to fix the code.\n`, + `\n${importMessages.join("\n")}\n`, ``, - ] - .concat(importMessages.length ? [...importMessages, "\n"] : []) - .concat([`${planNode.block}`, "\n"]) - .concat( - planNode.kind === "seed" && planNode.errorMessages.length > 0 - ? [ - `The block has the following build errors:`, - "", - ...planNode.errorMessages.map((e) => `\n${e.message}\n`), - "", - ] - : [], - ) - .join("\n"), + `${planNode.block}`, + "\n", + ...(planNode.kind === "seed" && planNode.errorMessages.length > 0 + ? [ + `The block has the following build errors:`, + "", + ...planNode.errorMessages.map((e) => `\n${e.message}\n`), + "", + ] + : []), + ].join("\n"), }; }; @@ -218,14 +216,7 @@ export const fitToContext = ( export const createOpenAIService = (openai: OpenAI) => { return { codeplan: { - getReplacements: async ( - context: LLMContext, - temperature: number, - // externalDependencyContext: { - // imports: DependencyGraphNode[]; - // sourcegraph: ContextSearchResponse["getCodyContext"]; - // }, - ) => { + getReplacements: async (context: LLMContext, temperature: number) => { const { spatialContext, temporalContext,