chore: Add additional context type for terminal to API
What does this MR do and why?
Adds a new AI Additional Context Type of "terminal" to the GraphQL API.
Uses the "include_terminal_context" cloud connector unit primitive.
⛓️
Merge Chain Project | MR | - |
---|---|---|
Cloud Connector | Move explain_terminal unit primitive to included context | |
AI Gateway | feat: add additional context type 'terminal' | |
Rails Monolith | Add additional context type for terminal to API | <-- You are here! |
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
Depends on gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!2059 (merged)
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
-
Run
bundle exec rails c
-
Start
gdk
with LLM debug. In yourgdk
directory run the following commands:export LLM_DEBUG=1
gdk start
tail -f rails/log/llm.log
-
Navigate to http://gdk.test:3000/-/graphql-explorer
-
Run the following mutation:
mutation newTerminalChatMessage{ aiAction(input: {chat: { resourceId: "gid://gitlab/User/1", content: "Explain terminal input", additionalContext: [ { id: "test" category: TERMINAL, content: "$ git status" } ]}}) { clientMutationId errors requestId } }
-
Check LLM logs
-
You should see a record similar to this truncated example
{"severity":"DEBUG","time":"2024-08-08T09:40:34.337Z","action_name":"chat","options":{"content":"Explain terminal input","additional_context":[{"type":"terminal","content":"$ git status"}],"referer_url":"http://gdk.test:3000/-/graphql-explorer"}}
-
Run the following query, replacing
<requestId>
with the value from the response in step 4.
query getAiMessages {
aiMessages(requestIds: ["<requestId>"]) {
nodes {
requestId
role
content
contentHtml
timestamp
errors
extras {
sources
additionalContext {
id
category
metadata
content
}
}
}
}
}
- The result should contain:
-
"category": "TERMINAL"
, -
"content": "$ git status"
, - no errors