Add AiCatalogItem.configurationForProject field
What does this MR do and why?
Add a new AiCatalogItem.configurationForProject
GraphQL field.
The field returns the Ai::Catalog::ItemConsumer
(referred to as a item configuration in GraphQL) for an AI Catalog item and the given project.
How to set up and validate locally
Enable the global_ai_catalog
flag.
(Optional). Patch your local to allow any project to create AI Catalog items.
diff --git a/ee/app/models/ee/project.rb b/ee/app/models/ee/project.rb
index dc8c5541fcea..c6ac444489ec 100644
--- a/ee/app/models/ee/project.rb
+++ b/ee/app/models/ee/project.rb
@@ -622,6 +622,7 @@ def suggested_reviewers_available?
end
def ai_catalog_available?
+ return true
duo_features_enabled && ::Gitlab::Llm::StageCheck.available?(self, :ai_catalog)
end
strong_memoize_attr :ai_catalog_available?
Visit http://gdk.test:3000/explore/ai-catalog/agents/ and create some agents for a project https://docs.gitlab.com/user/duo_agent_platform/agents/#create-an-agent.
Add one of the agents to the project https://docs.gitlab.com/user/duo_agent_platform/agents/#enable-an-agent.
Now visit http://gdk.test:3000/-/graphql-explorer and perform some GraphQL queries, substitute <ITEM_ID>
with the ID of the agent (visible when viewing the agent in the AI Catalog) and <PROJECT_ID>
with your project ID:
Query using the agent ID you added to the project.
{
aiCatalogItem(id: "gid://gitlab/Ai::Catalog::Item/<ITEM_ID>") {
id
configurationForProject(projectId: "gid://gitlab/Project/<PROJECT_ID>") {
id
enabled
}
}
}
You should get a response similar to:
{
"data": {
"aiCatalogItem": {
"id": "gid://gitlab/Ai::Catalog::Item/192",
"configurationForProject": {
"id": "gid://gitlab/Ai::Catalog::ItemConsumer/39",
"enabled": true
}
}
},
"correlationId": "01K852F1A8RGHD6TH7EVK98TJS"
}
Now query for the agent you did not add to the project, you should get a response similar to:
{
"data": {
"aiCatalogItem": {
"id": "gid://gitlab/Ai::Catalog::Item/191",
"configurationForProject": null
}
},
"correlationId": "01K85437PZAXEMY46J19HABFMM"
}
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #577040