Populate safety attributes on Anthropic output
What does this merge request do and why?
This fixes an issue with attempting to extract nullable safety
attributes for code generations. safety_attributes
is now a required
field for TextGenModelOutput
and can't not be None
. This helps to ensure
a consistent interface for the caller and avoid multiple layers of None
value
checks.
How to set up and validate locally
- Check out to this merge request's branch.
- Configure
ANTHROPIC_API_KEY
in the.env
file. - Ensure a local Docker image built successfully.
docker buildx build --platform linux/amd64 -t ai-gateway:test .
- Run a local service on Docker.
docker run --platform linux/amd64 --rm \ -p 5052:5052 \ -e AUTH_BYPASS_EXTERNAL=true \ -v $PWD:/app -it ai-gateway:test
- Execute the following cURL.
curl --request POST \ --url http://codesuggestions.gdk.test:5052/v2/code/generations \ --header 'Content-Type: application/json' \ --data '{ "current_file": { "file_name": "snippets/python/censor.py", "content_above_cursor": "# Hello world", "content_below_cursor": "\n" }, "prompt_version": 2, "prompt": "Human: Write a wonderful function\n", "model_provider": "anthropic" } '
- Confirm 200 HTTP response and no error in the logs.
Merge request checklist
-
Tests added for new functionality. If not, please raise an issue to follow up. -
Documentation added/updated, if needed.
Closes #319 (closed)
Edited by Tan Le