Skip to content

Commit 0e77d50

Browse files
authored
Update add-human-feedback-api.mdx
get log id using binding to submit human feedback via api
1 parent 9e52333 commit 0e77d50

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/content/docs/ai-gateway/evaluations/add-human-feedback-api.mdx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The `cf-aig-log-id` is a unique identifier for the specific log entry to which y
3939

4040
### Method 1: Locate the `cf-aig-log-id` in the request response
4141

42-
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.
42+
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.
4343

4444
The steps below outline how to do this.
4545

@@ -122,6 +122,22 @@ In the example below, the `id` is `01JADMCQQQBWH3NXZ5GCRN98DP`.
122122
}
123123
```
124124

125+
### Method 3: Retrieve the `cf-aig-log-id` via a binding
126+
127+
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:
128+
129+
```bash
130+
const resp = await env.AI.run('@cf/meta/llama-3-8b-instruct', {
131+
prompt: 'something'
132+
}, {
133+
gateway: {
134+
id: 'gateway_id'
135+
}
136+
})
137+
138+
const my_log_id = env.AI.aiGatewayLogId
139+
```
140+
125141
## 4. Submit feedback via PATCH request
126142

127143
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:

0 commit comments

Comments
 (0)