Skip to content
代码片段 群组 项目
未验证 提交 c9036165 编辑于 作者: Tomas Bulva's avatar Tomas Bulva 提交者: GitLab
浏览文件

Merge branch '463135-initialise-new-self-hosted-model-app' into 'master'

Initialise Self-hosted Model Create App

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/160674



Merged-by: default avatarTomas Bulva <tbulva@gitlab.com>
Approved-by: default avatarTomas Bulva <tbulva@gitlab.com>
Reviewed-by: default avatarEduardo Bonet <ebonet@gitlab.com>
Co-authored-by: default avatarJulie Huang <julhuang@gitlab.com>
No related branches found
No related tags found
无相关合并请求
<script>
import { s__ } from '~/locale';
import selfHostedModelCreateMutation from '../graphql/mutations/create_self_hosted_model.mutation.graphql';
const MUTATION_NAME = 'aiSelfHostedModelCreate';
export default {
name: 'NewSelfHostedModel',
props: {
basePath: {
type: String,
required: true,
},
modelOptions: {
type: Array,
required: true,
},
},
i18n: {
title: s__('AdminSelfHostedModels|Add self-hosted models'),
description: s__(
'AdminSelfHostedModels|Add a new AI model that can be used for GitLab Duo features.',
),
},
mutationData: {
name: MUTATION_NAME,
mutation: selfHostedModelCreateMutation,
},
};
</script>
<template>
<div>
<h1>{{ $options.i18n.title }}</h1>
<p class="gl-pt-3 gl-pb-2">
{{ $options.i18n.description }}
</p>
<!--
TODO: Add form for creating self hosted model.
The form will be passed props basePath, modelOptions and mutationData.
-->
</div>
</template>
mutation createSelfHostedModel($input: AiSelfHostedModelCreateInput!) {
aiSelfHostedModelCreate(input: $input) {
errors
}
}
import { initSimpleApp } from '~/helpers/init_simple_app_helper';
import NewSelfHostedModel from '../components/new_self_hosted_model.vue';
initSimpleApp('#js-new-self-hosted-model', NewSelfHostedModel, { withApolloProvider: true });
- page_title s_('AdminSelfHostedModels|New self-hosted model') - page_title s_('AdminSelfHostedModels|Add self-hosted models')
%h1.page-title.gl-font-size-h-display - if Feature.enabled?(:custom_models_vue_app, current_user)
= s_('AdminSelfHostedModels|New self-hosted model') - model_options = Ai::SelfHostedModel.models.map { |name, _| { modelValue: name.upcase, modelName: name.capitalize } }
= render 'form', url: admin_ai_self_hosted_models_path, back_path: admin_ai_self_hosted_models_path
#js-new-self-hosted-model{ data: { view_model: { basePath: admin_ai_self_hosted_models_path, modelOptions: model_options }.to_json } }
- else
%h1.page-title.gl-text-size-h-display
= s_('AdminSelfHostedModels|Add self-hosted models')
= render 'form', url: admin_ai_self_hosted_models_path, back_path: admin_ai_self_hosted_models_path
...@@ -30,3 +30,11 @@ export const mockAiSelfHostedModelsQueryResponse = { ...@@ -30,3 +30,11 @@ export const mockAiSelfHostedModelsQueryResponse = {
}, },
}, },
}; };
export const SELF_HOSTED_MODEL_OPTIONS = [
{ modelValue: 'MIXTRAL', modelName: 'Mixtral' },
{ modelValue: 'MISTRAL', modelName: 'Mistral' },
{ modelValue: 'CODEGEMMA', modelName: 'Codegemma' },
{ modelValue: 'CODESTRAL', modelName: 'Codestral' },
{ modelValue: 'CODELLAMA', modelName: 'Codellama' },
];
import { mountExtended } from 'helpers/vue_test_utils_helper';
import NewSelfHostedModel from 'ee/pages/admin/ai/self_hosted_models/components/new_self_hosted_model.vue';
import { SELF_HOSTED_MODEL_OPTIONS } from './mock_data';
describe('NewSelfHostedModel', () => {
let wrapper;
const basePath = '/admin/ai/self_hosted_models';
const createComponent = () => {
wrapper = mountExtended(NewSelfHostedModel, {
propsData: {
basePath,
modelOptions: SELF_HOSTED_MODEL_OPTIONS,
},
});
};
beforeEach(() => {
createComponent();
});
it('has a title', () => {
expect(wrapper.text()).toMatch('Add self-hosted models');
});
it('has a description', () => {
expect(wrapper.text()).toMatch('Add a new AI model that can be used for GitLab Duo features.');
});
});
...@@ -3729,9 +3729,15 @@ msgstr "" ...@@ -3729,9 +3729,15 @@ msgstr ""
msgid "AdminSelfHostedModels|API token (if needed)" msgid "AdminSelfHostedModels|API token (if needed)"
msgstr "" msgstr ""
   
msgid "AdminSelfHostedModels|Add a new AI model that can be used for GitLab Duo features."
msgstr ""
msgid "AdminSelfHostedModels|Add self-hosted language models to use as backups for GitLab Duo features." msgid "AdminSelfHostedModels|Add self-hosted language models to use as backups for GitLab Duo features."
msgstr "" msgstr ""
   
msgid "AdminSelfHostedModels|Add self-hosted models"
msgstr ""
msgid "AdminSelfHostedModels|An API key is set" msgid "AdminSelfHostedModels|An API key is set"
msgstr "" msgstr ""
   
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册