vinhnx90 commited on
Commit
384e373
1 Parent(s): 0988d77

Create .env to config key

Browse files
Files changed (3) hide show
  1. README.md +12 -3
  2. apikey.py +8 -1
  3. app.py +0 -4
README.md CHANGED
@@ -73,9 +73,18 @@ pip install -r requirements.txt
73
 
74
  4. **Configure the App**:
75
 
76
- - Open the `app.py` file in the VSCode editor.
77
- - Set your OpenAI API key by modifying the `OPENAI_API_KEY` variable.
78
- - Optionally, you can change the `CHROMA_PERSIST_DIRECTORY` and `OPENAI_MODEL` variables according to your preferences.
 
 
 
 
 
 
 
 
 
79
 
80
  5. **Run the Streamlit App**:
81
 
 
73
 
74
  4. **Configure the App**:
75
 
76
+ - Navigate to OpenAI Platform > API Keys to generate an API Key to run the model
77
+ - Create a `.env` file locally, this file is hidden and will be automatically ignored by `.gitignore`
78
+
79
+ ```sh
80
+ touch .env
81
+ ```
82
+
83
+ Inside `.env` file, pass the API Key into `OPENAI_API_KEY` value
84
+
85
+ ```sh
86
+ OPENAI_API_KEY = "sk-..."
87
+ ```
88
 
89
  5. **Run the Streamlit App**:
90
 
apikey.py CHANGED
@@ -1 +1,8 @@
1
- openai_api_key = ""
 
 
 
 
 
 
 
 
1
+ import os
2
+ import openai
3
+
4
+ from dotenv import load_dotenv, find_dotenv
5
+
6
+ _ = load_dotenv(find_dotenv())
7
+
8
+ openai_api_key = os.environ["OPENAI_API_KEY"]
app.py CHANGED
@@ -12,10 +12,6 @@ from langchain.document_loaders import (
12
  TextLoader,
13
  )
14
 
15
- from apikey import openai_api_key
16
-
17
- os.environ["OPENAI_API_KEY"] = openai_api_key
18
-
19
 
20
  def load_and_process_file(file_data):
21
  """
 
12
  TextLoader,
13
  )
14
 
 
 
 
 
15
 
16
  def load_and_process_file(file_data):
17
  """