feat: add v2 prompt versions to support claude 3.7 sonnet
What does this merge request do and why?
Creates a new prompt version to support the claude 3.7 model. We are making this a new major version as we can place this around a feature flag to allow for slow rollout of all Duo Chat features.
Relates: gitlab-org/gitlab#521063 (closed)
How to set up and validate locally
Request each v1/prompt/
to ensure the following tool has the updated 2.0.0
definition. The Request to LLM
log should contain the claude-3-7-sonnet-20250219
parameters.
curl -X 'POST' \
'http://gdk.test:5052/v1/prompts/<unit_primitive>' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'x-gitlab-enabled-feature-flags: expanded_ai_logging'\
-d '{"inputs": {<required_data>}, "prompt_version": "2.0.0", "stream": true, }'
Example logs with for documentation_search
:
Log Request
suggestions:Auth is disabled, all users allowed
2025-02-24_23:39:04.03846 gitlab-ai-gateway : INFO:snowplow_tracker.emitters:Emitter initialized with endpoint http://127.0.0.1:9091/com.snowplowanalytics.snowplow/tp2
2025-02-24_23:39:04.12846 gitlab-ai-gateway : 2025-02-24 16:39:04 [info ] Initializing prompt registry from local yaml correlation_id=5b4d993dedf84362bfada42dfcedc280 custom_models_enabled=False default_prompts={}
2025-02-24_23:39:04.12956 gitlab-ai-gateway : 2025-02-24 16:39:04 [info ] Resolved prompt id correlation_id=5b4d993dedf84362bfada42dfcedc280 prompt_id=chat/documentation_search/base
2025-02-24_23:39:04.13347 gitlab-ai-gateway : 2025-02-24 16:39:04 [info ] Returning prompt from the registry correlation_id=5b4d993dedf84362bfada42dfcedc280 prompt_id=chat/documentation_search/base prompt_name='Claude 3 Documentation Search agent' prompt_version=2.0.0
2025-02-24_23:39:04.20302 gitlab-ai-gateway : 2025-02-24 16:39:04 [info ] Request to LLM api_key=None correlation_id=5b4d993dedf84362bfada42dfcedc280 request_content_json={'max_tokens': 4096, 'messages': [{'role': 'user', 'content': 'The following are provided:\n\n* <question>: question\n* <doc>: GitLab documentation, and a ATTRS which will later be converted to URL\n* <example>: example responses\n\nGiven the above:\n\nIf you know the answer, create a final answer.\n * Then return relevant "ATTRS" part for references, under the "ATTRS:" heading.\nIf you don\'t know the answer: start the response with "Unfortunately, I could not find any documentation", and don\'t try to make up an answer.\n\n---\n\nQuestion:\n<question>How do I change my password in GitLab?</question>\n\nDocumentation:\n<doc>\nCONTENT: If you do not know your current password, select **I forgot my password**\nand complete the form. A password reset email is sent to the email address you\nenter into this form, provided that the email address is verified. If you enter an\nunverified email address into this form, no email is sent, and you see the following\nmessage:\n\n> "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."\n\nNOTE:\nYour account can have more than one verified email address, and any email address\nassociated with your account can be verified.\n\n## Password requirements\n\nYour passwords must meet a set of requirements when:\n\n- You choose a password during registration.\n- You choose a new password using the forgotten password reset flow.\n- You change your password proactively.\n- You change your password after it expires.\n- An administrator creates your account.\n- An administrator updates your account.\n\nBy default GitLab enforces the following password requirements:\n\n- Minimum and maximum password lengths. For example,\n see [the settings for GitLab.com](../gitlab_com/index.md#password-requirements).\n- Disallowing [weak passwords](#block-weak-passwords).\n\nSelf-managed installations can configure the following additional password requirements:\n\n- [Password minimum and maximum length limits](../../security/password_length_limits.md).ATTRS: CNT-IDX-fe781284e5cecb386896118bb573adb5\n</doc>\n<doc>\nCONTENT: # Reset a user\'s password\n\nDETAILS:\n**Tier:** Free, Premium, Ultimate\n**Offering:** Self-managed, GitLab Dedicated\n\nYou can reset user passwords by using the UI, a Rake task, a Rails console, or the\n[Users API](../api/users.md#user-modification).\n\n## Prerequisites\n\nTo reset a user password, you must be an administrator of a self-managed GitLab instance.\n\nThe user\'s new password must meet all [password requirements](../user/profile/user_passwords.md#password-requirements).\n\n## Use the UI\n\nTo reset a user\'s password in the UI:\n\n1. On the left sidebar, at the bottom, select **Admin Area**.\n1. Select **Overview > Users**.\n1. For the user whose password you want to update, select **Edit**.\n1. In the **Password** area, type a password and password confirmation.\n1. Select **Save changes**.\n\nA confirmation is displayed.\n\n## Use a Rake task\n\nUse the following Rake task to reset a user\'s password.\n\n::Tabs\n\n:::TabTitle Linux package (Omnibus)\n\n```shell\nsudo gitlab-rake "gitlab:password:reset"\n```\n\n:::TabTitle Self-compiled (source)\n\n```shell\nbundle exec rake "gitlab:password:reset"\n```\n\n::EndTabs\n\nGitLab requests a username, a password, and confirmation of the password. When complete, the user\'s password is updated.\n\nThe Rake task can take a username as an argument. For example, to reset the password for the user with username\n`sidneyjones`:\n\n::Tabs\n\n:::TabTitle Linux package (Omnibus)\n\n ```shell\n sudo gitlab-rake "gitlab:password:reset[sidneyjones]"\n ```\nATTRS: CNT-IDX-9effe73ba22edf411e160f64a0416e80\n</doc>\n<doc>\nCONTENT: # User passwords\n\nDETAILS:\n**Tier:** Free, Premium, Ultimate\n**Offering:** GitLab.com, Self-managed, GitLab Dedicated\n\nIf you use a password to sign in to GitLab, a strong password is very important. A weak or guessable password makes it\neasier for unauthorized people to sign in to your account.\n\nSome organizations require you to meet certain requirements when choosing a password.\n\nImprove the security of your account with [two-factor authentication](account/two_factor_authentication.md)\n\n## Choose your password\n\nYou can choose a password when you [create a user account](account/create_accounts.md).\n\nIf you register your account using an external authentication and\nauthorization provider, you do not need to choose a password. GitLab\n[sets a random, unique, and secure password for you](../../security/passwords_for_integrated_authentication_methods.md).\n\n## Change your password\n\n> - Password reset emails sent to any verified email address [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/16311) in GitLab 16.1.\n\nYou can change your password. GitLab enforces [password requirements](#password-requirements) when you choose your new\npassword.\n\n1. On the left sidebar, select your avatar.\n1. Select **Edit profile**.\n1. On the left sidebar, select **Password**.\n1. In the **Current password** text box, enter your current password.\n1. In the **New password** and **Password confirmation** text box, enter your new password.\n1. Select **Save password**.ATTRS: CNT-IDX-c850f74fc44686f57b644f021f6f55b5\n</doc>\n<doc>\nCONTENT: Commands that change data can cause damage if not run correctly or under the right conditions. Always run commands in a test environment first and have a backup instance ready to restore.\n\nTo reset the Jira user\'s password for all projects with active Jira integrations,\nrun the following in a [Rails console](../../administration/operations/rails_console.md#starting-a-rails-console-session):\n\n```ruby\np = Project.find_by_sql("SELECT p.id FROM projects p LEFT JOIN integrations i ON p.id = i.project_id WHERE i.type_new = \'Integrations::Jira\' AND i.active = true")\n\np.each do |project|\n project.jira_integration.update_attribute(:password, \'<your-new-password>\')\nend\n```\n\n## Jira issue list\n\nWhen [viewing Jira issues](configure.md#view-jira-issues) in GitLab, you might encounter the following issues.\n\n### `500 We\'re sorry` when accessing a Jira issue in GitLab\n\nWhen accessing a Jira issue in GitLab, you might get a `500 We\'re sorry. Something went wrong on our end` error.\nCheck [`production.log`](../../administration/logs/index.md#productionlog) to see if the file contains the following exception:\n\n```plaintext\n:NoMethodError (undefined method \'duedate\' for #<JIRA::Resource::Issue:0x00007f406d7b3180>)\n```\n\nIf that\'s the case, ensure the [**Due date** field is visible for issues](https://confluence.atlassian.com/jirakb/due-date-field-is-missing-189431917.html) in the integrated Jira project.\n\n### Error when requesting data from JiraATTRS: CNT-IDX-361688f033616b72df13d6b3b47552e4\n</doc>\n\nExample responses:\n<example>\n The documentation for configuring AIUL is present. The relevant sections provide step-by-step instructions on how to configure it in GitLab, including the necessary settings and fields. The documentation covers different installation methods, such as A, B and C.\n\n ATTRS:\n CNT-IDX-a52b551c78c6cc11a603e231b4e789b2\n CNT-IDX-27d7595271143710461371bcef69ed1e\n</example>\n<example>\n Unfortunately, I could not find any documentation related to this question.\n\n ATTRS:\n</example>\n<example>\n Unfortunately, I could not find any documentation about the REFS configuration.\n One documentation mentions that the restriction can be changed by an owner, but it does not specify how to do it.\n\n ATTRS:\n CNT-IDX-a52b551c78c6cc11a603e231b4e789b2\n</example>'}, {'role': 'assistant', 'content': 'FINAL ANSWER:'}], 'model': 'claude-3-7-sonnet-20250219', 'stream': True, 'temperature': 0.1} request_method=POST request_url=URL('https://api.anthropic.com/v1/messages') source=ai_gateway.models.base
2025-02-24_23:39:08.35808 gitlab-ai-gateway : 2025-02-24 16:39:08 [info ] Request to LLM complete correlation_id=5b4d993dedf84362bfada42dfcedc280 duration=4.211037499999293 source=ai_gateway.instrumentators.model_requests
2025-02-24_23:39:08.35865 gitlab-ai-gateway : 2025-02-24 16:39:08 [info ] 172.16.123.1:57684 - "POST /v1/prompts/chat/documentation_search HTTP/1.1" 200 client_ip=172.16.123.1 client_port=57684 content_type='text/event-stream; charset=utf-8' correlation_id=5b4d993dedf84362bfada42dfcedc280 cpu_s=0.1964920000000001 duration_request=-1 duration_s=4.320605584000077 enabled_feature_flags=expanded_ai_logging first_chunk_duration_s=1.220505334000336 gitlab_duo_seat_count=None gitlab_feature_enabled_by_namespace_ids=None gitlab_feature_enablement_type=None gitlab_global_user_id=None gitlab_host_name=None gitlab_instance_id=None gitlab_language_server_version=None gitlab_realm=None gitlab_saas_duo_pro_namespace_ids=None gitlab_version=None http_version=1.1 meta.feature_category=ai_abstraction_layer method=POST path=/v1/prompts/chat/documentation_search request_arrived_at=2025-02-24T23:39:04.037905+00:00 response_start_duration_s=0.10896483400028956 status_code=200 tracked_internal_events=['request_documentation_search'] url=http://gdk.test:5052/v1/prompts/chat/documentation_search user_agent=curl/8.7.1
Merge request checklist
-
Tests added for new functionality. If not, please raise an issue to follow up. -
Documentation added/updated, if needed.
Merge request reports
Activity
added groupai framework label
assigned to @nateweinshenker
added devopsai-powered sectiondata-science labels
Reviewer roulette
To spread load more evenly across eligible reviewers, Danger has picked a candidate for each review slot. 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.
Once you've decided who will review this merge request, mention them as you normally would! Danger does not automatically notify them for you.
Reviewer Maintainer @mhamda
(UTC+1, 8 hours ahead of author)
@eduardobonet
(UTC+1, 8 hours ahead of author)
If needed, you can retry the
danger-review
job that generated this comment.Generated by
DangerEdited by ****Can I have some help with Duo Chat to ensure the following are the correct model configurations for the tool Duo Chat tool?
- Resolved by 🤖 GitLab Bot 🤖
Proper labels assigned to this merge request. Please ignore me.
@nateweinshenker
- please see the following guidance and update this merge request.1 Error Please add typebug typefeature, or typemaintenance label to this merge request. Edited by 🤖 GitLab Bot 🤖
added typemaintenance label
requested review from @jessieay
@nateweinshenker can you fill out "## How to set up and validate locally" ?
Update the issue description.
@jessieay Could you please review this merge request?
This change adds a new model configuration file. The follow-up change will set default Duo Chat definitions behind a 2.0.0 model version. We're implementing this approach for a gradual rollout of the new prompt definitions.
Here's the associated issue tracking this change.
index 3cfa1423..a97fc20b 100644 --- a/ai_gateway/chat/container.py +++ b/ai_gateway/chat/container.py @@ -5,6 +5,7 @@ from dependency_injector import containers, providers from ai_gateway.chat.agents import ReActAgent, TypeAgentEvent from ai_gateway.chat.executor import GLAgentRemoteExecutor, TypeAgentFactory from ai_gateway.chat.toolset import DuoChatToolsRegistry +from ai_gateway.feature_flags import FeatureFlag, is_feature_enabled if TYPE_CHECKING: from ai_gateway.prompts import BasePromptRegistry @@ -18,6 +19,9 @@ def _react_agent_factory( prompt_registry: "BasePromptRegistry", ) -> TypeAgentFactory[TypeAgentEvent]: def _fn(**kwargs) -> ReActAgent: + if is_feature_enabled(FeatureFlag.ENABLE_ANTHROPIC_CLAUDE_3_7): + return prompt_registry.get("chat/react", "^2.0.0", **kwargs) + return prompt_registry.get("chat/react", "^1.0.0", **kwargs)
The diff will have usfeature flag check for enabling Claude 3.7, which will use the new 2.0.0 version of the chat/react prompt when enabled.
1 --- 2 name: Claude 3 Build Reader agent changed this line in version 5 of the diff
1 --- 2 name: Claude 3 Commit Reader agent 3 model: 4 config_file: claude_3_7 5 params: 6 max_tokens: 2_048 7 unit_primitives: 8 - ask_commit Question: why does this have a different UP from the 1.0 version?
@jessie thanks for the catch!
changed this line in version 5 of the diff
1 --- 2 name: Claude 3 Documentation Search agent 3 model: 4 config_file: claude_3_7 5 params: 6 temperature: 0.1 Question: should this include
max_tokens
and other params like 1.0?@jessieay We don't need to include the
max_token
because the prompt file overrides the configuration file, given that it's specified last in the dict merge, and the last keys take precedence. E.g.:>>> {**{'a': 1, 'b': 2}, **{'b': 3, 'c': 4}} {'a': 1, 'b': 3, 'c': 4}
Hi @nateweinshenker - I need to take my dog to the vet right now but left some initial feedback here. Can you explain why these prompt templates would look different from the 1.0.0 versions?
@jessieay Part of this was due to Dogfooding Duo Workflow to help speed up making these prompt versions. I didn't do enough combing through the prompt differences before placing it in an MR. Luckily, they are caught by our
unit
tests https://gitlab.com/gitlab-org/modelops/applied-ml/code-suggestions/ai-assist/-/jobs/9232041649.Edited by Nathan Weinshenker
removed review request for @jessieay
mentioned in merge request !2033 (merged)
FYI @juan-silva and team on this MR
mentioned in issue gitlab-org/gitlab#521063 (closed)
assigned to @shinya.maeda
added groupduo chat label and removed groupai framework label
added Category:Duo Chat label
Closing this MR due to https://gitlab.com/gitlab-org/gitlab/-/issues/521058#note_2367094986.
mentioned in issue #810