Skip to content

Commit

Permalink
修改readme中读取环境变量的部分
Browse files Browse the repository at this point in the history
  • Loading branch information
jayceftg committed Oct 30, 2024
1 parent 6fd8c2f commit f86256a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ examples/novel.md
examples/9_knowledge_files/*
ga/*
html/*
.history
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,28 @@ pip install GeneralAgent


## 配置
### 方式一:使用环境变量(推荐)
1. 安装依赖:
```bash
pip install python-dotenv
```

参考 [.env.example](./.env.example) 文件,配置大模型的Key或者其他参数

2. 参考 [.env.example](./.env.example) 文件,创建并配置 .env 文件:
```bash
export OPENAI_API_KEY=your_openai_api_key
# export OPENAI_API_BASE=your_openai_base_url
# using with not openai official server or using other OpenAI API formate LLM server such as deepseek, zhipu(chatglm),qwen, etc.
OPENAI_API_KEY=your_openai_api_key
# OPENAI_API_BASE=your_openai_base_url
```

3. 在代码中加载环境变量:
```python
from dotenv import load_dotenv
from GeneralAgent import Agent

load_dotenv()
agent = Agent('You are a helpful agent.')
```

或者在代码中配置
### 方式二:直接在代码中配置

```python
from GeneralAgent import Agent
Expand Down
23 changes: 18 additions & 5 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,28 @@ pip install GeneralAgent

## Configuration

Refer to the [.env.example](./.env.example) file to configure the key or other parameters of the large model
### Method 1: Using Environment Variables (Recommended)
1. Install dependency:
```bash
pip install python-dotenv
```

2. Refer to [.env.example](./.env.example) file to create and configure .env file:
```bash
export OPENAI_API_KEY=your_openai_api_key
# export OPENAI_API_BASE=your_openai_base_url
# using with not openai official server or using other OpenAI API formate LLM server such as deepseek, zhipu(chatglm),qwen, etc.
OPENAI_API_KEY=your_openai_api_key
# OPENAI_API_BASE=your_openai_base_url
```

3. Load environment variables in code:
```python
from dotenv import load_dotenv
from GeneralAgent import Agent

load_dotenv()
agent = Agent('You are a helpful agent.')
```

Or configure in the code
### Method 2: Configure in Code

```python
from GeneralAgent import Agent
Expand Down

0 comments on commit f86256a

Please sign in to comment.