diff --git a/ui/index.html b/ui/index.html index c6b14cc72..4e8168e01 100644 --- a/ui/index.html +++ b/ui/index.html @@ -1,9 +1,9 @@ - + - - - + + + %VITE_APP_TITLE% diff --git a/ui/public/embeb.js b/ui/public/embeb.js new file mode 100644 index 000000000..f8c3ea147 --- /dev/null +++ b/ui/public/embeb.js @@ -0,0 +1,66 @@ +// async function embedChatbot() { +// const t = window.difyChatbotConfig +// if (t && t.token) { +// var e = !!t.isDev +// const o = t.baseUrl || `https://${e ? 'dev.' : ''}udify.app`, +// n = ` +// +// `, +// i = ` +// +// ` +// if (!document.getElementById('dify-chatbot-bubble-button')) { +// e = document.createElement('div') +// ;(e.id = 'dify-chatbot-bubble-button'), +// (e.style.cssText = +// 'position: fixed; bottom: 1rem; right: 1rem; width: 50px; height: 50px; border-radius: 25px; background-color: #155EEF; box-shadow: rgba(0, 0, 0, 0.2) 0px 4px 8px 0px; cursor: pointer; z-index: 2147483647; transition: all 0.2s ease-in-out 0s; left: unset; transform: scale(1); :hover {transform: scale(1.1);}') +// const d = document.createElement('div') +// ;(d.style.cssText = +// 'display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; z-index: 2147483647;'), +// (d.innerHTML = n), +// e.appendChild(d), +// document.body.appendChild(e), +// e.addEventListener('click', function () { +// var e = document.getElementById('dify-chatbot-bubble-window') +// e +// ? 'none' === e.style.display +// ? ((e.style.display = 'block'), (d.innerHTML = i)) +// : ((e.style.display = 'none'), (d.innerHTML = n)) +// : (((e = document.createElement('iframe')).allow = 'fullscreen;microphone'), +// (e.title = 'dify chatbot bubble window'), +// (e.id = 'dify-chatbot-bubble-window'), +// (e.src = o + '/chatbot/' + t.token), +// (e.style.cssText = +// 'border: none; position: fixed; flex-direction: column; justify-content: space-between; box-shadow: rgba(150, 150, 150, 0.2) 0px 10px 30px 0px, rgba(150, 150, 150, 0.2) 0px 0px 0px 1px; bottom: 5rem; right: 1rem; width: 24rem; max-width: calc(100vw - 2rem); height: 40rem; max-height: calc(100vh - 6rem);border-radius: 0.75rem; display: flex; z-index: 2147483647; overflow: hidden; left: unset; background-color: #F3F4F6;'), +// document.body.appendChild(e), +// (d.innerHTML = i)) +// }) +// } +// } else console.error('difyChatbotConfig is empty or token is not provided') +// } +// document.body.onload = embedChatbot diff --git a/ui/src/api/application.ts b/ui/src/api/application.ts index 7e3a3ffaa..fe1cd7e25 100644 --- a/ui/src/api/application.ts +++ b/ui/src/api/application.ts @@ -72,14 +72,100 @@ const postChatMessage: (chat_id: string, message: string) => Promise = (cha ] } */ -const postApplication: ( data: ApplicationFormType, loading?: Ref ) => Promise> = (data, loading) => { +const postApplication: ( + data: ApplicationFormType, + loading?: Ref +) => Promise> = (data, loading) => { return post(`${prefix}`, data, undefined, loading) } +/** + * 修改应用 + * @param 参数 + * { + "name": "string", + "desc": "string", + "model_id": "string", + "multiple_rounds_dialogue": true, + "prologue": "string", + "example": [ + "string" + ], + "dataset_id_list": [ + "string" + ] +} + */ +const putApplication: ( + applicaiton_id: String, + data: ApplicationFormType, + loading?: Ref +) => Promise> = (applicaiton_id, data, loading) => { + return put(`${prefix}/${applicaiton_id}`, data, undefined, loading) +} + +/** + * 删除应用 + * @param 参数 applicaiton_id + */ +const delApplication: (applicaiton_id: String) => Promise> = (applicaiton_id) => { + return del(`${prefix}/${applicaiton_id}`) +} + +/** + * 应用详情 + * @param 参数 applicaiton_id + */ +const getApplicationDetail: ( + applicaiton_id: string, + loading?: Ref +) => Promise> = (applicaiton_id, loading) => { + return get(`${prefix}/${applicaiton_id}`, undefined, loading) +} + +/** + * 获得当前应用可使用的数据集 + * @param 参数 applicaiton_id + */ +const getApplicationDataset: ( + applicaiton_id: string, + loading?: Ref +) => Promise> = (applicaiton_id, loading) => { + return get(`${prefix}/${applicaiton_id}/list_dataset`, undefined, loading) +} + +/** + * API_KEY列表 + * @param 参数 applicaiton_id + */ +const getAPIKey: (applicaiton_id: string, loading?: Ref) => Promise> = ( + applicaiton_id, + loading +) => { + return get(`${prefix}/${applicaiton_id}/api_key`, undefined, loading) +} + +/** + * 获取AccessToken + * @param 参数 applicaiton_id + */ +const getAccessToken: (applicaiton_id: string, loading?: Ref) => Promise> = ( + applicaiton_id, + loading +) => { + return get(`${prefix}/${applicaiton_id}/access-token`, undefined, loading) +} + export default { getAllAppilcation, getApplication, postApplication, + putApplication, postChatOpen, - postChatMessage + postChatMessage, + delApplication, + getApplicationDetail, + getApplicationDataset, + getAPIKey, + getAccessToken } diff --git a/ui/src/assets/window1.png b/ui/src/assets/window1.png new file mode 100644 index 000000000..a96b907f6 Binary files /dev/null and b/ui/src/assets/window1.png differ diff --git a/ui/src/assets/window2.png b/ui/src/assets/window2.png new file mode 100644 index 000000000..02d1ec979 Binary files /dev/null and b/ui/src/assets/window2.png differ diff --git a/ui/src/components/ai-dialog/index.vue b/ui/src/components/ai-dialog/index.vue index b231bfe5e..471331977 100644 --- a/ui/src/components/ai-dialog/index.vue +++ b/ui/src/components/ai-dialog/index.vue @@ -55,12 +55,13 @@
-
- {{ '回答中...' }} +
+ 回答中...
+ 停止回答
@@ -77,22 +78,9 @@ :disabled="loading" />
- - - + + +
@@ -100,11 +88,10 @@ + diff --git a/ui/src/views/application/index.vue b/ui/src/views/application/index.vue index 17e2e0504..32d14f957 100644 --- a/ui/src/views/application/index.vue +++ b/ui/src/views/application/index.vue @@ -71,7 +71,7 @@ 运行中 - 删除 + 删除 @@ -88,9 +88,8 @@ import { ref, onMounted, reactive } from 'vue' import applicationApi from '@/api/application' import type { pageRequest } from '@/api/type/common' -// import { MsgSuccess, MsgConfirm } from '@/utils/message' + import { MsgSuccess, MsgConfirm } from '@/utils/message' import { useRouter } from 'vue-router' -// import { numberFormat } from '@/utils/utils' const router = useRouter() const loading = ref(false) @@ -102,7 +101,6 @@ const pageConfig = reactive({ }) const applicationList = ref([]) -const state = ref(false) function loadDataset() {} @@ -111,29 +109,29 @@ function search() { getList() } -// function deleteDateset(row: any) { -// MsgConfirm( -// `是否删除数据集:${row.name} ?`, -// `此数据集关联 ${row.char_length} 个应用,删除后无法恢复,请谨慎操作。`, -// { -// confirmButtonText: '删除', -// confirmButtonClass: 'danger' -// } -// ) -// .then(() => { -// loading.value = true -// datasetApi -// .delDateset(row.id) -// .then(() => { -// MsgSuccess('删除成功') -// getList() -// }) -// .catch(() => { -// loading.value = false -// }) -// }) -// .catch(() => {}) -// } + function deleteApplication(row: any) { + MsgConfirm( + `是否删除应用:${row.name} ?`, + `删除后该应用将不再提供服务,请谨慎操作。`, + { + confirmButtonText: '删除', + confirmButtonClass: 'danger' + } + ) + .then(() => { + loading.value = true + applicationApi + .delApplication(row.id) + .then(() => { + MsgSuccess('删除成功') + getList() + }) + .catch(() => { + loading.value = false + }) + }) + .catch(() => {}) + } // function changeState(bool: Boolean, row: any) { // const obj = { diff --git a/ui/src/views/chat/index.vue b/ui/src/views/chat/index.vue new file mode 100644 index 000000000..c5c4bd504 --- /dev/null +++ b/ui/src/views/chat/index.vue @@ -0,0 +1,36 @@ + + +