Skip to content

Add /v1/chat/agent endpoint (with `prompt_components` list)

What does this merge request do and why?

See the discussion on the payload structure in gitlab-org/gitlab!135837 (comment 1645445571)

We expect a prompt_components list, but expect only a single element.


Introduces the first iteration of the /v1/chat/agent endpoint that will be used to enable Duo Chat for Self-Managed users.
Response streaming will be introduced in a separate follow-up MR.

Screenshots

Happy path

Screenshot_2023-11-10_at_14.05.33

Receiving multiple prompt_components (not expected)

Screenshot_2023-11-10_at_14.06.46

How to set up and validate locally

  1. Pull the branch
  2. Start the instance
  3. Open http://0.0.0.0:5052/docs#/chat/chat_v1_chat_agent_post
  4. Send the payload, example below:
{
  "prompt_components": [
    {
      "type": "prompt",
      "metadata": {
        "source": "test-source",
        "version": "no-version"
      },
      "payload": {
        "content": "\n\nHuman: hello, what is your name?\n\nAssistant:",
        "provider": "anthropic",
        "model": "claude-2"
      }
    }
  ]
}

Merge request checklist

  • Tests added for new functionality. If not, please raise an issue to follow up.
  • Documentation added/updated, if needed.

Closes #317 (closed)

Edited by Aleksei Lipniagov

Merge request reports