fix: docs search performed in server thread
What does this merge request do and why?
This MR fixes the issue that the gitlab-docs search performed in the server thread. This is network I/O bound process, hence it should use AsyncIO to avoid blocking the server thread.
How to set up and validate locally
- Checkout this branch and run
poetry run ai_gateway
.
Request example:
curl -X 'POST' \
'http://localhost:5052/v1/search/gitlab-docs' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"type": "string",
"metadata": {
"source": "string",
"version": "17.0"
},
"payload": {
"query": "how to create an issue?"
}
}'
Response example:
{
"response": {
"results": [
{
"id": "7e85d5fbdaf1414e0469f41bec5c7b9e",
"content": "# Create an issue\n\nDETAILS:\n**Tier:** Free, Premium, Ultimate\n**Offering:** GitLab.com, Self-managed, GitLab Dedicated\n\nWhen you create an issue, you are prompted to enter the fields of the issue.\nIf you know the values you want to assign to an issue, you can use\n[quick actions](../quick_actions.md) to enter them.\n\nYou can create an issue in many ways in GitLab:\n\n- [From a project](#from-a-project)\n- [From a group](#from-a-group)\n- [From another issue or incident](#from-another-issue-or-incident)\n- [From an issue board](#from-an-issue-board)\n- [By sending an email](#by-sending-an-email)\n- [Using a URL with prefilled values](#using-a-url-with-prefilled-values)\n- [Using Service Desk](#using-service-desk)\n\n## From a project\n\nPrerequisites:\n\n- You must have at least the Guest role for the project.\n\nTo create an issue:\n\n1. On the left sidebar, select **Search or go to** and find your project.\n1. Either:\n\n - On the left sidebar, select **Plan > Issues**, and then, in the upper-right corner, select **New issue**.\n - On the left sidebar, at the top, select the plus sign (**{plus}**) and then, under **In this project**,\n select **New issue**.\n\n1. Complete the [fields](#fields-in-the-new-issue-form).\n1. Select **Create issue**.\n\nThe newly created issue opens.\n\n## From a group\n\nIssues belong to projects, but when you're in a group, you can access and create issues that belong\nto the projects in the group.\n\nPrerequisites:\n",
"metadata": {
"source_type": "doc",
"title": "Create an issue",
"md5sum": "7984b425ebb2afbbf53eabfb1cdfc712adcbd672c982df02c9a7675bd9a82993",
"source": "user/project/issues/create_issues.md",
"source_url": "https://gitlab.com/help/user/project/issues/create_issues"
}
},
{
"id": "908aac3b791908bad6c1043f84b61a68",
"content": "- You must have at least the Guest role for the project.\n\nTo create an issue from a project issue board:\n\n1. On the left sidebar, select **Search or go to** and find your project.\n1. Select **Plan > Issue boards**.\n1. At the top of a board list, select **Create new issue** (**{plus-square}**).\n1. Enter the issue's title.\n1. Select **Create issue**.\n\nTo create an issue from a group issue board:\n\n1. On the left sidebar, select **Search or go to** and find your group.\n1. Select **Plan > Issue boards**.\n1. At the top of a board list, select **Create new issue** (**{plus-square}**).\n1. Enter the issue's title.\n1. Under **Projects**, select the project in the group that the issue should belong to.\n1. Select **Create issue**.\n\nThe issue is created and shows up in the board list. It shares the list's characteristic, so, for\nexample, if the list is scoped to a label `Frontend`, the new issue also has this label.\n\n## By sending an email\n\nYou can send an email to create an issue in a project on the project's\n**Issues List** page.\n\nPrerequisites:\n\n- Your GitLab instance must have [incoming email](../../../administration/incoming_email.md)\n configured with [email sub-addressing or catch-all mailbox](../../../administration/incoming_email.md#requirements).\n- There must be at least one issue in the issue list.\n- You must have at least the Guest role for the project.\n\nTo email an issue to a project:\n\n1. On the left sidebar, select **Search or go to** and find your project.",
"metadata": {
"title": "Create an issue",
"source_type": "doc",
"md5sum": "7984b425ebb2afbbf53eabfb1cdfc712adcbd672c982df02c9a7675bd9a82993",
"source_url": "https://gitlab.com/help/user/project/issues/create_issues",
"source": "user/project/issues/create_issues.md"
}
}
]
},
"metadata": {
"provider": "vertex-ai",
"timestamp": 1716259270
}
}
Merge request checklist
-
Tests added for new functionality. If not, please raise an issue to follow up. -
Documentation added/updated, if needed.
Edited by Shinya Maeda