Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions open-sse/config/providerFieldStrips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,21 @@ export function stripGroqUnsupportedFields<T extends Record<string, unknown>>(bo
delete next.top_logprobs;
if (Array.isArray(next.messages)) {
next.messages = next.messages.map((m) => {
if (m && typeof m === "object" && "name" in m) {
const { name: _name, ...rest } = m as Record<string, unknown>;
if (m && typeof m === "object") {
const {
name: _name,
model: _model,
messageId: _msgId,
sender: _sender,
...rest
} = m as Record<string, unknown>;

return rest;
}

return m;
});
}
return next as T;
}

24 changes: 24 additions & 0 deletions tests/unit/provider-field-strips.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,27 @@ test("stripGroqUnsupportedFields is immutable (does not mutate input)", () => {
assert.equal(input.messages[0].name, "bob");
assert.equal(input.logprobs, true);
});

test("stripGroqUnsupportedFields drops unsupported messages[].model and other metadata while keeping role and content", () => {
const out = stripGroqUnsupportedFields({
messages: [
{ role: "user", content: "hello" },
{
role: "assistant",
content: "hello!",
model: "groq/openai/gpt-oss-20b",
messageId: "msg_123",
sender: "assistant",
},
],
});
assert.equal(out.messages.length, 2);
assert.equal(out.messages[0].role, "user");
assert.equal(out.messages[0].content, "hello");
assert.equal(out.messages[1].role, "assistant");
assert.equal(out.messages[1].content, "hello!");
assert.equal("model" in out.messages[1], false);
assert.equal("messageId" in out.messages[1], false);
assert.equal("sender" in out.messages[1], false);
});