Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
inscode
NodeJS_639770
提交
d96fc4fc
N
NodeJS_639770
项目概览
inscode
/
NodeJS_639770
与 Fork 源项目一致
Fork自
inscode / NodeJS
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
NodeJS_639770
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
d96fc4fc
编写于
5月 17, 2024
作者:
View Design
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'main' of gitcode.com:git_bot/ai-fe
上级
2624e9de
49d8e7d2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
38 deletion
+42
-38
pages/search/[id].vue
pages/search/[id].vue
+42
-38
未找到文件。
pages/search/[id].vue
浏览文件 @
d96fc4fc
...
@@ -177,14 +177,14 @@ const handleCopyMD = (index) => {
...
@@ -177,14 +177,14 @@ const handleCopyMD = (index) => {
})
})
}
}
const
handleReGenerate
=
(
index
)
=>
{
const
handleReGenerate
=
(
index
)
=>
{
editIndex
.
value
=
index
;
editIndex
.
value
=
index
const
question
=
data
.
value
[
editIndex
.
value
].
question
;
const
question
=
data
.
value
[
editIndex
.
value
].
question
data
.
value
[
editIndex
.
value
]
=
{
data
.
value
[
editIndex
.
value
]
=
{
question
,
question
,
desLoading
:
true
desLoading
:
true
}
;
}
nextTick
(()
=>
{
nextTick
(()
=>
{
generateFetchData
(
question
)
;
generateFetchData
(
question
)
})
})
}
}
...
@@ -211,18 +211,22 @@ defineShortcuts({
...
@@ -211,18 +211,22 @@ defineShortcuts({
}
}
})
})
let
asking
=
ref
(
false
)
let
asking
=
ref
(
false
)
const
handleClearInput
=
()
=>
{
continueQuestion
.
value
=
''
}
const
handleContinueAsk
=
(
question
)
=>
{
const
handleContinueAsk
=
(
question
)
=>
{
if
(
asking
.
value
)
return
if
(
asking
.
value
)
return
asking
.
value
=
true
asking
.
value
=
true
editIndex
.
value
=
data
.
value
.
length
;
editIndex
.
value
=
data
.
value
.
length
createGenerateInitItem
(
question
);
createGenerateInitItem
(
question
)
generateFetchData
(
question
);
generateFetchData
(
question
)
handleClearInput
()
}
}
// 处理ai generate
// 处理ai generate
let
aiChatController
=
null
;
// 用户取消操作方法
let
aiChatController
=
null
// 用户取消操作方法
const
markedEnd
=
'
[DONE]
'
;
const
markedEnd
=
'
[DONE]
'
let
storeSource
=
[]
;
let
storeSource
=
[]
const
createGenerateInitItem
=
(
question
)
=>
{
const
createGenerateInitItem
=
(
question
)
=>
{
data
.
value
.
push
({
question
,
desLoading
:
true
})
data
.
value
.
push
({
question
,
desLoading
:
true
})
}
}
...
@@ -230,17 +234,17 @@ const resetAnsLoading = () => {
...
@@ -230,17 +234,17 @@ const resetAnsLoading = () => {
Object
.
assign
(
data
.
value
[
editIndex
.
value
],
{
ansLoading
:
false
})
Object
.
assign
(
data
.
value
[
editIndex
.
value
],
{
ansLoading
:
false
})
}
}
const
handleFormFetchData
=
(
fetchData
)
=>
{
const
handleFormFetchData
=
(
fetchData
)
=>
{
let
message
=
{}
;
let
message
=
{}
try
{
try
{
message
=
JSON
.
parse
(
fetchData
)
;
message
=
JSON
.
parse
(
fetchData
)
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
}
}
if
(
Object
.
keys
(
message
).
length
===
0
)
return
;
if
(
Object
.
keys
(
message
).
length
===
0
)
return
const
{
meta
,
choices
}
=
message
;
const
{
meta
,
choices
}
=
message
const
index
=
editIndex
.
value
;
const
index
=
editIndex
.
value
nextTick
(()
=>
{
nextTick
(()
=>
{
scrollToView
()
;
scrollToView
()
})
})
if
(
meta
.
type
===
'
answer
'
)
{
if
(
meta
.
type
===
'
answer
'
)
{
Object
.
assign
(
data
.
value
[
index
],
{
Object
.
assign
(
data
.
value
[
index
],
{
...
@@ -258,16 +262,16 @@ const handleFormFetchData = (fetchData) => {
...
@@ -258,16 +262,16 @@ const handleFormFetchData = (fetchData) => {
}
}
if
(
meta
.
action
===
'
search_file
'
)
{
if
(
meta
.
action
===
'
search_file
'
)
{
Object
.
assign
(
data
.
value
[
index
],
{
desLoading
:
true
})
Object
.
assign
(
data
.
value
[
index
],
{
desLoading
:
true
})
let
source
=
choices
[
0
].
message
.
content
;
let
source
=
choices
[
0
].
message
.
content
storeSource
=
source
.
split
(
'
\n
'
)
;
storeSource
=
source
.
split
(
'
\n
'
)
}
}
}
}
const
handleUpdateSource
=
()
=>
{
const
handleUpdateSource
=
()
=>
{
const
index
=
editIndex
.
value
;
const
index
=
editIndex
.
value
data
.
value
[
index
]
=
data
.
value
[
index
]
||
{}
;
data
.
value
[
index
]
=
data
.
value
[
index
]
||
{}
// https://github.com/allwefantasy/byzer-llm/blob/master/tests/functions_suite.py
// https://github.com/allwefantasy/byzer-llm/blob/master/tests/functions_suite.py
const
endWidthGit
=
state
.
gitPath
.
endsWith
(
'
.git
'
)
;
const
endWidthGit
=
state
.
gitPath
.
endsWith
(
'
.git
'
)
const
baseUrl
=
endWidthGit
?
state
.
gitPath
.
slice
(
0
,
state
.
gitPath
.
length
-
4
)
:
state
.
gitPath
;
const
baseUrl
=
endWidthGit
?
state
.
gitPath
.
slice
(
0
,
state
.
gitPath
.
length
-
4
)
:
state
.
gitPath
storeSource
=
storeSource
.
map
((
item
)
=>
{
storeSource
=
storeSource
.
map
((
item
)
=>
{
return
{
return
{
repo
:
state
.
repo
,
repo
:
state
.
repo
,
...
@@ -275,37 +279,37 @@ const handleUpdateSource = () => {
...
@@ -275,37 +279,37 @@ const handleUpdateSource = () => {
label
:
item
label
:
item
}
}
})
})
Object
.
assign
(
data
.
value
[
index
],
{
source
:
storeSource
})
;
Object
.
assign
(
data
.
value
[
index
],
{
source
:
storeSource
})
}
}
const
handleHideInitLoading
=
()
=>
{
const
handleHideInitLoading
=
()
=>
{
initLoading
.
value
=
false
;
initLoading
.
value
=
false
}
}
const
handleMessage
=
(
event
)
=>
{
const
handleMessage
=
(
event
)
=>
{
if
(
initLoading
.
value
)
{
if
(
initLoading
.
value
)
{
handleHideInitLoading
()
handleHideInitLoading
()
createGenerateInitItem
(
state
.
query
)
createGenerateInitItem
(
state
.
query
)
}
;
}
if
(
event
.
data
===
markedEnd
)
{
if
(
event
.
data
===
markedEnd
)
{
asking
.
value
=
false
;
asking
.
value
=
false
resetAnsLoading
()
;
resetAnsLoading
()
handleUpdateSource
()
;
handleUpdateSource
()
return
;
return
}
}
handleFormFetchData
(
event
.
data
)
handleFormFetchData
(
event
.
data
)
}
}
const
handleStopGenerate
=
()
=>
{
const
handleStopGenerate
=
()
=>
{
asking
.
value
&&
aiChatController
&&
aiChatController
.
abort
()
;
asking
.
value
&&
aiChatController
&&
aiChatController
.
abort
()
asking
.
value
=
false
;
asking
.
value
=
false
}
}
const
handleError
=
(
event
)
=>
{
const
handleError
=
(
event
)
=>
{
handleStopGenerate
()
;
handleStopGenerate
()
}
}
const
generateFetchData
=
(
query
)
=>
{
const
generateFetchData
=
(
query
)
=>
{
const
{
gitPath
,
id
}
=
state
;
const
{
gitPath
,
id
}
=
state
const
messages
=
[]
;
const
messages
=
[]
messages
.
push
({
role
:
'
user
'
,
content
:
query
})
;
messages
.
push
({
role
:
'
user
'
,
content
:
query
})
aiChatController
=
new
AbortController
()
;
aiChatController
=
new
AbortController
()
asking
.
value
=
true
;
asking
.
value
=
true
fetchEventSource
(
'
/v1/chat/completions
'
,
{
fetchEventSource
(
'
/v1/chat/completions
'
,
{
params
:
{
params
:
{
repo_path
:
gitPath
,
repo_path
:
gitPath
,
...
@@ -320,6 +324,6 @@ const generateFetchData = (query) => {
...
@@ -320,6 +324,6 @@ const generateFetchData = (query) => {
})
})
}
}
onMounted
(()
=>
{
onMounted
(()
=>
{
generateFetchData
(
state
.
query
)
;
generateFetchData
(
state
.
query
)
})
})
</
script
>
</
script
>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录