#4205 add finetune patch

Merged
chenshihai merged 1 commits from V20230517.patch_ft into V20230517.patch 11 months ago
  1. +11
    -0
      models/modelarts_deploy.go
  2. +19
    -2
      routers/api/v1/finetune/panguervice.go
  3. +1
    -1
      routers/routes/routes.go
  4. +1
    -0
      templates/repo/modelarts/trainjob/show.tmpl
  5. +9
    -0
      web_src/js/features/cloudbrainShow.js
  6. +98
    -9
      web_src/vuepages/pages/modelbase/home/index.vue
  7. +36
    -3
      web_src/vuepages/pages/modelbase/inference/index.vue

+ 11
- 0
models/modelarts_deploy.go View File

@@ -241,3 +241,14 @@ func DeployStatusConvert(status string) string {
return statusConvert
}
}

func GetModelartsDeployFinishTimebyJobID(jobID string) (finishTime timeutil.TimeStamp, err error) {
finishTime = timeutil.TimeStamp(0)
deploy, err := GetModelartsDeployByJobID(jobID)
if err != nil || deploy.CompleteUnix == timeutil.TimeStamp(0) {
return finishTime, err
} else {
finishTime = deploy.CompleteUnix.Add(int64(30 * 60))
return finishTime, nil
}
}

+ 19
- 2
routers/api/v1/finetune/panguervice.go View File

@@ -199,9 +199,26 @@ func SyncPanguDeployStatus() {

func GetPanguDeployStatus(ctx *context.APIContext) {
var jobID = ctx.Params(":jobid")
status, _ := models.GetModelartsDeployStatusByJobID(jobID)

status, err := models.GetModelartsDeployStatusByJobID(jobID)
if err != nil {
log.Info("panguService: GetPanguDeployStatus, jobID %s, err %v", jobID, status, err)
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(err.Error()))
return
}

finishTime, err := models.GetModelartsDeployFinishTimebyJobID(jobID)
if err != nil {
log.Info("panguService: GetModelartsDeployFinishTimebyJobID, jobID %s, err %v", jobID, status, err)
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(err.Error()))
return
}

log.Info("panguService: GetPanguDeployStatus, jobID %s, status %s, finishTime %s", jobID, status, finishTime)

ctx.JSON(http.StatusOK, map[string]interface{}{
"fineTuneDeployStatus": status,
"fineTuneDeployStatus": status,
"fineTuneDeployFinishTime": finishTime,
})
}



+ 1
- 1
routers/routes/routes.go View File

@@ -385,7 +385,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("", modelapp.ModelBaseUI)
m.Group("/pangufinetune", func() {
m.Get("", modelapp.PanguFinetuneUI)
m.Get("/create", reqSignIn, modelapp.PanguFinetuneCreateUI)
m.Get("/create", reqSignIn, reqWechatBind, modelapp.PanguFinetuneCreateUI)
m.Get("/inference", reqSignIn, modelapp.PanguInferenceUI)
})



+ 1
- 0
templates/repo/modelarts/trainjob/show.tmpl View File

@@ -23,6 +23,7 @@
}
</style>
{{template "custom/global_mask" .}}
<div class="alert"></div>
<div class="repository">
{{template "repo/header" .}}
<div class="ui container">


+ 9
- 0
web_src/js/features/cloudbrainShow.js View File

@@ -522,6 +522,15 @@ export default async function initCloudrainSow() {
}
refreshStatusShow(version_name, ID, repoPath);
} else {
setTimeout(() => {
$(".alert")
.html(data.Message)
.removeClass("alert-success")
.addClass("alert-danger")
.show()
.delay(1500)
.fadeOut();
}, 520);
return;
}
}).fail(function (err) {


+ 98
- 9
web_src/vuepages/pages/modelbase/home/index.vue View File

@@ -3,15 +3,13 @@
<TopHeader>
<div class="title">
<div class="title-1">大模型基地</div>
<!-- <div class="title-2">
<a target="_blank" href="">
<span>中国NLP大模型总部基地启动仪式</span>
<i class="el-icon-video-play"></i>
</a>
</div> -->
<div class="tab-c">
<div class="tab" :class="tabIndex == '1' ? 'focused' : ''" @click="changeTab(1)">大模型</div>
<div class="tab" :class="tabIndex == '2' ? 'focused' : ''" @click="changeTab(2)">相关工具系统</div>
</div>
</div>
</TopHeader>
<div>
<div v-if="tabIndex == '1'">
<div class="model-category-c" :class="index % 2 == 0 ? 'model-category-c-bg' : ''" v-for="(item, index) in list"
:key="index">
<div class="model-category ui container">
@@ -65,6 +63,23 @@
</div>
</div>
</div>
<div v-if="tabIndex == '2'">
<div class="tool-c">
<div class="tool-list ui container">
<div class="model-tool-list">
<a class="model-tool" :class="`tool-bg-${index + 1}`" :href="item.href" target="_blank"
v-for="(item, index) in tools">
<div class="tool-title">{{ item.name }}</div>
</a>
</div>
</div>
</div>
<div class="model-category-c">
<div class="ui container model-category-more">
<div class="more-model">更多大模型工具系统接入中...</div>
</div>
</div>
</div>
</div>
</template>

@@ -74,6 +89,7 @@ import TopHeader from '../components/TopHeader.vue';
export default {
data() {
return {
tabIndex: '1',
list: [{
name: '鹏程·盘古大模型',
logo: 'https://openi.pcl.ac.cn/repo-avatars/34812-90a3a6045581fa11522237766a4db6b3',
@@ -262,11 +278,22 @@ export default {
detail: true,
detailUrl: 'https://openi.pcl.ac.cn/FoundationModel/Wenzhong/modelmanage/show_model',
}]
}]
}],
tools: [{
name: '启智飞轮标注系统',
href: 'https://pangu-alpha.pcl.ac.cn/dialog',
}, {
name: '盘古适配GCU',
href: 'https://openi.pcl.ac.cn/Enflame/GCU_Pytorch_pangu',
}],
};
},
components: { TopHeader, },
methods: {},
methods: {
changeTab(tab) {
this.tabIndex = tab;
}
},
beforeMount() { },
mounted() { },
beforeDestroy() { },
@@ -297,6 +324,30 @@ export default {
color: rgba(16, 16, 16, 1);
}
}

.tab-c {
display: flex;
align-items: center;
justify-content: center;
margin-top: 16px;

.tab {
margin: 0 10px;
color: rgb(5, 127, 255);
border: 1px solid rgb(5, 127, 255);
height: 40px;
min-width: 132px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;

&.focused {
color: rgb(255, 255, 255);
background: rgb(5, 127, 255);
}
}
}
}

.model-category-c {
@@ -445,4 +496,42 @@ export default {
justify-content: center;
}
}

.tool-c {
display: flex;
align-items: center;
background: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20version%3D%221.1%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%221%22%20x1%3D%220%22%20x2%3D%221%22%20y1%3D%220%22%20y2%3D%220%22%20gradientTransform%3D%22matrix(0.11899999999999993%2C%201.217%2C%20-0.0901857098765432%2C%200.11899999999999993%2C%200.269%2C%20-0.22)%22%3E%3Cstop%20stop-color%3D%22%23ffffff%22%20stop-opacity%3D%220.47%22%20offset%3D%220%22%3E%3C%2Fstop%3E%3Cstop%20stop-color%3D%22%23e5e7eb%22%20stop-opacity%3D%220.3%22%20offset%3D%221%22%3E%3C%2Fstop%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22url(%231)%22%3E%3C%2Frect%3E%3C%2Fsvg%3E");
padding: 65px 0;

.tool-list {

.model-tool-list {
display: flex;
align-items: center;
justify-content: center;

.model-tool {
width: 310px;
height: 130px;
display: flex;
align-items: center;
justify-content: center;
margin: 10px 20px;

.tool-title {
font-size: 20px;
color: rgb(255, 255, 255);
}
}
}
}
}

.tool-bg-1 {
background: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20version%3D%221.1%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%221%22%20x1%3D%220%22%20x2%3D%221%22%20y1%3D%220%22%20y2%3D%220%22%20gradientTransform%3D%22null%22%3E%3Cstop%20stop-color%3D%22%236bcbb5%22%20stop-opacity%3D%221%22%20offset%3D%220%22%3E%3C%2Fstop%3E%3Cstop%20stop-color%3D%22%238799e4%22%20stop-opacity%3D%221%22%20offset%3D%221%22%3E%3C%2Fstop%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22url(%231)%22%3E%3C%2Frect%3E%3C%2Fsvg%3E");
}

.tool-bg-2 {
background: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20version%3D%221.1%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%221%22%20x1%3D%220%22%20x2%3D%221%22%20y1%3D%220%22%20y2%3D%220%22%20gradientTransform%3D%22matrix(0.9919999999999999%2C%200.803%2C%20-0.14121436004162333%2C%200.9919999999999999%2C%200%2C%200)%22%3E%3Cstop%20stop-color%3D%22%23e2ad71%22%20stop-opacity%3D%221%22%20offset%3D%220%22%3E%3C%2Fstop%3E%3Cstop%20stop-color%3D%22%23f9b96f%22%20stop-opacity%3D%221%22%20offset%3D%220.5%22%3E%3C%2Fstop%3E%3Cstop%20stop-color%3D%22%23f57d34%22%20stop-opacity%3D%221%22%20offset%3D%220.99%22%3E%3C%2Fstop%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22url(%231)%22%3E%3C%2Frect%3E%3C%2Fsvg%3E");
}
</style>

+ 36
- 3
web_src/vuepages/pages/modelbase/inference/index.vue View File

@@ -26,13 +26,15 @@
</div>
</div>
<div class="footer-tips-c">
<div class="tips">* 部署的模型可以体验30分钟,超时后将关闭。</div>
<div class="tips">* 部署的模型可以体验30分钟<span v-if="endTimeStr">,预计 <span style="color:red">{{ endTimeStr }}</span>
后将关闭</span>。</div>
<div class="tips">* 本项目处于前沿探索阶段,体验功能仅供学术测试使用。请勿输入违反法律内容,同时,未经许可,禁止分享,传播输入及生成文本内容。感谢理解!</div>
</div>
</div>
</template>

<script>
import dayjs from 'dayjs';
import { getFinetuneServiceStatus, getFinetuneServiceInference } from '~/apis/modules/modelbase';
import { getUrlSearchParams } from '~/utils';

@@ -90,6 +92,7 @@ export default {
jobCategory: '',
inputTxt: '',
outputTxt: '',
endTimeStr: '',

generating: false,
printTimer: null,
@@ -141,6 +144,10 @@ export default {
}).catch(err => {
this.generating = false;
console.log(err);
this.$message({
type: 'error',
message: err.message,
});
});
},
printText(text) {
@@ -166,8 +173,34 @@ export default {
this.jobId = urlParams.jobid;
this.type = urlParams.type;
this.jobCategory = urlParams.jobcategory;
console.log(this.jobId, this.type, this.jobCategory);
this.generateSample();
// console.log(this.jobId, this.type, this.jobCategory);
getFinetuneServiceStatus({
userName: this.userName,
jobId: this.jobId,
}).then(res => {
const data = res.data;
console.log(data);
if (data.code == 1) {
this.$message({
type: 'error',
message: data.message,
});
setTimeout(() => {
window.location.href = `/extension/modelbase/pangufinetune`;
}, 3000);
return;
}
if (data.fineTuneDeployStatus == 'SUCCEEDED') {
if (data.fineTuneDeployFinishTime && data.fineTuneDeployFinishTime != 0) {
this.endTimeStr = dayjs(data.fineTuneDeployFinishTime * 1000).format('YYYY-MM-DD HH:mm');
}
this.generateSample();
} else {
window.location.href = `/extension/modelbase/pangufinetune`;
}
}).catch(err => {
console.log(err);
});
},
mounted() { },
beforeDestroy() { },


Loading…
Cancel
Save