feat(ai): complete models runtime migration
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
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()) {
|
||||
@@ -5,3 +7,12 @@ export function headersToRecord(headers: Headers): Record<string, string> {
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user