Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoalbanese committed Dec 2, 2024
1 parent 103da13 commit 9789507
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
10 changes: 3 additions & 7 deletions content/cookbook/01-next/122-caching-middleware.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ export const cacheMiddleware: LanguageModelV1Middleware = {
}

// If not cached, proceed with streaming
const { stream, rawCall, rawResponse, request, warnings } =
await doStream();
const { stream, ...rest } = await doStream();

const fullResponse: unknown[] = [];
const fullResponse: LanguageModelV1StreamPart[] = [];

const transformStream = new TransformStream<
LanguageModelV1StreamPart,
Expand All @@ -125,10 +124,7 @@ export const cacheMiddleware: LanguageModelV1Middleware = {

return {
stream: stream.pipeThrough(transformStream),
rawCall,
rawResponse,
request,
warnings,
...rest,
};
},
};
Expand Down
10 changes: 3 additions & 7 deletions content/docs/06-advanced/04-caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ export const cacheMiddleware: LanguageModelV1Middleware = {
}

// If not cached, proceed with streaming
const { stream, rawCall, rawResponse, request, warnings } =
await doStream();
const { stream, ...rest } = await doStream();

const fullResponse: unknown[] = [];
const fullResponse: LanguageModelV1StreamPart[] = [];

const transformStream = new TransformStream<
LanguageModelV1StreamPart,
Expand All @@ -79,10 +78,7 @@ export const cacheMiddleware: LanguageModelV1Middleware = {

return {
stream: stream.pipeThrough(transformStream),
rawCall,
rawResponse,
request,
warnings,
...rest,
};
},
};
Expand Down

0 comments on commit 9789507

Please sign in to comment.