Skip to content

Commit ff4c60d

Browse files
authored
fix: file metadata (#60)
1 parent ae60886 commit ff4c60d

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/convert-to-openrouter-chat-messages.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,12 @@ describe('cache control', () => {
184184
{
185185
type: 'file',
186186
data: 'ZmlsZSBjb250ZW50',
187-
filename: 'file.txt',
188187
mimeType: 'text/plain',
188+
providerMetadata: {
189+
openrouter: {
190+
filename: 'file.txt',
191+
},
192+
},
189193
},
190194
],
191195
providerMetadata: {
@@ -240,9 +244,13 @@ describe('cache control', () => {
240244
},
241245
{
242246
type: 'file',
243-
filename: 'file.txt',
244247
data: 'ZmlsZSBjb250ZW50',
245248
mimeType: 'text/plain',
249+
providerMetadata: {
250+
openrouter: {
251+
filename: 'file.txt',
252+
},
253+
},
246254
// No part-specific provider metadata
247255
},
248256
],

src/convert-to-openrouter-chat-messages.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ export function convertToOpenRouterChatMessages(
8787
return {
8888
type: 'file' as const,
8989
file: {
90-
filename: part.filename,
90+
filename: String(
91+
part.providerMetadata?.openrouter?.filename,
92+
),
9193
file_data:
9294
part.data instanceof Uint8Array
9395
? `data:${part.mimeType};base64,${convertUint8ArrayToBase64(part.data)}`

0 commit comments

Comments
 (0)