Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
lmp_web
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
yujian
lmp_web
Commits
d36fb269
Commit
d36fb269
authored
Dec 23, 2023
by
mhw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
预览调整
parent
87e04e1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
17 deletions
+37
-17
index.vue
.../modelService/testOnline/components/contentView/index.vue
+10
-9
index.vue
...ing/modelService/testOnline/components/rightBox/index.vue
+27
-8
No files found.
src/views/gptTraining/modelService/testOnline/components/contentView/index.vue
View file @
d36fb269
<!-- 答案内容预览 -->
<
template
>
<vue-markdown
:source=
"content"
v-highlight
class=
"markdown-body"
:id=
"'myContainer'+index"
>
<vue-markdown
:source=
"content"
v-highlight
class=
"markdown-body"
>
</vue-markdown>
</
template
>
...
...
@@ -15,9 +15,10 @@ export default {
data
()
{
return
{
result
:
undefined
};
},
props
:
[
'content'
,
'index'
,
'isSuccess'
],
props
:
[
'content'
],
components
:
{
VueMarkdown
},
computed
:
{},
...
...
@@ -40,15 +41,15 @@ export default {
},
watch
:
{
'isSuccess'
()
{
if
(
this
.
isSuccess
)
{
const
anchorTags
=
document
.
querySelectorAll
(
`#myContainer
${
this
.
index
}
a`
);
this
.
preview
(
anchorTags
)
}
}
},
methods
:
{
isSuccess
()
{
this
.
$nextTick
(()
=>
{
const
anchorTags
=
Object
.
values
(
this
.
$el
.
getElementsByTagName
(
'a'
));
this
.
preview
(
anchorTags
)
})
},
preview
(
anchorTags
)
{
let
that
=
this
// 遍历并输出链接的 href 属性
...
...
@@ -65,7 +66,6 @@ export default {
if
(
isFile
)
{
// 判断可预览文件类型
// 阻止默认点击事件
event
.
preventDefault
();
if
(
tagUrl
.
indexOf
(
'https'
)
!==
-
1
)
{
url
=
tagUrl
.
replace
(
/^https:
\/\/[^/]
+
\/
/
,
`https://
${
window
.
location
.
hostname
}
:
${
window
.
location
.
port
}
/`
);
}
else
{
...
...
@@ -102,6 +102,7 @@ export default {
}
})
}
}
}
...
...
src/views/gptTraining/modelService/testOnline/components/rightBox/index.vue
View file @
d36fb269
...
...
@@ -3,7 +3,7 @@
<div
class=
"box"
>
<div
class=
"contentBox"
ref=
"contentBox"
v-if=
"myHistory.length > 0"
>
<div
v-for=
"
(item, index) in myHistory"
:key=
"index
"
>
<div
v-for=
"
item in myHistory"
:key=
"item.id
"
>
<div
class=
"userBox"
>
<div
class=
"content"
>
...
...
@@ -18,7 +18,7 @@
GPT
</div>
<div
class=
"content"
>
<contentView
:content=
"item.answer"
ref=
"contentView"
:index=
"index"
:isSuccess=
"isSuccess"
/>
<contentView
:content=
"item.answer"
:ref=
"'contentView'+item.id"
/>
</div>
</div>
...
...
@@ -49,7 +49,6 @@ import contentView from '../contentView';
export
default
{
data
()
{
return
{
isSuccess
:
false
,
templateController
:
undefined
,
isPromptTemplate
:
true
,
inputContent
:
null
,
...
...
@@ -81,6 +80,7 @@ export default {
// 移除监听事件 "share"
this
.
$bus
.
$off
(
'isPromptTemplate'
)
},
methods
:
{
clear
()
{
...
...
@@ -90,7 +90,6 @@ export default {
this
.
myHistory
=
[]
},
submit
()
{
this
.
isSuccess
=
false
this
.
param
.
model_name
=
this
.
chatForm
.
model_name
this
.
param
.
temperature
=
this
.
chatForm
.
temperature
this
.
heistoryRotate
=
this
.
chatForm
.
heistoryRotate
...
...
@@ -118,9 +117,11 @@ export default {
'role'
:
'user'
,
'content'
:
this
.
inputContent
,
'answer'
:
''
,
'excludeReferenceAnswer'
:
''
'excludeReferenceAnswer'
:
''
,
'id'
:
this
.
generateRandomString
(
8
)
})
this
.
inputContent
=
null
;
this
.
myHistory
.
slice
(
0
,
-
1
).
slice
(
-
this
.
heistoryRotate
).
forEach
((
item
)
=>
{
...
...
@@ -128,14 +129,18 @@ export default {
})
this
.
$emit
(
'submit'
)
let
getData
=
new
GetStreaming
(
apiUrl
,
this
.
param
,
this
.
onmessage
,
this
.
success
)
let
getData
=
new
GetStreaming
(
apiUrl
,
this
.
param
,
this
.
onmessage
,
this
.
s
etS
uccess
)
getData
.
initeventSource
()
},
success
()
{
this
.
isSuccess
=
true
setSuccess
()
{
this
.
$nextTick
(()
=>
{
let
nowChat
=
this
.
myHistory
[
this
.
myHistory
.
length
-
1
]
this
.
$refs
[
'contentView'
+
nowChat
.
id
][
0
].
isSuccess
()
})
},
onmessage
(
data
)
{
console
.
log
(
data
);
let
nowChat
=
this
.
myHistory
[
this
.
myHistory
.
length
-
1
]
if
(
this
.
chatForm
.
pattern
===
'通用智能问答'
)
{
nowChat
.
answer
+=
data
...
...
@@ -169,6 +174,20 @@ export default {
this
.
$nextTick
(()
=>
{
this
.
$refs
.
contentBox
.
scrollTo
(
0
,
this
.
$refs
.
contentBox
.
scrollHeight
)
})
},
generateRandomString
(
length
)
{
const
characters
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
;
const
charactersLength
=
characters
.
length
;
const
randomValues
=
new
Uint32Array
(
length
);
crypto
.
getRandomValues
(
randomValues
);
let
result
=
''
;
for
(
let
i
=
0
;
i
<
length
;
i
++
)
{
result
+=
characters
.
charAt
(
randomValues
[
i
]
%
charactersLength
);
}
return
result
;
}
}
...
...
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