Skip to content

Commit 60b3a97

Browse files
kathaylG4brymhyperlint-ai[bot]
authored andcommitted
Update add-human-feedback-api.mdx (#17878)
* Update add-human-feedback-api.mdx get log id using binding to submit human feedback via api * Fix get cf-aig-log-id examples * Update src/content/docs/ai-gateway/evaluations/add-human-feedback-api.mdx Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com> * Fix typo --------- Co-authored-by: Gabriel Massadas <[email protected]> Co-authored-by: Gabriel Massadas <[email protected]> Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>
1 parent f3c152a commit 60b3a97

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

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

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,23 @@ 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

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-
"data": {
55-
"response": "Sample response data",
54+
"headers": {
5655
"cf-aig-log-id": "01JADMCQQQBWH3NXZ5GCRN98DP"
56+
},
57+
"data": {
58+
"response": "Sample response data"
5759
}
5860
}
5961
```
@@ -122,6 +124,30 @@ In the example below, the `id` is `01JADMCQQQBWH3NXZ5GCRN98DP`.
122124
}
123125
```
124126

127+
### Method 3: Retrieve the `cf-aig-log-id` via a binding
128+
129+
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:
130+
131+
```js
132+
const resp = await env.AI.run('@cf/meta/llama-3-8b-instruct', {
133+
prompt: 'tell me a joke'
134+
}, {
135+
gateway: {
136+
id: 'my_gateway_id'
137+
}
138+
})
139+
140+
const myLogId = env.AI.aiGatewayLogId
141+
```
142+
143+
:::note[Note:]
144+
145+
146+
The `aiGatewayLogId` property, will only hold the last inference call log id.
147+
148+
149+
:::
150+
125151
## 4. Submit feedback via PATCH request
126152

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