Skip to content

Add AdditionalContext to GraphQL AIMessageType

What does this MR do and why?

Allow to retrieve additional context from AIMessages

Related to #480703 (closed)

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

Screenshot_2024-09-05_at_11.33.06

How to set up and validate locally

  1. Run bundle exec rails c
  2. Find a required user user = User.find_by_username('<YOUR-USERNAME>')
  3. Make sure feature flag is enabled Feature.enable(:duo_additional_context, user)
  4. In your browser make sure you're logged in at http://gdk.test:3000 as a user from previous steps
  5. Navigate to http://gdk.test:3000/-/graphql-explorer
  6. Run the following mutation to create a message with the context
    mutation {
      aiAction(input: {chat: {content: "Explain this code", additionalContext: [
        {
          category: SNIPPET, id: "hello world", content: "puts 'Hello, world'",
          metadata: "{\"freeform\":\"json\"}"
        }
      ]}}) {
        clientMutationId
        errors
      }
    }
  7. Read the recent messages using following GraphQL query
    query getMessages {
      aiMessages {
        edges {
          node {
            id
            content
            additionalContext {
              id
              category
              content
              metadata
            }
          }
        }
      }
    }
Edited by Vitali Tatarintev

Merge request reports

Loading