明树Git Lab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
D
deepseek_wechat_chat
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
zengfanpei
deepseek_wechat_chat
Commits
3b841d47
Commit
3b841d47
authored
Feb 20, 2025
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
4847908d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
1 deletion
+42
-1
.gitignore
.gitignore
+0
-1
test.js
test.js
+42
-0
No files found.
.gitignore
View file @
3b841d47
...
...
@@ -3,5 +3,4 @@ node_modules/
package-lock.json
.vscode
test/
test.js
public/avatar
\ No newline at end of file
test.js
0 → 100644
View file @
3b841d47
const
axios
=
require
(
'axios'
);
async
function
callDashScope
()
{
// 若没有配置环境变量,可用百炼API Key将下行替换为:apiKey='sk-xxx'。但不建议在生产环境中直接将API Key硬编码到代码中,以减少API Key泄露风险。
const
apiKey
=
"sk-0ff2fc43671f4ed28dd7c80289da04e7"
;
const
appId
=
'6de1065c75074ee1a11238ab90c1aa34'
;
// 替换为实际的应用 ID
const
url
=
`https://dashscope.aliyuncs.com/api/v1/apps/
${
appId
}
/completion`
;
const
data
=
{
input
:
{
prompt
:
"你是谁?"
},
parameters
:
{},
debug
:
{}
};
try
{
const
response
=
await
axios
.
post
(
url
,
data
,
{
headers
:
{
'Authorization'
:
`Bearer
${
apiKey
}
`
,
'Content-Type'
:
'application/json'
}
});
if
(
response
.
status
===
200
)
{
console
.
log
(
`
${
response
.
data
.
output
.
text
}
`
);
}
else
{
console
.
log
(
`request_id=
${
response
.
headers
[
'request_id'
]}
`
);
console
.
log
(
`code=
${
response
.
status
}
`
);
console
.
log
(
`message=
${
response
.
data
.
message
}
`
);
}
}
catch
(
error
)
{
console
.
error
(
`Error calling DashScope:
${
error
.
message
}
`
);
if
(
error
.
response
)
{
console
.
error
(
`Response status:
${
error
.
response
.
status
}
`
);
console
.
error
(
`Response data:
${
JSON
.
stringify
(
error
.
response
.
data
,
null
,
2
)}
`
);
}
}
}
callDashScope
();
\ No newline at end of file
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