From c7e0fd8b8e0b256acff66c47c2fafcf897b931a3 Mon Sep 17 00:00:00 2001 From: rex <1073853456@qq.com> Date: Thu, 18 Apr 2024 20:42:29 +0800 Subject: [PATCH] update readme --- README.md | 10 +++++++++- README_en.md | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1ee4fe5..003e8f2 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,15 @@ export OPENAI_API_BASE_URL="https://api.example.com" # 可选 Win 在系统中设置环境变量。 -注:环境变量中,`OPENAI_API_BASE` 优先于 `OPENAI_API_BASE_URL`,二者选其一即可。 +也可以在代码中设置: + +```py +import chattool +chattool.api_key = "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +chattool.api_base = "https://api.example.com/v1" +``` + +注:`OPENAI_API_BASE` 优先于 `OPENAI_API_BASE_URL`,二者选其一即可。 ### 示例 diff --git a/README_en.md b/README_en.md index c27dc25..824115c 100644 --- a/README_en.md +++ b/README_en.md @@ -40,10 +40,20 @@ Set environment variables in `~/.bashrc` or `~/.zshrc`: ```bash export OPENAI_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -export OPENAI_API_BASE_URL="https://api.example.com" -export OPENAI_API_BASE="https://api.example.com/v1" +export OPENAI_API_BASE="https://api.example.com/v1" +export OPENAI_API_BASE_URL="https://api.example.com" # optional ``` +Or in Python code: + +```py +import chattool +chattool.api_key = "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +chattool.api_base = "https://api.example.com/v1" +``` + +Note: `OPENAI_API_BASE` is prior to `OPENAI_API_BASE_URL`, and you only need to set one of them. + ## Examples Example 1, simulate multi-turn dialogue: