-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jiachenxu01
committed
Jul 26, 2024
1 parent
c23e589
commit cddc576
Showing
2 changed files
with
26 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,26 @@ | ||
1. 需安装 npm。 | ||
2. 安装好后,在命令行里输入: npm install express。 | ||
3. 需要启动 proxy, 在命令行里面输入:npm run proxy -- ak sk。 ak 和sk对应的位置分别输入你的access key 和secret key。 | ||
4. proxy启动后,用浏览器打开html文件,刷新,即可在console里面查看返回结果。 | ||
|
||
1. 浏览器使用需要添加base url, | ||
2. 需要启动 proxy, 可以在本地package.json 的scripts下面加入: "proxy": "cd bce-qianfan-sdk/javascript/proxyServer && node proxy.js" 运行 命令 | ||
或者进入nodemodules里面的千帆sdk下面的javascript里面直接运行命令: npm run proxy -- ak sk。 ak 和sk对应的位置分别输入你的access key 和secret key。 | ||
3. proxy启动后,用浏览器打开html文件,刷新,即可在console里面查看返回结果。 | ||
![browserproxy](../docs/imgs/browserproxy.jpeg) | ||
|
||
```ts | ||
import {ChatCompletion, setEnvVariable} from "@baiducloud/qianfan"; | ||
|
||
const client = new ChatCompletion({QIANFAN_BASE_URL: 'http://172.18.184.85:8002', QIANFAN_CONSOLE_API_BASE_URL: 'http://172.18.184.85:8003'}); | ||
|
||
async function main() { | ||
const resp = await client.chat({ | ||
messages: [ | ||
{ | ||
role: 'user', | ||
content: '你好!', | ||
}, | ||
], | ||
}); | ||
console.log(resp); | ||
} | ||
|
||
main(); | ||
``` |