Skip to content

Commit

Permalink
feat: Update guide for applying and using keys in camel (#1176)
Browse files Browse the repository at this point in the history
Co-authored-by: Wendong <w3ndong.fan@gmail.com>
  • Loading branch information
NeilJohnson0930 and Wendong-Fan authored Nov 18, 2024
1 parent db1d9ef commit 5a2e4e2
Show file tree
Hide file tree
Showing 4 changed files with 720 additions and 634 deletions.
78 changes: 78 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# To use these environment variables:
# 1. Populate the .env file with your API keys.
# 2. Include the following code snippet in your Python script:
# from dotenv import load_dotenv
# import os
#
# load_dotenv() # Load environment variables from .env file

#===========================================
# Models API
#===========================================

# OpenAI API (https://platform.openai.com/signup)
OPENAI_API_KEY="Fill your API key here"

# Anthropic API (https://www.anthropic.com/)
ANTHROPIC_API_KEY="Fill your API key here"

# Groq API (https://groq.com/)
GROQ_API_KEY="Fill your API key here"

# Cohere API (https://cohere.ai/)
COHERE_API_KEY="Fill your API key here"

# Hugging Face API (https://huggingface.co/join)
HF_TOKEN="Fill your API key here"

# Azure OpenAI API (https://azure.microsoft.com/products/cognitive-services/openai-service/)
AZURE_OPENAI_API_KEY="Fill your API key here"
AZURE_API_VERSION="Fill your API Version here"
AZURE_DEPLOYMENT_NAME="Fill your Deployment Name here"
AZURE_OPENAI_BASE_URL="Fill your Base URL here"

# Mistral API (https://mistral.ai/)
MISTRAL_API_KEY="Fill your API key here"

# Reka API (https://www.reka.ai/)
REKA_API_KEY="Fill your API key here"

# Zhipu AI API (https://www.zhipu.ai/)
ZHIPUAI_API_KEY="Fill your API key here"
ZHIPUAI_API_BASE_URL="Fill your Base URL here"

# Qwen API (https://help.aliyun.com/document_detail/611472.html)
QWEN_API_KEY="Fill your API key here"

# LingYi API (https://platform.lingyiwanwu.com/apikeys)
YI_API_KEY="Fill your API key here"

#===========================================
# Tools & Services API
#===========================================

# Google Search API (https://developers.google.com/custom-search/v1/overview)
GOOGLE_API_KEY="Fill your API key here"
SEARCH_ENGINE_ID="Fill your API key here"

# OpenWeatherMap API (https://home.openweathermap.org/users/sign_up)
OPENWEATHERMAP_API_KEY="Fill your API key here"

# NVIDIA API (https://build.nvidia.com/explore/discover)
NVIDIA_API_BASE_URL="Fill your API key here"
NVIDIA_API_KEY="Fill your API key here"

# Neo4j Database (https://neo4j.com/)
NEO4J_URI="Fill your API key here"
NEO4J_USERNAME="Fill your User Name here"
NEO4J_PASSWORD="Fill your Password here"

# Firecrawl API (https://www.firecrawl.dev/)
FIRECRAWL_API_KEY="Fill your API key here"

# AskNews API (https://docs.asknews.app/en/reference)
ASKNEWS_CLIENT_ID="Fill your Client ID here"
ASKNEWS_CLIENT_SECRET="Fill your Client Secret here"

# Chunkr API (https://chunkr.ai/)
CHUNKR_API_KEY="Fill your API key here"
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ celerybeat.pid
*.sage.py

# Environments
.env
.venv
env/
venv/
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,37 @@ Replace `<insert your OpenAI API key>` with your actual OpenAI API key in each c

Please note that the environment variable is session-specific. If you open a new terminal window or tab, you will need to set the API key again in that new session.

**For `.env` File:**

To simplify the process of managing API Keys, you can use store information in a `.env` file and load them into your application dynamically.

1. Modify .env file in the root directory of CAMEL and fill the following lines:

```bash
OPENAI_API_KEY=<fill your API KEY here>
```

Replace <fill your API KEY here> with your actual API key.

2. Load the .env file in your Python script: Use the load_dotenv() function from the dotenv module to load the variables from the .env file into the environment. Here's an example:
```python
from dotenv import load_dotenv
import os
# Load environment variables from the .env file
load_dotenv()
```
For more details about the key names in project and how to apply key,
you can refer to [here](https://github.com/camel-ai/camel/.env).
> [!TIP]
> By default, the load_dotenv() function does not overwrite existing environment variables that are already set in your system. It only populates variables that are missing.
If you need to overwrite existing environment variables with the values from your `.env` file, use the `override=True` parameter:
> ```python
> load_dotenv(override=True)
> ```
After setting the OpenAI API key, you can run the `role_playing.py` script. Find tasks for various assistant-user roles [here](https://drive.google.com/file/d/194PPaSTBR07m-PzjS-Ty6KlPLdFIPQDd/view?usp=share_link).
```bash
Expand Down
Loading

0 comments on commit 5a2e4e2

Please sign in to comment.