Skip to content

Commit c9e21eb

Browse files
authored
Merge pull request #1414 from websentry-ai/pm/add-unbound-metadata
Adds Unbound metadata for non-streaming requests
2 parents aa57ae9 + 4073bdc commit c9e21eb

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/api/providers/__tests__/unbound.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ describe("UnboundHandler", () => {
192192
temperature: 0,
193193
max_tokens: 8192,
194194
}),
195+
expect.objectContaining({
196+
headers: expect.objectContaining({
197+
"X-Unbound-Metadata": expect.stringContaining("roo-code"),
198+
}),
199+
}),
195200
)
196201
})
197202

@@ -233,6 +238,11 @@ describe("UnboundHandler", () => {
233238
messages: [{ role: "user", content: "Test prompt" }],
234239
temperature: 0,
235240
}),
241+
expect.objectContaining({
242+
headers: expect.objectContaining({
243+
"X-Unbound-Metadata": expect.stringContaining("roo-code"),
244+
}),
245+
}),
236246
)
237247
expect(mockCreate.mock.calls[0][0]).not.toHaveProperty("max_tokens")
238248
})

src/api/providers/unbound.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,18 @@ export class UnboundHandler extends BaseProvider implements SingleCompletionHand
157157
requestOptions.max_tokens = this.getModel().info.maxTokens
158158
}
159159

160-
const response = await this.client.chat.completions.create(requestOptions)
160+
const response = await this.client.chat.completions.create(requestOptions, {
161+
headers: {
162+
"X-Unbound-Metadata": JSON.stringify({
163+
labels: [
164+
{
165+
key: "app",
166+
value: "roo-code",
167+
},
168+
],
169+
}),
170+
},
171+
})
161172
return response.choices[0]?.message.content || ""
162173
} catch (error) {
163174
if (error instanceof Error) {

0 commit comments

Comments
 (0)