Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy #719

Merged
merged 15 commits into from
Aug 9, 2024
Binary file removed docs/imgs/browserproxy.jpeg
Binary file not shown.
Binary file added docs/imgs/proxy.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion docs/javascript/Proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
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](../imgs/browserproxy.jpeg)

![browserproxy](../imgs/proxy.jpeg)


```ts
import {ChatCompletion, setEnvVariable} from "@baiducloud/qianfan";
Expand Down
1 change: 0 additions & 1 deletion javascript/src/Base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ export class BaseClient {
let fetchOptions;
// 如果enableOauth开启, 则放开鉴权
if (getCurrentEnvironment() === 'node' || this.enableOauth) {

// 检查鉴权信息
if (!(this.qianfanAccessKey && this.qianfanSecretKey) && !(this.qianfanAk && this.qianfanSk)) {
throw new Error('请设置AK/SK或QIANFAN_ACCESS_KEY/QIANFAN_SECRET_KEY');
Expand Down