Skip to content
Merged
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
12 changes: 12 additions & 0 deletions packages/langbase/src/common/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ export class Request {
// All endpoints should return headers if rawResponse is true
if (!isLllmGenerationEndpoint && options.body?.rawResponse) {
const responseData = await response.json();
// For array responses, attach rawResponse as a hidden property to preserve response type as array
// while still providing access to response headers when needed
if (Array.isArray(responseData)) {
Object.defineProperty(responseData, 'rawResponse', {
value: {
headers: Object.fromEntries(response.headers.entries()),
},
enumerable: false,
writable: true,
});
return responseData as T;
}
return {
...responseData,
rawResponse: {
Expand Down
Loading