fix: strip trailing assistant prefill · voidsteed/copilot-proxy-api@0528271 · GitHub
Skip to content

Commit 0528271

Browse files
committed
fix: strip trailing assistant prefill
1 parent b65d4ea commit 0528271

3 files changed

Lines changed: 149 additions & 4 deletions

File tree

src/routes/messages/non-stream-translation.ts

Lines changed: 23 additions & 4 deletions

tests/anthropic-request.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ describe("Anthropic to OpenAI translation logic", () => {
8484
role: "assistant",
8585
content: "The weather in Boston is sunny and 75°F.",
8686
},
87+
{ role: "user", content: "Thanks." },
8788
],
8889
temperature: 0.7,
8990
max_tokens: 150,
@@ -144,6 +145,7 @@ describe("Anthropic to OpenAI translation logic", () => {
144145
{ type: "text", text: "2+2 equals 4." },
145146
],
146147
},
148+
{ role: "user", content: "Thanks." },
147149
],
148150
max_tokens: 100,
149151
}
@@ -183,6 +185,16 @@ describe("Anthropic to OpenAI translation logic", () => {
183185
},
184186
],
185187
},
188+
{
189+
role: "user",
190+
content: [
191+
{
192+
type: "tool_result",
193+
tool_use_id: "call_123",
194+
content: "72°F and sunny",
195+
},
196+
],
197+
},
186198
],
187199
max_tokens: 100,
188200
}

tests/translation.test.ts

Lines changed: 114 additions & 0 deletions

0 commit comments

Comments
 (0)