diff --git a/README.md b/README.md index 7180efd5a..f9e82a237 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ pip3 install --upgrade -r requirements.txt Create a `.env` file in the root directory and add your API key: ```bash -CHATGPT_API_KEY=your_openai_key_here +OPENAI_API_KEY=your_openai_key_here ``` ### 3. Run PageIndex on your PDF diff --git a/pageindex/utils.py b/pageindex/utils.py index dc7acd888..45a321339 100644 --- a/pageindex/utils.py +++ b/pageindex/utils.py @@ -17,7 +17,7 @@ from pathlib import Path from types import SimpleNamespace as config -CHATGPT_API_KEY = os.getenv("CHATGPT_API_KEY") +OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") def count_tokens(text, model=None): if not text: @@ -26,7 +26,7 @@ def count_tokens(text, model=None): tokens = enc.encode(text) return len(tokens) -def ChatGPT_API_with_finish_reason(model, prompt, api_key=CHATGPT_API_KEY, chat_history=None): +def ChatGPT_API_with_finish_reason(model, prompt, api_key=OPENAI_API_KEY, chat_history=None): max_retries = 10 client = openai.OpenAI(api_key=api_key) for i in range(max_retries): @@ -58,7 +58,7 @@ def ChatGPT_API_with_finish_reason(model, prompt, api_key=CHATGPT_API_KEY, chat_ -def ChatGPT_API(model, prompt, api_key=CHATGPT_API_KEY, chat_history=None): +def ChatGPT_API(model, prompt, api_key=OPENAI_API_KEY, chat_history=None): max_retries = 10 client = openai.OpenAI(api_key=api_key) for i in range(max_retries): @@ -86,7 +86,7 @@ def ChatGPT_API(model, prompt, api_key=CHATGPT_API_KEY, chat_history=None): return "Error" -async def ChatGPT_API_async(model, prompt, api_key=CHATGPT_API_KEY): +async def ChatGPT_API_async(model, prompt, api_key=OPENAI_API_KEY): max_retries = 10 messages = [{"role": "user", "content": prompt}] for i in range(max_retries):