Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
f44fe6eb
Commit
f44fe6eb
authored
Jul 26, 2023
by
Joel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feat/universal-chat-fe' into deploy/dev
parents
ba9041ea
49783327
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
markdown.tsx
web/app/components/base/markdown.tsx
+9
-5
index.tsx
web/app/components/explore/universal-chat/index.tsx
+1
-1
universal-chat.ts
web/service/universal-chat.ts
+1
-1
No files found.
web/app/components/base/markdown.tsx
View file @
f44fe6eb
...
...
@@ -10,11 +10,15 @@ import type { RefObject } from 'react'
import
{
useEffect
,
useRef
,
useState
}
from
'react'
// import { copyToClipboard } from "../utils";
// https://txtfiddle.com/~hlshwya/extract-urls-from-text
const
urlRegex
=
/
\b((
https
?
|ftp|file
)
:
\/\/
|
(
www|ftp
)\.)[
-A-Z0-9+&@#
\/
%?=~_|$!:,.;
]
*
[
A-Z0-9+&@#
\/
%=~_|$
]
/ig
//
const urlRegex = /\b((https?|ftp|file):\/\/|(www|ftp)\.)[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/ig
function
highlightURL
(
content
:
string
)
{
return
content
.
replace
(
urlRegex
,
'[$&]($&)'
)
}
// function highlightURL(content: string) {
// return content.replace(urlRegex, (url) => {
// // fix http:// in [] will be parsed to link agin
// const res = `[${url.replace('://', '://')}](${url})`
// return res
// })
// }
export
function
PreCode
(
props
:
{
children
:
any
})
{
const
ref
=
useRef
<
HTMLPreElement
>
(
null
)
...
...
@@ -88,7 +92,7 @@ export function Markdown(props: { content: string }) {
linkTarget=
{
'_blank'
}
>
{
/* Markdown detect has problem. */
}
{
highlightURL
(
props
.
content
)
}
{
props
.
content
}
</
ReactMarkdown
>
</
div
>
)
...
...
web/app/components/explore/universal-chat/index.tsx
View file @
f44fe6eb
...
...
@@ -677,7 +677,7 @@ const Main: FC<IMainProps> = () => {
isResponsing=
{
isResponsing
}
canStopResponsing=
{
!!
messageTaskId
}
abortResponsing=
{
async
()
=>
{
await
stopChatMessageResponding
(
APP_ID
,
messageTaskId
)
await
stopChatMessageResponding
(
messageTaskId
)
setHasStopResponded
(
true
)
setResponsingFalse
()
}
}
...
...
web/service/universal-chat.ts
View file @
f44fe6eb
...
...
@@ -25,7 +25,7 @@ export const sendChatMessage = async (body: Record<string, any>, { onData, onCom
},
{
onData
,
onCompleted
,
onThought
,
onError
,
getAbortController
})
}
export
const
stopChatMessageResponding
=
async
(
appId
:
string
,
taskId
:
string
)
=>
{
export
const
stopChatMessageResponding
=
async
(
taskId
:
string
)
=>
{
return
post
(
getUrl
(
`messages/
${
taskId
}
/stop`
))
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment