feat: add xray data to /refactor, /fix, and /tests prompts
What does this merge request do and why?
For gitlab-org/gitlab#450753 (closed)
- gitlab-org/gitlab!173750 (merged) solves the monolith part
- This MR solves the aigw part
The Repository X-Ray is a tool that searches for dependency manager configuration/lock files and then extracts a list of libraries from the content.
gitlab-org/gitlab!173750 (merged) fetches the latest xray report (if available) for a project and includes this xray_data
in the prompt_options
that are passed to the aigw for /refactor
, /fix
, and /tests
. This MR then adds the xray_data
to the corresponding prompts in the aigw. Given this context the code refactored/fixed/with tests should be more relevant and higher quality.
How to set up and validate locally
- Set up LangSmith tracing for Duo Chat: https://docs.gitlab.com/ee/development/ai_features/duo_chat.html#use-tracing-with-langsmith
- Follow the validation steps in this related MR to trigger creating an xray report for a project in gdk. Make a note of the project id where the xray report was generated: gitlab-org/gitlab!165391 (merged)
- Run
gdk
locally butgdk stop gitlab-ai-gateway
, we're going to run this separately - Open a second terminal and
cd gitlab-ai-gateway
thenpoetry shell
andpoetry run ai_gateway
- Go to the graphql explorer: http://gdk.test:3000/-/graphql-explorer
- Run a mutation to trigger
/refactor
,/fix
, or/tests
, be sure to pass in the correct id for the project where you created an xray reportmutation { aiAction( input: { chat: { content: "/refactor", currentFile: { selectedText: "\n@sold_items = %w( onions garlic potatoes ) \ndef print_report\nputs '*** Sales Report for #{Time.new.strftime('%d/%m/%Y')} ***'\n@sold_items.each { |i| puts i }\nputs '*** End of Sales Report ***'\nend", fileName: "hello.rb" }, resourceId: "gid://gitlab/Project/25" }, } ) { clientMutationId errors } }
- Open LangSmith and go to the project you set up for tracing. You should see a new run for the
/refactor
call you just made - The ChatAnthropic section shows the compiled System prompt. Verify that the prompt includes the injected xray libraries!
Here are some examples:
-
/refactor
➡️ https://smith.langchain.com/public/cc4abef2-ea4c-4fae-beaa-868051a26778/r -
/fix
➡️ https://smith.langchain.com/public/a0eb12f8-4146-4ea1-b6e5-6e708ad8b444/r -
/tests
➡️ https://smith.langchain.com/public/bceff713-62c7-4e12-82b6-dd01cc90f06b/r
Screenshots or screen recordings
See
Merge request checklist
-
Tests added for new functionality. If not, please raise an issue to follow up. -
Documentation added/updated, if needed.
Edited by Missy Davies