Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
juncaipeng committed Sep 18, 2023
2 parents 83ef377 + 60b2860 commit f0f05ae
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
28 changes: 23 additions & 5 deletions docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ AI Studio后端可以使用access token进行鉴权,支持如下三种方法

(1) 使用环境变量:

```shell
``` {.copy}
export EB_API_TYPE="aistudio"
export EB_ACCESS_TOKEN="<access-token-for-aistudio>"
```
Expand Down Expand Up @@ -63,7 +63,7 @@ response = erniebot.ChatCompletion.create(
)
```

如果大家同时使用多种方式设置鉴权参数,ERNIE Bot SDK将根据优先级确定配置项的最终取值(其他后端类似)。三种设置方式的优先级从高到低依次为:使用`_config_`参数使用全局变量使用环境变量。
如果大家同时使用多种方式设置鉴权参数,ERNIE Bot SDK将根据优先级确定配置项的最终取值(其他后端类似)。三种设置方式的优先级从高到低依次为:使用`_config_`参数 > 使用全局变量 > 使用环境变量。

## 2 `千帆大模型平台`后端的认证鉴权

Expand All @@ -90,7 +90,7 @@ response = erniebot.ChatCompletion.create(

请注意设置后端参数为`'qianfan'`,并且使用千帆平台申请的access token。

```shell
``` {.copy}
export EB_API_TYPE="qianfan"
export EB_ACCESS_TOKEN="<access-token-for-qianfan>"
```
Expand All @@ -104,7 +104,7 @@ erniebot.access_token = "<access-token-for-qianfan>"

此外,千帆后端还可以使用AK/SK进行鉴权,同样支持三种方法,环境变量对应是`EB_AK``EB_SK`,Python变量对应是`ak``sk`,举例如下。

```shell
``` {.copy}
export EB_API_TYPE="qianfan"
export EB_AK="<access-key-for-qianfan>"
export EB_SK="<secret-access-key-for-qianfan>"
Expand Down Expand Up @@ -140,7 +140,9 @@ erniebot.sk = "<secret-access-key-for-qianfan>"

请注意设置后端参数为`'yinian'`,并且使用智能创作平台申请的access_token、AK/SK。

```shell
使用access token的例子:

``` {.copy}
export EB_API_TYPE="yinian"
export EB_ACCESS_TOKEN="<access-token-for-yinian>"
```
Expand All @@ -151,3 +153,19 @@ import erniebot
erniebot.api_type = "yinian"
erniebot.access_token = "<access-token-for-yinian>"
```

使用AK/SK的例子:

``` {.copy}
export EB_API_TYPE="yinian"
export EB_AK="<access-key-for-yinian>"
export EB_SK="<secret-access-key-for-yinian>"
```

``` {.py .copy}
import erniebot

erniebot.api_type = "yinian"
erniebot.ak = "<access-key-for-yinian>"
erniebot.sk = "<secret-access-key-for-yinian>"
```
6 changes: 4 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# 快速安装

执行如下命令,快速安装Python语言的最新版本ERNIE Bot SDK(推荐Python >= 3.8)。
```shell

``` {.copy}
pip install --upgrade erniebot
```

如果希望自源码安装,可以执行如下命令:
```shell

``` {.copy}
git clone https://github.com/PaddlePaddle/ERNIE-Bot-SDK
cd ERNIE-Bot-SDK
pip install .
Expand Down
3 changes: 2 additions & 1 deletion examples/function_calling/function_calling_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,8 @@ def to_pretty_json(obj, *, from_json=False):


def handle_exception(exception, message, *, raise_=False):
traceback.print_exception(exception)
traceback.print_exception(
type(exception), exception, exception.__traceback__)
if raise_:
raise gr.Error(message)
else:
Expand Down

0 comments on commit f0f05ae

Please sign in to comment.