Skip to content

Commit fd7fd36

Browse files
feat: model
1 parent ecc2579 commit fd7fd36

File tree

9 files changed

+230
-118
lines changed

9 files changed

+230
-118
lines changed

ui/src/api/model/model.ts

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1-
21
import { Result } from '@/request/Result'
32
import { get, post, del, put } from '@/request/index'
43
import { type Ref } from 'vue'
54
import type {
65
ListModelRequest,
76
Model,
8-
BaseModel,
97
CreateModelRequest,
108
EditModelRequest,
119
} from '@/api/type/model'
1210
import type { FormField } from '@/components/dynamics-form/type'
13-
import type { KeyValue } from '../type/common'
14-
const prefix = '/model'
15-
const prefix_provider = '/provider'
11+
12+
const prefix = '/workspace'
1613

1714
/**
1815
* 获得模型列表
1916
* @params 参数 name, model_type, model_name
2017
*/
2118
const getModel: (
19+
wordspace_id: string,
2220
request?: ListModelRequest,
2321
loading?: Ref<boolean>,
24-
) => Promise<Result<Array<Model>>> = (data, loading) => {
25-
return get(`${prefix}`, data, loading)
22+
) => Promise<Result<Array<Model>>> = (wordspace_id, data, loading) => {
23+
return get(`${prefix}/${wordspace_id}/model`, data, loading)
2624
}
2725

2826
/**
@@ -37,42 +35,6 @@ const getModelParamsForm: (
3735
) => Promise<Result<Array<FormField>>> = (model_id, loading) => {
3836
return get(`model/${model_id}/model_params_form`, {}, loading)
3937
}
40-
/**
41-
* 获取模型类型列表
42-
* @param provider 供应商
43-
* @param loading 加载器
44-
* @returns 模型类型列表
45-
*/
46-
const listModelType: (
47-
provider: string,
48-
loading?: Ref<boolean>,
49-
) => Promise<Result<Array<KeyValue<string, string>>>> = (provider, loading?: Ref<boolean>) => {
50-
return get(`${prefix_provider}/model_type_list`, { provider }, loading)
51-
}
52-
53-
/**
54-
* 获取基础模型列表
55-
* @param provider
56-
* @param model_type
57-
* @param loading
58-
* @returns
59-
*/
60-
const listBaseModel: (
61-
provider: string,
62-
model_type: string,
63-
loading?: Ref<boolean>,
64-
) => Promise<Result<Array<BaseModel>>> = (provider, model_type, loading) => {
65-
return get(`${prefix_provider}/model_list`, { provider, model_type }, loading)
66-
}
67-
68-
const listBaseModelParamsForm: (
69-
provider: string,
70-
model_type: string,
71-
model_name: string,
72-
loading?: Ref<boolean>,
73-
) => Promise<Result<Array<BaseModel>>> = (provider, model_type, model_name, loading) => {
74-
return get(`${prefix_provider}/model_params_form`, { provider, model_type, model_name }, loading)
75-
}
7638

7739
/**
7840
* 创建模型
@@ -159,9 +121,6 @@ const deleteModel: (model_id: string, loading?: Ref<boolean>) => Promise<Result<
159121
}
160122
export default {
161123
getModel,
162-
listModelType,
163-
listBaseModel,
164-
listBaseModelParamsForm,
165124
createModel,
166125
updateModel,
167126
deleteModel,

ui/src/api/model/provider.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Result } from '@/request/Result'
22
import { get, post } from '@/request/index'
33
import type { Ref } from 'vue'
4-
import type { Provider } from '@/api/type/model'
4+
import type { Provider, BaseModel } from '@/api/type/model'
55
import type { FormField } from '@/components/dynamics-form/type'
6+
import type { KeyValue } from '../type/common'
67
const prefix_provider = '/provider'
78
/**
89
* 获得供应商列表
@@ -37,8 +38,48 @@ const getModelCreateForm: (
3738
) => Promise<Result<Array<FormField>>> = (provider, model_type, model_name, loading) => {
3839
return get(`${prefix_provider}/model_form`, { provider, model_type, model_name }, loading)
3940
}
41+
42+
/**
43+
* 获取模型类型列表
44+
* @param provider 供应商
45+
* @param loading 加载器
46+
* @returns 模型类型列表
47+
*/
48+
const listModelType: (
49+
provider: string,
50+
loading?: Ref<boolean>,
51+
) => Promise<Result<Array<KeyValue<string, string>>>> = (provider, loading?: Ref<boolean>) => {
52+
return get(`${prefix_provider}/model_type_list`, { provider }, loading)
53+
}
54+
55+
/**
56+
* 获取基础模型列表
57+
* @param provider
58+
* @param model_type
59+
* @param loading
60+
* @returns
61+
*/
62+
const listBaseModel: (
63+
provider: string,
64+
model_type: string,
65+
loading?: Ref<boolean>,
66+
) => Promise<Result<Array<BaseModel>>> = (provider, model_type, loading) => {
67+
return get(`${prefix_provider}/model_list`, { provider, model_type }, loading)
68+
}
69+
70+
const listBaseModelParamsForm: (
71+
provider: string,
72+
model_type: string,
73+
model_name: string,
74+
loading?: Ref<boolean>,
75+
) => Promise<Result<Array<BaseModel>>> = (provider, model_type, model_name, loading) => {
76+
return get(`${prefix_provider}/model_params_form`, { provider, model_type, model_name }, loading)
77+
}
4078
export default {
4179
getProvider,
4280
getModelCreateForm,
4381
getProviderByModelType,
82+
listModelType,
83+
listBaseModel,
84+
listBaseModelParamsForm,
4485
}

ui/src/assets/icon_document.svg

Lines changed: 12 additions & 0 deletions
Loading
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<template>
2+
<el-card shadow="hover" class="card-box" @mouseenter="cardEnter()" @mouseleave="cardLeave()">
3+
<div class="card-header">
4+
<slot name="header">
5+
<div class="title flex align-center" :class="$slots.subTitle ? 'mt-4' : ''">
6+
<slot name="icon">
7+
<el-avatar v-if="showIcon" class="mr-12 avatar-blue" shape="square" :size="32">
8+
<img src="@/assets/icon_document.svg" style="width: 58%" alt="" />
9+
</el-avatar>
10+
</slot>
11+
<div style="width: 90%">
12+
<slot name="title">
13+
<auto-tooltip :content="title" style="width: 65%; height: 22px">
14+
{{ title }}
15+
</auto-tooltip>
16+
</slot>
17+
<slot name="subTitle"> </slot>
18+
</div>
19+
</div>
20+
</slot>
21+
</div>
22+
<div class="description break-all mt-12">
23+
<slot>
24+
<div class="content">
25+
{{ description }}
26+
</div>
27+
</slot>
28+
</div>
29+
<div @mouseenter="subHoveredEnter">
30+
<slot name="mouseEnter" v-if="$slots.mouseEnter && show" />
31+
</div>
32+
<div class="card-footer" v-if="$slots.footer">
33+
<slot name="footer" />
34+
</div>
35+
</el-card>
36+
</template>
37+
<script setup lang="ts">
38+
import { ref, useSlots } from 'vue'
39+
import { t } from '@/locales'
40+
defineOptions({ name: 'CardBox' })
41+
const props = withDefaults(
42+
defineProps<{
43+
/**
44+
* 标题
45+
*/
46+
title?: string
47+
/**
48+
* 描述
49+
*/
50+
description?: string
51+
/**
52+
* 是否展示icon
53+
*/
54+
showIcon?: boolean
55+
}>(),
56+
{ title: t('common.title'), description: '', showIcon: true, border: true },
57+
)
58+
59+
const show = ref(false)
60+
// card上面存在dropdown菜单
61+
const subHovered = ref(false)
62+
function cardEnter() {
63+
show.value = true
64+
subHovered.value = false
65+
}
66+
67+
function cardLeave() {
68+
show.value = subHovered.value
69+
}
70+
71+
function subHoveredEnter() {
72+
subHovered.value = true
73+
}
74+
</script>
75+
<style lang="scss" scoped>
76+
.card-box {
77+
font-size: 14px;
78+
position: relative;
79+
min-height: var(--card-min-height);
80+
min-width: var(--card-min-width);
81+
border-radius: 8px;
82+
.card-header {
83+
margin-top: -10px;
84+
}
85+
.description {
86+
color: var(--app-text-color-secondary);
87+
line-height: 22px;
88+
font-weight: 400;
89+
.content {
90+
display: -webkit-box;
91+
height: var(--app-card-box-description-height, 40px);
92+
-webkit-box-orient: vertical;
93+
-webkit-line-clamp: 2;
94+
overflow: hidden;
95+
}
96+
}
97+
98+
.card-footer {
99+
position: absolute;
100+
bottom: 8px;
101+
left: 0;
102+
min-height: 30px;
103+
color: var(--app-text-color-secondary);
104+
font-weight: 400;
105+
padding: 0 16px;
106+
width: 100%;
107+
box-sizing: border-box;
108+
}
109+
}
110+
</style>

ui/src/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import dynamicsForm from './dynamics-form'
66
import AppIcon from './app-icon/AppIcon.vue'
77
import LayoutContainer from './layout-container/index.vue'
88
import ContentContainer from './layout-container/ContentContainer.vue'
9+
import CardBox from './card-box/index.vue'
910
export default {
1011
install(app: App) {
1112
app.component('LogoFull', LogoFull)
@@ -15,5 +16,6 @@ export default {
1516
app.component('AppIcon', AppIcon)
1617
app.component('LayoutContainer', LayoutContainer)
1718
app.component('ContentContainer', ContentContainer)
19+
app.component('CardBox', CardBox)
1820
},
1921
}

ui/src/components/layout-container/ContentContainer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const showBack = computed(() => {
4242
.content-container__main {
4343
// background-color: var(--app-view-bg-color);
4444
box-sizing: border-box;
45-
min-width: 847px;
45+
min-width: 447px;
4646
}
4747
}
4848
</style>

ui/src/components/layout-container/index.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="layout-container flex h-full">
3-
<div class="layout-container__left">
3+
<div class="layout-container__left border-r">
44
<slot name="left"></slot>
55
</div>
66
<div class="layout-container__right">
@@ -30,7 +30,6 @@ const showBack = computed(() => {
3030
transition: width 0.28s;
3131
width: var(--sidebar-width);
3232
min-width: var(--sidebar-width);
33-
background-color: var(--sidebar-bg-color);
3433
}
3534
&__right {
3635
width: calc(100% - var(--sidebar-width));

0 commit comments

Comments
 (0)