Create initial Tanuki bot api endpoint
What does this MR do and why?
Related https://gitlab.com/gitlab-org/enablement-section/tanuki-bot/-/issues/2
Creates an API endpoint that receives and responds with json:
POST /-/llm/tanuki_bot/ask
{ "q": "What is advanced search?" }
This is part of a series of MRs and should be reviewed and merged in this order
MR | status |
---|---|
Add support for the embedding database (!118156 - merged) (db setup) | merged ![]() |
Add the tanuki_bot model (!118195 - merged) (migration) | merged ![]() |
Create initial Tanuki bot api endpoint (!117695 - merged) (api) | in review ![]() |
Screenshots or screen recordings
How to set up and validate locally
Feature.enable(:openai_experimentation)
Feature.enable(:tanuki_bot)
::Gitlab::CurrentSettings.update!(openai_api_key: '<YOUR_KEY>')
- Follow instructions for settings up the MR dependency: Add support for the embedding database (!118156 - merged)
- Run migrations:
rails db:migrate
- * Clone the tanuki-bot repository
- * cd into the
pgvector
folder - * use asdf to install python (should be python 3.11.3)
asdf install python
- * install pip
- * install requirements
pip install -r requirements.txt
- * run the command to copy the chroma db to the gdk postgres database
OPENAI_API_KEY=not-an-actual-key PG_USER=<Your user> PG_HOST=<Your gdk install directory>/postgresql python chroma_to_pg.py
- Make an API request to
POST /-/llm/tanuki_bot/ask
* you only need to do this once to have data in the embedding database.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Merge request reports
Activity
assigned to @terrichu
changed milestone to %15.11
added 3 commits
-
da285338...f4cb79de - 2 commits from branch
tchu-bot-service-api
- d320a83b - Create initial Tanuki bot api endpoint
-
da285338...f4cb79de - 2 commits from branch
- Resolved by Terri Chu
mentioned in merge request !117757 (merged)
4 Warnings This merge request is quite big (523 lines changed), please consider splitting it into multiple merge requests. c3499921: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines. featureaddition and featureenhancement merge requests normally have a documentation change. Consider adding a documentation update or confirming the documentation plan with the Technical Writer counterpart.
For more information, see:
- The Handbook page on merge request types.
- The definition of done documentation.
Do not add new controller specs. We are moving from controller specs to
request specs (and/or feature specs). Please add request specs under
/spec/requests
and/or/ee/spec/requests
instead.See &5076 for information.
1 Message This merge request adds or changes files that require a review from the Database team. This merge request requires a database review. To make sure these changes are reviewed, take the following steps:
- Ensure the merge request has database and databasereview pending labels. If the merge request modifies database files, Danger will do this for you.
- Prepare your MR for database review according to the docs.
- Assign and mention the database reviewer suggested by Reviewer Roulette.
If you no longer require a database review, you can remove this suggestion by removing the database label and re-running the
danger-review
job.Reviewer roulette
Changes that require review have been detected!
Please refer to the table below for assigning reviewers and maintainers suggested by Danger in the specified category:
Category Reviewer Maintainer backend Tarun Vellishetty (
@tvellishetty
) (UTC+5.5, 9.5 hours ahead of@terrichu
)Douglas Barbosa Alexandre (
@dbalexandre
) (UTC+0, 4 hours ahead of@terrichu
)database Vitali Tatarintev (
@ck3g
) (UTC+2, 6 hours ahead of@terrichu
)Michał Zając (
@Quintasan
) (UTC+2, 6 hours ahead of@terrichu
)To spread load more evenly across eligible reviewers, Danger has picked a candidate for each review slot, based on their timezone. Feel free to override these selections if you think someone else would be better-suited or use the GitLab Review Workload Dashboard to find other available reviewers.
To read more on how to use the reviewer roulette, please take a look at the Engineering workflow and code review guidelines. Please consider assigning a reviewer or maintainer who is a domain expert in the area of the merge request.
Once you've decided who will review this merge request, assign them as a reviewer! Danger does not automatically notify them for you.
If needed, you can retry the
danger-review
job that generated this comment.Generated by
DangerAllure report
allure-report-publisher
generated test report!e2e-review-qa:
test report for 3bf3b0bdexpand test summary
+-----------------------------------------------------------------------+ | suites summary | +------------------+--------+--------+---------+-------+-------+--------+ | | passed | failed | skipped | flaky | total | result | +------------------+--------+--------+---------+-------+-------+--------+ | Framework sanity | 9 | 0 | 1 | 0 | 10 | ✅ | | Plan | 49 | 0 | 1 | 0 | 50 | ✅ | | Create | 28 | 0 | 1 | 0 | 29 | ✅ | | Data Stores | 22 | 0 | 0 | 0 | 22 | ✅ | | Govern | 24 | 0 | 0 | 0 | 24 | ✅ | | Manage | 8 | 0 | 3 | 0 | 11 | ✅ | | Verify | 10 | 0 | 0 | 0 | 10 | ✅ | | Monitor | 4 | 0 | 0 | 0 | 4 | ✅ | | Package | 0 | 0 | 1 | 0 | 1 | ➖ | +------------------+--------+--------+---------+-------+-------+--------+ | Total | 154 | 0 | 7 | 0 | 161 | ✅ | +------------------+--------+--------+---------+-------+-------+--------+
e2e-package-and-test:
test report for 3bf3b0bdexpand test summary
+-----------------------------------------------------------------------+ | suites summary | +------------------+--------+--------+---------+-------+-------+--------+ | | passed | failed | skipped | flaky | total | result | +------------------+--------+--------+---------+-------+-------+--------+ | Create | 292 | 0 | 42 | 58 | 334 | ❗ | | Verify | 108 | 0 | 8 | 88 | 116 | ❗ | | Manage | 66 | 0 | 6 | 30 | 72 | ❗ | | Plan | 120 | 0 | 0 | 66 | 120 | ❗ | | Monitor | 20 | 0 | 0 | 20 | 20 | ❗ | | Secure | 14 | 0 | 10 | 14 | 24 | ❗ | | Data Stores | 68 | 0 | 0 | 22 | 68 | ❗ | | Govern | 92 | 0 | 0 | 92 | 92 | ❗ | | Fulfillment | 4 | 0 | 48 | 0 | 52 | ✅ | | Release | 12 | 0 | 0 | 8 | 12 | ❗ | | Analytics | 4 | 0 | 0 | 4 | 4 | ❗ | | Framework sanity | 0 | 0 | 2 | 0 | 2 | ➖ | | Package | 0 | 0 | 6 | 0 | 6 | ➖ | | Configure | 0 | 0 | 6 | 0 | 6 | ➖ | | ModelOps | 0 | 0 | 2 | 0 | 2 | ➖ | | Growth | 0 | 0 | 4 | 0 | 4 | ➖ | +------------------+--------+--------+---------+-------+-------+--------+ | Total | 800 | 0 | 134 | 402 | 934 | ❗ | +------------------+--------+--------+---------+-------+-------+--------+
changed milestone to %16.0
mentioned in merge request !117585 (closed)
- Resolved by Dmitry Gruzd
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@a77ae89b
added 2 commits
@zcuddy Continuing the discussion from !117757 (comment 1354791362)
We've slightly changed the URL one more time. Now it is
/-/llm/tanuki_bot/ask
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@15f72d64
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@12f214a4
added 1 commit
- 53c9dda8 - Require q param in controller & service, update specs
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@a190f072
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@228e5f55
added 1 commit
- 4ccd40d5 - Add check for users on paid hosted plans for GitLab.com
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@20ac58d2
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@58f4792e
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@a3ea73cc
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@00fb41ca
- Resolved by Joern Schneeweisz
mentioned in merge request !117967 (merged)
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@7d03fb74
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@bde23721
mentioned in merge request !118195 (merged)
added 840 commits
-
b2b4600e...042f0620 - 808 commits from branch
master
- 042f0620...9188ca8a - 22 earlier commits
- 08a1bd71 - Add check for users on paid hosted plans for GitLab.com
- 841aaebf - Fix bug found in CI, add more FF tests
- d116e9e7 - Remove comment
- 68d5161b - Refactor controller & specs
- 93fba8c7 - Rename licensed feature to ai_tanuki_bot
- 7ef6140a - Update feature flag milestone
- 896e48b0 - Rebase onto database MR and refactor
- b30586fd - Add pgvector to CI
- 7aab64f8 - fixup! Add pgvector to CI
- 857c4b6f - fixup! Rebase onto database MR and refactor
Toggle commit list-
b2b4600e...042f0620 - 808 commits from branch
- A deleted user
added database databasereview pending labels
mentioned in merge request !117793 (closed)
mentioned in merge request !118066 (closed)
mentioned in issue gitlab-org/enablement-section/tanuki-bot#6
mentioned in merge request !118156 (merged)
added 7 commits
-
21bf289a...f45a3261 - 6 commits from branch
add-tanuki-bot-model
- c85fffc3 - Add Tanuki Bot backend service and API
-
21bf289a...f45a3261 - 6 commits from branch
- Resolved by Madelein van Niekerk
- Resolved by Madelein van Niekerk
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@52550556
added 2 commits
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@f95c0865
mentioned in issue gitlab-org/enablement-section/tanuki-bot#25
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@0827b5b1
marked the checklist item I have evaluated the MR acceptance checklist for this MR. as completed
- Resolved by Dmitry Gruzd
- Resolved by Terri Chu
added 331 commits
-
386e22ba...d1de43d8 - 325 commits from branch
add-tanuki-bot-model
- 735deefc - Add Tanuki Bot backend service and API
- 91c20192 - Update feature flag MR
- a94b5857 - Move feature flag to ee
- 5887599f - Move endpoint out of namespace
- a7327eb0 - Remove comment and reference to trait
- 0d274684 - Revert "Move endpoint out of namespace"
Toggle commit list-
386e22ba...d1de43d8 - 325 commits from branch
- Resolved by Terri Chu
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@f1bef531
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@cda15c62
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@c27fe807
mentioned in merge request !117597 (merged)
added pipeline:run-all-rspec label
removed databasereview pending label
removed database label
added 12 commits
-
1f3556bc...b1254bc1 - 2 commits from branch
add-tanuki-bot-model
- 7373b94c - Add Tanuki Bot backend service and API
- 5e911caa - Update feature flag MR
- df2d19de - Move feature flag to ee
- 1437d444 - Move endpoint out of namespace
- 0c11913e - Remove comment and reference to trait
- 26178ef5 - Revert "Move endpoint out of namespace"
- c88241fb - Apply 1 suggestion(s) to 1 file(s)
- d766cff5 - Fixes from testing with frontend
- 9efe23c3 - fix locale issue
- cc74643f - Refactor factory and use in spec
Toggle commit list-
1f3556bc...b1254bc1 - 2 commits from branch
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@4f062239
added 176 commits
-
cc74643f...bccfe653 - 166 commits from branch
add-tanuki-bot-model
- 0efbc4ca - Add Tanuki Bot backend service and API
- fdda4fde - Update feature flag MR
- de269410 - Move feature flag to ee
- af9c428e - Move endpoint out of namespace
- 4853da02 - Remove comment and reference to trait
- bd714ff5 - Revert "Move endpoint out of namespace"
- 86109120 - Apply 1 suggestion(s) to 1 file(s)
- 52120af9 - Fixes from testing with frontend
- 70c3f86c - fix locale issue
- b919318a - Refactor factory and use in spec
Toggle commit list-
cc74643f...bccfe653 - 166 commits from branch
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@45cf4158
added 3 commits
-
b919318a...cc921dbe - 2 commits from branch
add-tanuki-bot-model
- 4e435014 - Add Tanuki Bot backend service and API
-
b919318a...cc921dbe - 2 commits from branch
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@1833ab6a
added 23 commits
-
4e435014...1d98f59d - 22 commits from branch
add-tanuki-bot-model
- 4ebace43 - Add Tanuki Bot backend service and API
-
4e435014...1d98f59d - 22 commits from branch
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@94bb5ce5
added 3 commits
-
4ebace43...d5daa9ef - 2 commits from branch
add-tanuki-bot-model
- 645dbd9d - Add Tanuki Bot backend service and API
-
4ebace43...d5daa9ef - 2 commits from branch
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@d5ff0072
requested review from @mattkasa
- Resolved by Madelein van Niekerk
requested review from @tkuah
mentioned in merge request !118463 (merged)
- Resolved by Stan Hu
- Resolved by Stan Hu
- Resolved by Stan Hu
- Resolved by Stan Hu
- Resolved by Terri Chu
- Resolved by Stan Hu
- Resolved by Stan Hu
removed review request for @stanhu
added 5 commits
-
645dbd9d...ddc3abd9 - 3 commits from branch
add-tanuki-bot-model
- 1a40621c - Add Tanuki Bot backend service and API
- fa9fb74a - Rebase changes and address reviewer's feedback
-
645dbd9d...ddc3abd9 - 3 commits from branch
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@79f56a27
added 1 commit
- 7fa45e42 - fixup! Rebase changes and address reviewer's feedback
added 1 commit
- 6ae42d15 - fixup! Rebase changes and address reviewer's feedback
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@bf4716a7
added 1 commit
- 9be62654 - fixup! Rebase changes and address reviewer's feedback
added 1 commit
- 629087ff - Rebase changes and address reviewer's feedback
added 1 commit
- 85722d1f - Rebase changes and address reviewer's feedback
added 1 commit
- 4b11ab4d - Rebase changes and address reviewer's feedback
added 1 commit
- 6df6c845 - Rebase changes and address reviewer's feedback
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@6e8a0b60
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@8cb53a11
added 1 commit
- 1cabdfa3 - Rebase changes and address reviewer's feedback
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@880f61bd
added 1 commit
- d1a04f64 - Rebase changes and address reviewer's feedback
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@f091d03a
- A deleted user
added database databasereview pending labels
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@5cc2bdd6
added 409 commits
-
d1a04f64...2b0dcabb - 407 commits from branch
master
- 01555c4f - Add Tanuki Bot backend service and API
- c3499921 - Rebase changes and address reviewer's feedback
-
d1a04f64...2b0dcabb - 407 commits from branch
@stanhu thank you for the review! I believe it is ready for another look
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@339101a9
- Resolved by Terri Chu
- Resolved by Stan Hu
- Resolved by Stan Hu
Hmm, it looks like
pgvector
was not building on my system sinceMacOS13.0sdk
doesn't exist:-------------------------------------------------------------------------------- Building pgvector/vector.so version v0.4.1 -------------------------------------------------------------------------------- clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk' [-Wmissing-sysroot] In file included from src/ivfbuild.c:1: In file included from /Users/stanhu/.asdf/installs/postgres/12.13/include/server/postgres.h:46: /Users/stanhu/.asdf/installs/postgres/12.13/include/server/c.h:59:10: fatal error: 'stdio.h' file not found #include <stdio.h> ^~~~~~~~~ 1 error generated. make[1]: *** [src/ivfbuild.o] Error 1 make: *** [pgvector/vector.so] Error 2
% ls -al /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs total 0 drwxr-xr-x 5 root wheel 160 Apr 1 05:17 . drwxr-xr-x 6 root wheel 192 Mar 24 04:08 .. drwxr-xr-x 7 root wheel 224 Mar 9 16:58 MacOSX.sdk lrwxr-xr-x 1 root wheel 10 Apr 1 05:13 MacOSX13.3.sdk -> MacOSX.sdk lrwxr-xr-x 1 root wheel 10 Apr 1 05:13 MacOSX13.sdk -> MacOSX.sdk
I may have been messing with this when testing another merge request. Creating a symlink fixed the problem.
- Resolved by Stan Hu
I have to set up an OpenAI key? That worries me a little.
% PG_HOST=~/gdk-ee/postgresql python chroma_to_pg.py Traceback (most recent call last): File "/Users/stanhu/gitlab/tanuki-bot/pgvector/chroma_to_pg.py", line 23, in <module> embedding = OpenAIEmbeddings() ^^^^^^^^^^^^^^^^^^ File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__ pydantic.error_wrappers.ValidationError: 1 validation error for OpenAIEmbeddings __root__ Did not find openai_api_key, please add an environment variable `OPENAI_API_KEY` which contains it, or pass `openai_api_key` as a named parameter. (type=value_error)
added 1 commit
- 39c5377f - Rebase changes and address reviewer's feedback
4 Warnings This merge request is quite big (526 lines changed), please consider splitting it into multiple merge requests. 39c5377f: Commits that change 30 or more lines across at least 3 files should describe these changes in the commit body. For more information, take a look at our Commit message guidelines. featureaddition and featureenhancement merge requests normally have a documentation change. Consider adding a documentation update or confirming the documentation plan with the Technical Writer counterpart.
For more information, see:
- The Handbook page on merge request types.
- The definition of done documentation.
Do not add new controller specs. We are moving from controller specs to
request specs (and/or feature specs). Please add request specs under
/spec/requests
and/or/ee/spec/requests
instead.See &5076 for information.
Reviewer roulette
Changes that require review have been detected!
Please refer to the table below for assigning reviewers and maintainers suggested by Danger in the specified category:
Category Reviewer Maintainer backend Thomas Hutterer (
@thutterer
) (UTC+2, 6 hours ahead of@terrichu
)Peter Leitzen (
@splattael
) (UTC+2, 6 hours ahead of@terrichu
)To spread load more evenly across eligible reviewers, Danger has picked a candidate for each review slot, based on their timezone. Feel free to override these selections if you think someone else would be better-suited or use the GitLab Review Workload Dashboard to find other available reviewers.
To read more on how to use the reviewer roulette, please take a look at the Engineering workflow and code review guidelines. Please consider assigning a reviewer or maintainer who is a domain expert in the area of the merge request.
Once you've decided who will review this merge request, assign them as a reviewer! Danger does not automatically notify them for you.
If needed, you can retry the
danger-review
job that generated this comment.Generated by
Dangerremoved database label
removed databasereview pending label
- Resolved by Dmitry Gruzd
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@78efbf4b
@stanhu
, thanks for approving this merge request.This is the first time the merge request is approved. To ensure full test coverage, a new pipeline will be started shortly.
For more info, please refer to the following links:
added pipeline:mr-approved label
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@ff934843
- Resolved by Stan Hu
mentioned in commit gitlab-org-sandbox/gitlab-jh-validation@e4d22daf
enabled an automatic merge when the pipeline for e4d22daf succeeds
mentioned in commit cd0dca6f
added workflowstaging-canary label
added workflowcanary label and removed workflowstaging-canary label
added workflowstaging label and removed workflowcanary label
added workflowproduction label and removed workflowstaging label
mentioned in issue gitlab-org/enablement-section/tanuki-bot#32
mentioned in issue gitlab-org/enablement-section/tanuki-bot#33
added workflowpost-deploy-db-staging label and removed workflowproduction label
added workflowpost-deploy-db-production label and removed workflowpost-deploy-db-staging label
added releasedcandidate label
mentioned in epic &10524
mentioned in merge request kubitus-project/kubitus-installer!2145 (merged)
mentioned in merge request gitlab-com/www-gitlab-com!126154 (merged)
mentioned in issue #461062 (closed)