Spaces:
Sleeping
Sleeping
Commit
·
dbcad54
1
Parent(s):
87d7b67
add openai key to huggingface
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ import gradio as gr
|
|
7 |
import openai # for calling the OpenAI API
|
8 |
import pandas as pd # for storing text and embeddings data
|
9 |
import tiktoken # for counting tokens
|
|
|
10 |
from ai_configs import (
|
11 |
EMBEDDING_MODEL,
|
12 |
FILEPATH_EMBEDDINGS,
|
@@ -17,12 +18,15 @@ from ai_configs import (
|
|
17 |
)
|
18 |
from scipy import spatial # for calculating vector similarities for search
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
print(open)
|
26 |
|
27 |
model_name = MODEL_NAME
|
28 |
# Read embbeding file
|
|
|
7 |
import openai # for calling the OpenAI API
|
8 |
import pandas as pd # for storing text and embeddings data
|
9 |
import tiktoken # for counting tokens
|
10 |
+
from pathlib import Path
|
11 |
from ai_configs import (
|
12 |
EMBEDDING_MODEL,
|
13 |
FILEPATH_EMBEDDINGS,
|
|
|
18 |
)
|
19 |
from scipy import spatial # for calculating vector similarities for search
|
20 |
|
21 |
+
# Read openai key
|
22 |
+
if Path(".env").is_file():
|
23 |
+
# file exists
|
24 |
+
env = configparser.ConfigParser()
|
25 |
+
env.read(".env")
|
26 |
+
openai.api_key = env["OpenAI"]["OPENAI_KEY_TT"] # localhost
|
27 |
+
else:
|
28 |
+
openai.api_key = OPENAI_API_KEY # huggingface
|
29 |
|
|
|
30 |
|
31 |
model_name = MODEL_NAME
|
32 |
# Read embbeding file
|