Download packages/ai/src/utils/headers.ts from SaylorTwift/pi: direct link, hf CLI and curl.
- Browser
- Download file 624 Bytes
-
https://huggingface.co/SaylorTwift/pi/resolve/main/packages/ai/src/utils/headers.ts
- Command line
-
hf download hf://SaylorTwift/pi/packages/ai/src/utils/headers.ts
-
curl -L -o headers.ts https://huggingface.co/SaylorTwift/pi/resolve/main/packages/ai/src/utils/headers.ts
624 Bytes
| import type { ProviderHeaders } from "../types.ts"; | |
| export function headersToRecord(headers: Headers): Record<string, string> { | |
| const result: Record<string, string> = {}; | |
| for (const [key, value] of headers.entries()) { | |
| result[key] = value; | |
| } | |
| return result; | |
| } | |
| export function providerHeadersToRecord(headers: ProviderHeaders | undefined): Record<string, string> | undefined { | |
| if (!headers) return undefined; | |
| const result: Record<string, string> = {}; | |
| for (const [key, value] of Object.entries(headers)) { | |
| if (value !== null) result[key] = value; | |
| } | |
| return Object.keys(result).length > 0 ? result : undefined; | |
| } | |