Add repository x ray endpoint
What does this merge request do and why?
Completes #347 (closed)
As part of gitlab-org&12060 (closed) new endpoint is required in AI Gateway that is able to proxy requests from X-Ray scanner job into LLM.
/x-ray/libraries
endpoint is designed according to https://docs.gitlab.com/ee/architecture/blueprints/ai_gateway/index.html#protocol and it aims to be prompt agnostic. That means that clients using it are responsible for composing valid prompt template string, as well as for supplying all required variable for that prompt template. Such approach should reduce need to align updates in two repositories: X-Ray scanner and AI Gateway, as new feature is iterated on.
How to set up and validate locally
curl -X 'POST' \
'http://localhost:5052/v1/x-ray/libraries' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"prompt_components": [
{
"type":"x_ray_package_file_prompt",
"payload":{
"prompt": "Human: Parse Gemfile content: `gem kaminari`. Respond using only valid JSON with list of libraries.\n\nAssistant:",
"provider": "anthropic",
"model": "claude-2.0"
},
"metadata": {"scannerVersion": "0.0.1"}
}
]
}'
{
"response": " Here is the response in valid JSON format with the list of libraries parsed from the Gemfile content:\n\n```json\n[\n \"kaminari\"\n]\n```"
}
Merge request checklist
-
Tests added for new functionality. If not, please raise an issue to follow up. -
Documentation added/updated, if needed.
Edited by Tan Le