Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
strategy:
matrix:
include:
- python-version: "3.9"
- python-version: "3.10"
os: ubuntu-latest
- python-version: "3.9"
- python-version: "3.10"
os: macos-latest
# - python-version: "3.9"
# os: window
Expand Down
81 changes: 6 additions & 75 deletions README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ pip install askchat --upgrade
Configure environment variables:

```bash
# Initialize configuration (interactive)
chatenv init -i

# Or manually set environment variables
export OPENAI_API_KEY="your-api-key"
export OPENAI_API_BASE="https://api.openai.com/v1"
export OPENAI_API_BASE_URL="https://api.openai.com"
Expand All @@ -56,13 +60,13 @@ Note: The `OPENAI_API_BASE` variable takes precedence over the `OPENAI_API_BASE_

## How to Use

Use environment variables for simple question and answer:
After configuration, use environment variables for simple question and answer:

```bash
ask hello world
```

In addition, you can use `askchat` for more flexible dialogue and `askenv` to manage environment configurations.
In addition, you can use `askchat` for more flexible dialogue.

## AskChat

Expand Down Expand Up @@ -126,7 +130,6 @@ Default parameters for `askchat`, these are used for direct interaction with Cha
| `--api-base` | `--api-base https://api.example.com/v1` | Set the Base URL |
| `--api-key` | `-a sk-xxxxxxx` | Provide the OpenAI API key |
| `--option` | `-o top_p 1 temperature 0.5` | Set request parameters |
| `--use-env` | `-u prod` | Load environment variables from a specified config, see [AskEnv](#askenv) |

Note: Some model APIs, such as Zhishu, use `/v4` as the API base path, in which case use the `--api-base` parameter.

Expand All @@ -136,7 +139,6 @@ Auxiliary features, such as generating configuration files, debugging logs, prin

| Parameter | Example | Explanation |
|--------------------------|----------------------------------|---------------------------------------|
| `--generate-config` | `askchat --generate-config` | Generate a configuration file, saved in `~/.askchat/.env` |
| `--print-curl` | `askchat hello --print-curl` | Print the actual request URL |
| `--debug` | `askchat --debug` | Print debugging logs |
| `--valid-models` | `askchat --valid-models` | Print a list of models containing "gpt" in their names |
Expand All @@ -145,77 +147,6 @@ Auxiliary features, such as generating configuration files, debugging logs, prin

Note: `--all-valid-models` will print all available models, including Embedding, dalle-3, tts, etc., use `--valid-models` to filter these out.

## AskEnv

`askenv` is used to manage different environment configurations, including creating, activating, deleting, etc., making it easy to switch between different channels.

### Examples

<div align="center">
<figure>
<div style="margin-top: 10px; color: #555;">1. Create channel</div>
<img src="docs/assets/svgs/askenv.svg" alt="askenv" width="480">
</figure>
</div>

<div align="center">
<figure>
<div style="margin-top: 10px; color: #555;">2. Edit channel</div>
<img src="docs/assets/svgs/editenv.svg" alt="editenv" width="480">
</figure>
</div>

### Basic Usage

1. Create a new environment configuration using the `new` command.

```bash
askenv new <name> [-a API_KEY] [-b BASE_URL] [--api-base API_BASE] [-m MODEL]
```

Or generate a default config from environment variables using `askchat --generate-config`:

```bash
askchat --generate-config
```

2. Activate a certain environment, setting it as the currently used configuration.

```bash
askenv use <name>
```

3. Delete a specified environment configuration file.

```bash
askenv delete <name>
askenv delete --default
```

4. List all currently available environments.

```bash
askenv list
```

5. Show configuration info of a specified environment, or the default environment if no name is specified.

```bash
askenv show [name]
```

6. Save the currently activated environment configuration as a specified name's configuration file.

```bash
askenv save <name>
```

7. Update one or more settings of a specified or default environment configuration.

```bash
askenv config [name] [-a API_KEY] [-b BASE_URL] [--api-base API_BASE] [-m MODEL]
```

## Issues and Feedback

If you encounter any problems or have suggestions, feel free to submit an [Issue](https://github.com/cubenlp/askchat/issues).
77 changes: 6 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ pip install askchat --upgrade
配置环境变量:

```bash
# 初始化配置(交互式)
chatenv init -i

# 或者手动设置环境变量
export OPENAI_API_KEY="your-api-key"
export OPENAI_API_BASE="https://api.openai.com/v1"
export OPENAI_API_BASE_URL="https://api.openai.com"
Expand All @@ -52,13 +56,13 @@ export OPENAI_API_MODEL="gpt-3.5-turbo"

## 使用方法

使用环境变量,进行简单的问答:
配置完成后,进行简单的问答:

```bash
ask hello world
```

除此之外,可使用 `askchat` 进行更灵活的对话,使用 `askenv` 管理环境配置
除此之外,可使用 `askchat` 进行更灵活的对话。

## AskChat

Expand Down Expand Up @@ -114,7 +118,6 @@ ask hello world
| `--api-base` | `--api-base https://api.example.com/v1` | 设置 Base URL |
| `--api-key` | `-a sk-xxxxxxx` | 提供 OpenAI API 密钥 |
| `--option` | `-o top_p 1 temperature 0.5` | 设置请求参数 |
| `--use-env` | `-u prod` | 使用指定配置文件加载环境变量,详见 [AskEnv](#askenv) |

注:一些模型 API,比如智谱,使用 `/v4` 作为 API 的基础路径,这时得用 `--api-base` 参数。

Expand All @@ -124,7 +127,6 @@ ask hello world

| 参数 | 示例 | 解释 |
|---------------------------|----------------------|--------------------------------------------|
| `--generate-config` | `askchat --generate-config` | 生成配置文件,保存在 `~/.askchat/.env` 中 |
| `--print-url` | `askchat hello --print-url` | 打印实际请求的 URL |
| `--debug` | `askchat --debug` | 打印调试日志 |
| `--valid-models` | `askchat --valid-models` | 打印包含 "gpt" 名称的模型列表 |
Expand All @@ -133,73 +135,6 @@ ask hello world

注:`--all-valid-models` 会打印所有可用模型,包括 Embedding, dalle-3, tts 等,使用 `--valid-models` 可以过滤掉这些。

## AskEnv

`askenv` 用于管理不同的环境配置,包括创建、激活、删除等操作,便于在不同的渠道间切换。

### 示例

<div align="center">
<div style="margin-top: 10px; color: #555;">1. 创建渠道</div>
<img src="docs/assets/svgs/askenv.svg" alt="askenv" width="480">
</div>

<div align="center">
<div style="margin-top: 10px; color: #555;">2. 编辑渠道</div>
<img src="docs/assets/svgs/editenv.svg" alt="editenv" width="480">
</div>

### 基本用法

1. 创建一个新的环境配置,使用 `new` 命令。

```bash
askenv new <name> [-a API_KEY] [-b BASE_URL] [--api-base API_BASE] [-m MODEL]
```

或者用 `askchat --generate-config` 从环境变量生成默认配置:

```bash
askchat --generate-config
```

2. 激活某个环境,将其设置为当前使用的配置。

```bash
askenv use <name>
```

3. 删除指定的环境配置文件。

```bash
askenv delete <name>
askenv delete --default
```

4. 列出当前所有可用环境。

```bash
askenv list
```

5. 显示指定环境的配置信息,如果没有指定环境名称,则显示默认环境的配置。

```bash
askenv show [name]
```

6. 将当前激活的环境配置保存为指定名称的配置文件。

```bash
askenv save <name>
```

7. 更新指定或默认环境配置的一项或多项设置。

```bash
askenv config [name] [-a API_KEY] [-b BASE_URL] [--api-base API_BASE] [-m MODEL]
```

## 问题和反馈

使用过程中有任何问题或建议,欢迎提交 [Issue](https://github.com/cubenlp/askchat/issues)。
Loading