Skip to content

Commit

Permalink
fixed proxy.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jiachenxu01 committed Jul 26, 2024
1 parent c23e589 commit cddc576
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
Binary file added docs/imgs/browserproxy.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 26 additions & 4 deletions docs/javascript/Proxy.md
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();
```

0 comments on commit cddc576

Please sign in to comment.