Hi,
I am trying to create an "auto-session" id and get it back in the search/answer endpoints response so that I can pass it back in the subsequent request but I am unable to create one and keep running into 404 error. From the documentation, under the field "session", (https://cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.dataSto...), I see we need to add "/sessions" in the url but it does not seem to work regardless of where I put it. For example, I see a successful response coming back when I hit the below endpoint (Marked project name and dataStore names with ** as they are internal information)
But when I add "/sessions in the url, it does not work like the below -
Any thoughts?
Solved! Go to Solution.
Hi @Ravi9,
Welcome to Google Cloud Community!
While the concept of appending sessions to the endpoint URL is a common practice in some APIs, it appears the Discovery Engine API handles session management differently.
Be guided that there is a dedicated endpoint for creating sessions. Here's the corrected information:
POST /v1alpha/{parent=projects/*/locations/*/collections/*/dataStores/*}/sessions
The request body should include a sessionId field for the session. If you don't provide one, the API will generate a unique ID for you.
{
"sessionId": "my-custom-session-id"
}
The response will include the created session in the body, containing the session ID.
Using Sessions in Search Requests
POST /v1alpha/{parent=projects/*/locations/*/collections/*/dataStores/*/servingConfigs/*}:search
Within the search request body, you'll include a "session" field with the session ID you want to use.
{
"servingConfig": "projects/*/locations/global/collections/default_collection/dataStores/*/servingConfigs/default_search",
"session": {
"sessionId": "your-generated-session-id"
},
"query": "blue jeans",
"pageSize": 10
}
Key Points:
Additional Notes:
By following these steps and ensuring the correct endpoint structure, you should be able to create sessions and retrieve session IDs for your Vertex AI search/answer endpoints.
I hope the above information is helpful.
Hi @Ravi9,
Welcome to Google Cloud Community!
While the concept of appending sessions to the endpoint URL is a common practice in some APIs, it appears the Discovery Engine API handles session management differently.
Be guided that there is a dedicated endpoint for creating sessions. Here's the corrected information:
POST /v1alpha/{parent=projects/*/locations/*/collections/*/dataStores/*}/sessions
The request body should include a sessionId field for the session. If you don't provide one, the API will generate a unique ID for you.
{
"sessionId": "my-custom-session-id"
}
The response will include the created session in the body, containing the session ID.
Using Sessions in Search Requests
POST /v1alpha/{parent=projects/*/locations/*/collections/*/dataStores/*/servingConfigs/*}:search
Within the search request body, you'll include a "session" field with the session ID you want to use.
{
"servingConfig": "projects/*/locations/global/collections/default_collection/dataStores/*/servingConfigs/default_search",
"session": {
"sessionId": "your-generated-session-id"
},
"query": "blue jeans",
"pageSize": 10
}
Key Points:
Additional Notes:
By following these steps and ensuring the correct endpoint structure, you should be able to create sessions and retrieve session IDs for your Vertex AI search/answer endpoints.
I hope the above information is helpful.
Thank you @ruthseki
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |