From 5d8a9f2cbc0b1464e50e24ea259fbd0b6d6a94e2 Mon Sep 17 00:00:00 2001 From: Gabriel Massadas Date: Wed, 9 Oct 2024 15:22:54 +0100 Subject: [PATCH 1/2] Add property aiGatewayLogId to AI binding --- src/cloudflare/internal/ai-api.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cloudflare/internal/ai-api.ts b/src/cloudflare/internal/ai-api.ts index 3dbdd307345..76615833fb3 100644 --- a/src/cloudflare/internal/ai-api.ts +++ b/src/cloudflare/internal/ai-api.ts @@ -53,6 +53,7 @@ export class Ai { private logs: Array = []; private options: AiOptions = {}; public lastRequestId: string | null = null; + public aiGatewayLogId: string | null = null; public constructor(fetcher: Fetcher) { this.fetcher = fetcher; @@ -104,6 +105,7 @@ export class Ai { ); this.lastRequestId = res.headers.get('cf-ai-req-id'); + this.aiGatewayLogId = res.headers.get('cf-aig-log-id'); if (inputs['stream']) { if (!res.ok) { From 076bcd50f0e55fb4260ac2974c4abd0f6bd0bf78 Mon Sep 17 00:00:00 2001 From: Gabriel Massadas Date: Wed, 9 Oct 2024 15:26:06 +0100 Subject: [PATCH 2/2] Add cacheKey and collectLog options to AI Binding --- src/cloudflare/internal/ai-api.ts | 2 ++ types/defines/ai.d.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/cloudflare/internal/ai-api.ts b/src/cloudflare/internal/ai-api.ts index 76615833fb3..e5cfdc00950 100644 --- a/src/cloudflare/internal/ai-api.ts +++ b/src/cloudflare/internal/ai-api.ts @@ -20,9 +20,11 @@ export type SessionOptions = { export type GatewayOptions = { id: string; + cacheKey?: string; cacheTtl?: number; skipCache?: boolean; metadata?: Record; + collectLog?: boolean; }; export type AiOptions = { diff --git a/types/defines/ai.d.ts b/types/defines/ai.d.ts index b3fc2b03b98..812b612b795 100644 --- a/types/defines/ai.d.ts +++ b/types/defines/ai.d.ts @@ -175,9 +175,11 @@ export declare abstract class BaseAiTranslation { } export type GatewayOptions = { id: string; + cacheKey?: string; cacheTtl?: number; skipCache?: boolean; metadata?: Record; + collectLog?: boolean; }; export type AiOptions = { gateway?: GatewayOptions;