refactor: add adapter to redirect v1 chat request through v2 chat
What does this merge request do and why?
This change adds a new implementation for the v1 chat endpoint. The code introduces functionality to convert older v1 chat requests to the newer v2 format. The original endpoint is marked as deprecated and will be removed in the future. This change assist the transition from the older chat implementation to the newer architecture while maintaining backward compatibility and allowing request to continue to function even after underlying resources such as Clause 2.1 are completely retired in the coming months.
Issue: #802 (closed)
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Pull the branch
- Start the AI Gateway instance
- Send the payload, example below to invoke the endpoint without the redirect active:
curl -X 'POST' \
'http://localhost:5052/v1/chat/agent' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"prompt_components": [
{
"type": "string",
"metadata": {
"source": "string",
"version": "string"
},
"payload": {
"content": "\n\nHuman: hello, what is your name?\n\nAssistant:",
"provider": "anthropic",
"model": "claude-2.1",
"params": {
"stop_sequences": [
"\n\nHuman",
"Observation:"
],
"temperature": 0.2,
"max_tokens_to_sample": 8192
},
"model_endpoint": "string",
"model_api_key": "string",
"model_identifier": "string"
}
}
],
"stream": false
}'
- Send the payload, example below to verify the endpoint with the feature flag activating the redirect:
curl -X 'POST' \
'http://localhost:5052/v1/chat/agent' \
-H 'x-gitlab-enabled-feature-flags: redirect_v1_chat_request' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"prompt_components": [
{
"type": "string",
"metadata": {
"source": "string",
"version": "string"
},
"payload": {
"content": "\n\nHuman: hello, what is your name?\n\nAssistant:",
"provider": "anthropic",
"model": "claude-2.1",
"params": {
"stop_sequences": [
"\n\nHuman",
"Observation:"
],
"temperature": 0.2,
"max_tokens_to_sample": 8192
},
"model_endpoint": "string",
"model_api_key": "string",
"model_identifier": "string"
}
}
],
"stream": false
}'
Merge request checklist
-
Tests added for new functionality. If not, please raise an issue to follow up. -
Documentation added/updated, if needed.
Edited by Michael Thomas