Skip to content

Commit

Permalink
fix: separate imports from block to avoid LLM confusion (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
zlalvani authored May 2, 2024
1 parent 92e2c94 commit 96bee28
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions packages/bumpgen-core/src/services/llm/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
`<relevant_imports path=${planNode.path}>\n${importMessages.join("\n")}\n</relevant_imports>`,
`<code \n path="${planNode.path}"\n>`,
]
.concat(importMessages.length ? [...importMessages, "\n"] : [])
.concat([`${planNode.block}`, "</code>\n"])
.concat(
planNode.kind === "seed" && planNode.errorMessages.length > 0
? [
`The block has the following build errors:`,
"<errors>",
...planNode.errorMessages.map((e) => `\n${e.message}\n`),
"</errors>",
]
: [],
)
.join("\n"),
`${planNode.block}`,
"</code>\n",
...(planNode.kind === "seed" && planNode.errorMessages.length > 0
? [
`The block has the following build errors:`,
"<errors>",
...planNode.errorMessages.map((e) => `\n${e.message}\n`),
"</errors>",
]
: []),
].join("\n"),
};
};

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 96bee28

Please sign in to comment.