GitLab Chat: Use moderation API
What does this MR do and why?
We've just merged !119050 (merged), which introduces moderation API usage. For GitLab chat, the defaults don't make sense. We only need to use it for the initial question that's turned into embeddings.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
- enable gdk for pgvector:
gdk config set pgvector.enabled true
- enable the embedding database:
gdk config set gitlab.rails.databases.embedding.enabled true
gdk reconfigure
- open rails console:
rails c
- Enable checks:
Feature.enable(:openai_experimentation)
,Feature.enable(:tanuki_bot)
,Feature.enable(:openai_moderation)
- Add openAI api key:
Gitlab::CurrentSettings.update(openai_api_key: "<openai-api-token>")
- Execute the script to bootstrap the database
- Execute
Gitlab::Llm::TanukiBot.execute(current_user: User.first, question: 'What is advanced search?')
- Ensure that it returns a valid response
- Replace the question with an example from https://platform.openai.com/docs/api-reference/moderations/create
- It should raise an exeption
Gitlab::Llm::OpenAi::Client::InputModerationError: Provided input violates OpenAI's Content Policy
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Dmitry Gruzd