Skip to content
Closed
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
42 changes: 42 additions & 0 deletions packages/gateway/src/gateway-language-model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,48 @@ describe('GatewayLanguageModel', () => {
});
});

it('should pass caching option for doGenerate', async () => {
prepareJsonResponse({
content: { type: 'text', text: 'Test response' },
});

await createTestModel().doGenerate({
prompt: TEST_PROMPT,
providerOptions: {
gateway: {
caching: 'auto',
},
},
});

const requestBody = await server.calls[0].requestBodyJson;
expect(requestBody.providerOptions).toEqual({
gateway: { caching: 'auto' },
});
});

it('should pass caching option for doStream', async () => {
prepareStreamResponse({
content: ['Hello', ' world'],
});

const { stream } = await createTestModel().doStream({
prompt: TEST_PROMPT,
providerOptions: {
gateway: {
caching: 'auto',
},
},
});

await convertReadableStreamToArray(stream);

const requestBody = await server.calls[0].requestBodyJson;
expect(requestBody.providerOptions).toEqual({
gateway: { caching: 'auto' },
});
});

it('should pass providerTimeouts for doGenerate', async () => {
prepareJsonResponse({
content: { type: 'text', text: 'Test response' },
Expand Down
6 changes: 6 additions & 0 deletions packages/gateway/src/gateway-provider-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ const gatewayProviderOptions = lazySchema(() =>
* - `'tps'`: highest tokens-per-second first
*/
sort: z.enum(['cost', 'ttft', 'tps']).optional(),
/**
* Automatically apply cache markers for providers that require them.
*
* Example: `'auto'`
*/
caching: z.literal('auto').optional(),
/**
* The unique identifier for the end user on behalf of whom the request was made.
*
Expand Down