Stéphane G commited on
Commit ·
c114add
1
Parent(s): da00ae1
Load env var for local dev set up
Browse files- .env.example +1 -0
- .gitignore +1 -0
- app.py +7 -2
.env.example
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
OPENAI_API_KEY="<insert-key-here>"
|
.gitignore
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
.DS_Store
|
|
|
|
|
|
| 1 |
.DS_Store
|
| 2 |
+
.env
|
app.py
CHANGED
|
@@ -5,12 +5,13 @@
|
|
| 5 |
# - Chroma for the vectorstore
|
| 6 |
|
| 7 |
# For local dev env : install the following packages
|
| 8 |
-
#!pip install langchain openai chromadb panel gitpython
|
| 9 |
|
| 10 |
import os
|
| 11 |
import panel as pn
|
| 12 |
from typing import List
|
| 13 |
from urllib.parse import urlparse
|
|
|
|
| 14 |
|
| 15 |
from langchain.chains import RetrievalQA
|
| 16 |
from langchain.llms import OpenAI
|
|
@@ -47,6 +48,10 @@ def get_names_repos_already_checkout():
|
|
| 47 |
remove_empty_subdirs(path_checkout)
|
| 48 |
return get_names_subdirs(path_checkout)
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
#------------------------------------------------------------------------------
|
| 51 |
# Panel setup
|
| 52 |
pn.extension(
|
|
@@ -65,7 +70,7 @@ pn.state.template.param.update(
|
|
| 65 |
# User inputs
|
| 66 |
|
| 67 |
input_key_openai = pn.widgets.PasswordInput(
|
| 68 |
-
value = "",
|
| 69 |
placeholder = "Enter your OpenAI API Key here...",
|
| 70 |
width = 300
|
| 71 |
)
|
|
|
|
| 5 |
# - Chroma for the vectorstore
|
| 6 |
|
| 7 |
# For local dev env : install the following packages
|
| 8 |
+
#!pip install langchain openai chromadb panel gitpython python-dotenv
|
| 9 |
|
| 10 |
import os
|
| 11 |
import panel as pn
|
| 12 |
from typing import List
|
| 13 |
from urllib.parse import urlparse
|
| 14 |
+
from dotenv import load_dotenv
|
| 15 |
|
| 16 |
from langchain.chains import RetrievalQA
|
| 17 |
from langchain.llms import OpenAI
|
|
|
|
| 48 |
remove_empty_subdirs(path_checkout)
|
| 49 |
return get_names_subdirs(path_checkout)
|
| 50 |
|
| 51 |
+
def get_env(key):
|
| 52 |
+
load_dotenv()
|
| 53 |
+
return os.getenv(key)
|
| 54 |
+
|
| 55 |
#------------------------------------------------------------------------------
|
| 56 |
# Panel setup
|
| 57 |
pn.extension(
|
|
|
|
| 70 |
# User inputs
|
| 71 |
|
| 72 |
input_key_openai = pn.widgets.PasswordInput(
|
| 73 |
+
value = get_env("OPENAI_API_KEY"),
|
| 74 |
placeholder = "Enter your OpenAI API Key here...",
|
| 75 |
width = 300
|
| 76 |
)
|