Skip to content

Commit 0772cf1

Browse files
shaohuzhang1wangdan-fit2cloudzhanweizhang7liuruibinliqiang-fit2cloud
authored
perf: chat share (#4806)
* perf: chat share * fix: Range error * fix: update imports for BaseMessage and message types from langchain_core * fix: update django dependency to version 5.2.11 * fix: enhance tool result handling for various content types * dep: upgrade PostgreSQL from 17.6 to 17.7. * refactor: set --timeout to 30s. * build(deps): bump pypdf in the pip group across 1 directory Bumps the pip group with 1 update in the / directory: [pypdf](https://github.com/py-pdf/pypdf). Updates `pypdf` from 6.6.2 to 6.7.1 - [Release notes](https://github.com/py-pdf/pypdf/releases) - [Changelog](https://github.com/py-pdf/pypdf/blob/main/CHANGELOG.md) - [Commits](py-pdf/pypdf@6.6.2...6.7.1) --- updated-dependencies: - dependency-name: pypdf dependency-version: 6.7.1 dependency-type: direct:production dependency-group: pip ... Signed-off-by: dependabot[bot] <support@github.com> * fix(deps): update langchain and related dependencies to latest versions * refactor: move chat share endpoints to chat API routes and remove workspace_id from share-link flow * feat: share chat * feat: chat share --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: wangdan-fit2cloud <dan.wang@fit2cloud.com> Co-authored-by: zhangzhanwei <zhanwei.zhang@fit2cloud.com> Co-authored-by: CaptainB <bin@fit2cloud.com> Co-authored-by: liqiang-fit2cloud <liqiang@fit2cloud.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 78e198a commit 0772cf1

File tree

25 files changed

+754
-500
lines changed

25 files changed

+754
-500
lines changed

ui/src/api/chat/chat.ts

Lines changed: 81 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Result} from '@/request/Result'
1+
import { Result } from '@/request/Result'
22
import {
33
get,
44
post,
@@ -9,17 +9,17 @@ import {
99
download,
1010
exportFile,
1111
} from '@/request/chat/index'
12-
import {type ChatProfile} from '@/api/type/chat'
13-
import {type Ref} from 'vue'
14-
import type {ResetPasswordRequest} from '@/api/type/user.ts'
12+
import { type ChatProfile } from '@/api/type/chat'
13+
import { type Ref } from 'vue'
14+
import type { ResetPasswordRequest } from '@/api/type/user.ts'
1515

1616
import useStore from '@/stores'
17-
import type {LoginRequest} from '@/api/type/user'
17+
import type { LoginRequest } from '@/api/type/user'
1818

19-
const prefix: any = {_value: '/workspace/'}
19+
const prefix: any = { _value: '/workspace/' }
2020
Object.defineProperty(prefix, 'value', {
2121
get: function () {
22-
const {user} = useStore()
22+
const { user } = useStore()
2323
return this._value + user.getWorkspaceId() + '/application'
2424
},
2525
})
@@ -51,7 +51,7 @@ const chatProfile: (assessToken: string, loading?: Ref<boolean>) => Promise<Resu
5151
assessToken,
5252
loading,
5353
) => {
54-
return get('/profile', {access_token: assessToken}, loading)
54+
return get('/profile', { access_token: assessToken }, loading)
5555
}
5656
/**
5757
* 匿名认证
@@ -63,7 +63,7 @@ const anonymousAuthentication: (
6363
assessToken: string,
6464
loading?: Ref<boolean>,
6565
) => Promise<Result<any>> = (assessToken, loading) => {
66-
return post('/auth/anonymous', {access_token: assessToken}, {}, loading)
66+
return post('/auth/anonymous', { access_token: assessToken }, {}, loading)
6767
}
6868
/**
6969
* 密码认证
@@ -77,7 +77,7 @@ const passwordAuthentication: (
7777
password: string,
7878
loading?: Ref<boolean>,
7979
) => Promise<Result<any>> = (assessToken, password, loading) => {
80-
return post('auth/password', {access_token: assessToken, password: password}, {}, loading)
80+
return post('auth/password', { access_token: assessToken, password: password }, {}, loading)
8181
}
8282
/**
8383
* 获取应用相关信息
@@ -115,8 +115,12 @@ const ldapLogin: (
115115
* @param username
116116
* @param loading 接口加载器
117117
*/
118-
const getCaptcha: (username?: string, accessToken?: string, loading?: Ref<boolean>) => Promise<Result<any>> = (username, accessToken, loading) => {
119-
return get('/captcha', {username: username, accessToken: accessToken}, loading)
118+
const getCaptcha: (
119+
username?: string,
120+
accessToken?: string,
121+
loading?: Ref<boolean>,
122+
) => Promise<Result<any>> = (username, accessToken, loading) => {
123+
return get('/captcha', { username: username, accessToken: accessToken }, loading)
120124
}
121125

122126
/**
@@ -130,35 +134,35 @@ const getQrSource: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading)
130134
return get('auth/qr_type/source', undefined, loading)
131135
}
132136

133-
const getDingCallback: (code: string, accessToken: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
134-
code,
135-
accessToken,
136-
loading,
137-
) => {
138-
return get('auth/dingtalk', {code, accessToken: accessToken}, loading)
137+
const getDingCallback: (
138+
code: string,
139+
accessToken: string,
140+
loading?: Ref<boolean>,
141+
) => Promise<Result<any>> = (code, accessToken, loading) => {
142+
return get('auth/dingtalk', { code, accessToken: accessToken }, loading)
139143
}
140144

141-
const getDingOauth2Callback: (code: string, accessToken: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
142-
code,
143-
accessToken,
144-
loading,
145-
) => {
146-
return get('auth/dingtalk/oauth2', {code, accessToken: accessToken}, loading)
145+
const getDingOauth2Callback: (
146+
code: string,
147+
accessToken: string,
148+
loading?: Ref<boolean>,
149+
) => Promise<Result<any>> = (code, accessToken, loading) => {
150+
return get('auth/dingtalk/oauth2', { code, accessToken: accessToken }, loading)
147151
}
148152

149-
const getWecomCallback: (code: string, accessToken: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
150-
code,
151-
accessToken,
152-
loading,
153-
) => {
154-
return get('auth/wecom', {code, accessToken: accessToken}, loading)
153+
const getWecomCallback: (
154+
code: string,
155+
accessToken: string,
156+
loading?: Ref<boolean>,
157+
) => Promise<Result<any>> = (code, accessToken, loading) => {
158+
return get('auth/wecom', { code, accessToken: accessToken }, loading)
155159
}
156-
const getLarkCallback: (code: string, accessToken: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
157-
code,
158-
accessToken,
159-
loading,
160-
) => {
161-
return get('auth/lark/oauth2', {code, accessToken: accessToken}, loading)
160+
const getLarkCallback: (
161+
code: string,
162+
accessToken: string,
163+
loading?: Ref<boolean>,
164+
) => Promise<Result<any>> = (code, accessToken, loading) => {
165+
return get('auth/lark/oauth2', { code, accessToken: accessToken }, loading)
162166
}
163167

164168
/**
@@ -185,19 +189,20 @@ const vote: (
185189
vote_reason?: string,
186190
vote_other_content?: string,
187191
loading?: Ref<boolean>,
188-
) => Promise<Result<boolean>> = (chat_id, chat_record_id, vote_status, vote_reason, vote_other_content, loading) => {
189-
190-
const data = {
192+
) => Promise<Result<boolean>> = (
193+
chat_id,
194+
chat_record_id,
191195
vote_status,
192-
...(vote_reason !== undefined && { vote_reason }),
193-
...(vote_other_content !== undefined && { vote_other_content })
194-
}
195-
return put(
196-
`/vote/chat/${chat_id}/chat_record/${chat_record_id}`,
197-
data,
198-
undefined,
199-
loading,
200-
)
196+
vote_reason,
197+
vote_other_content,
198+
loading,
199+
) => {
200+
const data = {
201+
vote_status,
202+
...(vote_reason !== undefined && { vote_reason }),
203+
...(vote_other_content !== undefined && { vote_other_content }),
204+
}
205+
return put(`/vote/chat/${chat_id}/chat_record/${chat_record_id}`, data, undefined, loading)
201206
}
202207
const pageChat: (
203208
current_page: number,
@@ -292,9 +297,7 @@ const deleteChat: (chat_id: string, loading?: Ref<boolean>) => Promise<Result<an
292297
* @param loading
293298
* @returns
294299
*/
295-
const clearChat: (loading?: Ref<boolean>) => Promise<Result<any>> = (
296-
loading
297-
) => {
300+
const clearChat: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
298301
return del(`historical_conversation/clear`, undefined, undefined, loading)
299302
}
300303
/**
@@ -339,9 +342,32 @@ const postUploadFile: (
339342
return post(`/oss/file`, fd, undefined, loading)
340343
}
341344

342-
const getFile: (application_id: string, params: any) => Promise<Result<any>> = (application_id, params) => {
345+
const getFile: (application_id: string, params: any) => Promise<Result<any>> = (
346+
application_id,
347+
params,
348+
) => {
343349
return get(`/oss/get_url/${application_id}`, params)
344350
}
351+
352+
/**
353+
* 生成分享链接
354+
* @param 参数
355+
* chat_id: string
356+
* data
357+
*/
358+
const postShareChat: (
359+
application_id: string,
360+
chat_id: string,
361+
data: any,
362+
loading?: Ref<boolean>,
363+
) => Promise<any> = (application_id, chat_id, data, loading) => {
364+
return post(`/${application_id}/chat/${chat_id}/share_chat`, data, undefined, loading)
365+
}
366+
367+
const getShareLink: (link: string) => Promise<Result<any>> = (link) => {
368+
return get(`/share/${link}`, undefined)
369+
}
370+
345371
export default {
346372
open,
347373
chat,
@@ -372,5 +398,7 @@ export default {
372398
clearChat,
373399
modifyChat,
374400
postUploadFile,
375-
getFile
401+
getFile,
402+
postShareChat,
403+
getShareLink,
376404
}

ui/src/components/ai-chat/component/answer-content/index.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="item-content mb-16 lighter">
2+
<div class="item-content lighter">
33
<template v-for="(answer_text, index) in answer_text_list" :key="index">
44
<div class="avatar mr-8" v-if="showAvatar">
55
<img v-if="application.avatar" :src="application.avatar" height="28px" width="28px" />
@@ -12,7 +12,7 @@
1212
'padding-right': showUserAvatar ? 'var(--padding-left)' : '0',
1313
}"
1414
>
15-
<el-card shadow="always" class="mb-8 border-r-8" style="--el-card-padding: 6px 16px">
15+
<el-card shadow="always" class="border-r-8" style="--el-card-padding: 6px 16px">
1616
<MdRenderer
1717
v-if="
1818
(chatRecord.write_ed === undefined || chatRecord.write_ed === true) &&
@@ -60,6 +60,7 @@
6060
'padding-left': showAvatar ? 'var(--padding-left)' : '0',
6161
'padding-right': showUserAvatar ? 'var(--padding-left)' : '0',
6262
}"
63+
v-if="!selection"
6364
>
6465
<OperationButton
6566
:type="type"
@@ -88,8 +89,9 @@ const props = defineProps<{
8889
loading: boolean
8990
sendMessage: (question: string, other_params_data?: any, chat?: chatType) => Promise<boolean>
9091
chatManagement: any
91-
type: 'log' | 'ai-chat' | 'debug-ai-chat'
92+
type: 'log' | 'ai-chat' | 'debug-ai-chat' | 'share'
9293
executionIsRightPanel?: boolean
94+
selection?: boolean
9395
}>()
9496
9597
const emit = defineEmits([

0 commit comments

Comments
 (0)