From ef715e3e6ac921f1b530ee8f9abdd317c2265df6 Mon Sep 17 00:00:00 2001
From: Zaran Lalvani <zaran@xeol.io>
Date: Mon, 6 May 2024 17:31:18 -0400
Subject: [PATCH] add unique filter

---
 packages/bumpgen-core/src/services/llm/openai.ts | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/packages/bumpgen-core/src/services/llm/openai.ts b/packages/bumpgen-core/src/services/llm/openai.ts
index d75118a..cfb64c0 100644
--- a/packages/bumpgen-core/src/services/llm/openai.ts
+++ b/packages/bumpgen-core/src/services/llm/openai.ts
@@ -1,4 +1,5 @@
 import type { OpenAI } from "openai";
+import { unique } from "radash";
 
 import type { DependencyGraphNode } from "../../models/graph/dependency";
 import type { PlanGraphNode } from "../../models/graph/plan";
@@ -18,9 +19,13 @@ const makePlanNodeMessage = (
   importContext: DependencyGraphNode[],
   bumpedPackage: string,
 ) => {
-  const importMessages = importContext.map((context) => {
-    return context.block;
-  });
+  // We need to do this because we only store nodes for the specific identifiers in an import, so
+  // multiple can be in the same code block.
+  const importMessages = unique(
+    importContext.map((context) => {
+      return context.block;
+    }),
+  );
   return {
     role: "user" as const,
     content: [