diff --git a/src/content/docs/ai-gateway/evaluations/add-human-feedback-api.mdx b/src/content/docs/ai-gateway/evaluations/add-human-feedback-api.mdx index 2ec51f6e36ad973..7a36c96b6901e24 100644 --- a/src/content/docs/ai-gateway/evaluations/add-human-feedback-api.mdx +++ b/src/content/docs/ai-gateway/evaluations/add-human-feedback-api.mdx @@ -39,21 +39,23 @@ The `cf-aig-log-id` is a unique identifier for the specific log entry to which y ### Method 1: Locate the `cf-aig-log-id` in the request response -This method allows you to directly find the `cf-aig-log-id` within the body of the response returned by the AI Gateway. This is the most straightforward approach if you have access to the original API response. +This method allows you to directly find the `cf-aig-log-id` within the header of the response returned by the AI Gateway. This is the most straightforward approach if you have access to the original API response. The steps below outline how to do this. 1. **Make a Request to the AI Gateway**: This could be a request your application sends to the AI Gateway. Once the request is made, the response will contain various pieces of metadata. -2. **Check the Response Body**: The response body will include a field named `cf-aig-log-id`. This is the identifier you will need to submit feedback. +2. **Check the Response Headers**: The response will include a header named `cf-aig-log-id`. This is the identifier you will need to submit feedback. In the example below, the `cf-aig-log-id` is `01JADMCQQQBWH3NXZ5GCRN98DP`. ```json { "status": "success", - "data": { - "response": "Sample response data", + "headers": { "cf-aig-log-id": "01JADMCQQQBWH3NXZ5GCRN98DP" + }, + "data": { + "response": "Sample response data" } } ``` @@ -122,6 +124,30 @@ In the example below, the `id` is `01JADMCQQQBWH3NXZ5GCRN98DP`. } ``` +### Method 3: Retrieve the `cf-aig-log-id` via a binding + +You can also retrieve the `cf-aig-log-id` using a binding, which streamlines the process. Here's how to retrieve the log ID directly: + +```js +const resp = await env.AI.run('@cf/meta/llama-3-8b-instruct', { + prompt: 'tell me a joke' +}, { + gateway: { + id: 'my_gateway_id' + } +}) + +const myLogId = env.AI.aiGatewayLogId +``` + +:::note[Note:] + + +The `aiGatewayLogId` property, will only hold the last inference call log id. + + +::: + ## 4. Submit feedback via PATCH request Once you have both the API token and the `cf-aig-log-id`, you can send a PATCH request to submit feedback. Use the following URL format, replacing the `{account_id}`, `{gateway_id}`, and `{log_id}` with your specific details: