Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
skyagents
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
skyagents
Commits
86ba453c
提交
86ba453c
authored
2月 12, 2025
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: update
上级
4024759e
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
15 行增加
和
10 行删除
+15
-10
App.vue
src/App.vue
+1
-1
useAI.js
src/composables/useAI.js
+4
-4
useQianfan.js
src/composables/useQianfan.js
+10
-5
没有找到文件。
src/App.vue
浏览文件 @
86ba453c
...
@@ -38,7 +38,7 @@ async function postMessage(content) {
...
@@ -38,7 +38,7 @@ async function postMessage(content) {
if
(
!
userChatInput
.
value
)
return
if
(
!
userChatInput
.
value
)
return
console
.
log
(
userChatInput
.
value
)
console
.
log
(
userChatInput
.
value
)
messages
.
value
.
push
({
role
:
'user'
,
content
:
userChatInput
.
value
})
messages
.
value
.
push
({
role
:
'user'
,
content
:
userChatInput
.
value
})
post
({
userChatInpu
t
:
content
||
userChatInput
.
value
})
post
({
conten
t
:
content
||
userChatInput
.
value
})
userChatInput
.
value
=
''
userChatInput
.
value
=
''
}
}
...
...
src/composables/useAI.js
浏览文件 @
86ba453c
...
@@ -56,7 +56,7 @@ export function useAI() {
...
@@ -56,7 +56,7 @@ export function useAI() {
const
resp
=
await
axios
.
post
(
const
resp
=
await
axios
.
post
(
'/api/qianfan/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant?access_token='
+
(
await
getAccessToken
()),
'/api/qianfan/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant?access_token='
+
(
await
getAccessToken
()),
{
{
messages
:
[{
role
:
'user'
,
content
:
data
.
userChatInpu
t
}],
messages
:
[{
role
:
'user'
,
content
:
data
.
conten
t
}],
}
}
)
)
messages
.
value
.
push
({
role
:
'assistant'
,
content
:
resp
.
data
.
result
.
replaceAll
(
'
\
n'
,
'<br/>'
)
})
messages
.
value
.
push
({
role
:
'assistant'
,
content
:
resp
.
data
.
result
.
replaceAll
(
'
\
n'
,
'<br/>'
)
})
...
@@ -69,7 +69,7 @@ export function useAI() {
...
@@ -69,7 +69,7 @@ export function useAI() {
'/api/deepseek/chat/completions'
,
'/api/deepseek/chat/completions'
,
{
{
model
:
'deepseek-chat'
,
model
:
'deepseek-chat'
,
messages
:
[{
role
:
'user'
,
content
:
data
.
userChatInpu
t
}],
messages
:
[{
role
:
'user'
,
content
:
data
.
conten
t
}],
},
},
{
{
headers
:
{
'Content-Type'
:
'application/json'
,
Authorization
:
`Bearer
${
apiKey
}
`
},
headers
:
{
'Content-Type'
:
'application/json'
,
Authorization
:
`Bearer
${
apiKey
}
`
},
...
@@ -88,7 +88,7 @@ export function useAI() {
...
@@ -88,7 +88,7 @@ export function useAI() {
'/api/qwen/compatible-mode/v1/chat/completions'
,
'/api/qwen/compatible-mode/v1/chat/completions'
,
{
{
model
:
'qwen-max'
,
model
:
'qwen-max'
,
messages
:
[{
role
:
'user'
,
content
:
data
.
userChatInpu
t
}],
messages
:
[{
role
:
'user'
,
content
:
data
.
conten
t
}],
},
},
{
{
headers
:
{
'Content-Type'
:
'application/json'
,
Authorization
:
`Bearer
${
apiKey
}
`
},
headers
:
{
'Content-Type'
:
'application/json'
,
Authorization
:
`Bearer
${
apiKey
}
`
},
...
@@ -111,7 +111,7 @@ export function useAI() {
...
@@ -111,7 +111,7 @@ export function useAI() {
method
:
'POST'
,
method
:
'POST'
,
headers
:
{
'Content-Type'
:
'application/json'
,
app_key
:
appKey
,
sign
,
timestamp
,
stream
:
'true'
},
headers
:
{
'Content-Type'
:
'application/json'
,
app_key
:
appKey
,
sign
,
timestamp
,
stream
:
'true'
},
body
:
JSON
.
stringify
({
body
:
JSON
.
stringify
({
chat_history
:
[{
role
:
'user'
,
content
:
data
.
userChatInpu
t
}],
chat_history
:
[{
role
:
'user'
,
content
:
data
.
conten
t
}],
stream_resp_type
:
'update'
,
stream_resp_type
:
'update'
,
}),
}),
async
onopen
(
response
)
{
async
onopen
(
response
)
{
...
...
src/composables/useQianfan.js
浏览文件 @
86ba453c
...
@@ -11,16 +11,19 @@ export function useChat() {
...
@@ -11,16 +11,19 @@ export function useChat() {
async
function
post
(
data
)
{
async
function
post
(
data
)
{
isLoading
.
value
=
true
isLoading
.
value
=
true
const
res
=
await
axios
.
post
(
'/api/qianfan/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant?access_token='
+
(
await
getAccessToken
()),
{
const
res
=
await
axios
.
post
(
messages
:
[{
role
:
'user'
,
content
:
data
.
userChatInput
}]
'/api/qianfan/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant?access_token='
+
(
await
getAccessToken
()),
})
{
messages
:
[{
role
:
'user'
,
content
:
data
.
content
}],
}
)
messages
.
value
.
push
({
role
:
'assistant'
,
content
:
res
.
data
.
result
.
replaceAll
(
'
\
n'
,
'<br/>'
)
})
messages
.
value
.
push
({
role
:
'assistant'
,
content
:
res
.
data
.
result
.
replaceAll
(
'
\
n'
,
'<br/>'
)
})
isLoading
.
value
=
false
isLoading
.
value
=
false
// await fetchEventSource('/api/qianfan/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant?access_token=' + (await getAccessToken()), {
// await fetchEventSource('/api/qianfan/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant?access_token=' + (await getAccessToken()), {
// method: 'POST',
// method: 'POST',
// headers: { 'Content-Type': 'application/json' },
// headers: { 'Content-Type': 'application/json' },
// body: JSON.stringify({
// body: JSON.stringify({
// messages: [{ role: 'user', content: data.
userChatInpu
t }],
// messages: [{ role: 'user', content: data.
conten
t }],
// stream: true
// stream: true
// }),
// }),
// async onopen(response) {
// async onopen(response) {
...
@@ -53,7 +56,9 @@ export function useChat() {
...
@@ -53,7 +56,9 @@ export function useChat() {
}
}
async
function
getAccessToken
()
{
async
function
getAccessToken
()
{
const
res
=
await
axios
.
post
(
'/api/qianfan/oauth/2.0/token?grant_type=client_credentials&client_id='
+
AK
+
'&client_secret='
+
SK
)
const
res
=
await
axios
.
post
(
'/api/qianfan/oauth/2.0/token?grant_type=client_credentials&client_id='
+
AK
+
'&client_secret='
+
SK
)
return
res
.
data
.
access_token
return
res
.
data
.
access_token
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论