Skip to content

Commit cf414c2

Browse files
committed
Fix get cf-aig-log-id examples
1 parent 0e77d50 commit cf414c2

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

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

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,19 @@ This method allows you to directly find the `cf-aig-log-id` within the header of
4444
The steps below outline how to do this.
4545

4646
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.
47-
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.
47+
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.
4848

4949
In the example below, the `cf-aig-log-id` is `01JADMCQQQBWH3NXZ5GCRN98DP`.
5050

5151
```json
5252
{
5353
"status": "success",
54+
"headers": {
55+
"cf-aig-log-id": "01JADMCQQQBWH3NXZ5GCRN98DP"
56+
// other headers...
57+
},
5458
"data": {
5559
"response": "Sample response data",
56-
"cf-aig-log-id": "01JADMCQQQBWH3NXZ5GCRN98DP"
5760
}
5861
}
5962
```
@@ -126,18 +129,26 @@ In the example below, the `id` is `01JADMCQQQBWH3NXZ5GCRN98DP`.
126129

127130
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:
128131

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
132+
```js
133+
const resp = await env.AI.run('@cf/meta/llama-3-8b-instruct', {
134+
prompt: 'tell me a joke'
135+
}, {
136+
gateway: {
137+
id: 'my_gateway_id'
138+
}
139+
})
140+
141+
const myLogId = env.AI.aiGatewayLogId
139142
```
140143

144+
:::note[Note:]
145+
146+
147+
The `aiGatewayLogId` property, will only old the last inference call log id.
148+
149+
150+
:::
151+
141152
## 4. Submit feedback via PATCH request
142153

143154
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)