ProfessorLeVesseur
commited on
Commit
•
7639be6
1
Parent(s):
3474866
Update app.py
Browse files
app.py
CHANGED
@@ -2,24 +2,55 @@ import streamlit as st
|
|
2 |
import openai
|
3 |
import random
|
4 |
|
5 |
-
# Fetch the OpenAI API key from Streamlit secrets
|
6 |
-
openai_api_key = st.secrets["openai_api_key"]
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
# Initialize the OpenAI service with API key
|
9 |
openai.api_key = openai_api_key
|
10 |
|
11 |
-
#
|
12 |
-
#
|
13 |
-
# # pinecone_api_key = '555c0e70-331d-4b43-aac7-5b3aac5078d6'
|
14 |
-
# pinecone_environment = st.secrets["pinecone_environment"]
|
15 |
|
16 |
-
#
|
17 |
from pinecone import Pinecone
|
18 |
-
|
19 |
-
|
|
|
|
|
20 |
|
21 |
-
PINECONE_API_KEY = "555c0e70-331d-4b43-aac7-5b3aac5078d6"
|
22 |
-
pc = Pinecone(api_key=PINECONE_API_KEY)
|
23 |
|
24 |
# # Define the name of the Pinecone index
|
25 |
index_name = 'mimtssinkqa'
|
|
|
2 |
import openai
|
3 |
import random
|
4 |
|
|
|
|
|
5 |
|
6 |
+
|
7 |
+
|
8 |
+
|
9 |
+
# # Fetch the OpenAI API key from Streamlit secrets
|
10 |
+
# openai_api_key = st.secrets["openai_api_key"]
|
11 |
+
|
12 |
+
# # Initialize the OpenAI service with API key
|
13 |
+
# openai.api_key = openai_api_key
|
14 |
+
|
15 |
+
# # # Fetch Pinecone API key and environment from Streamlit secrets
|
16 |
+
# # PINECONE_API_KEY = st.secrets["PINECONE_API_KEY"]
|
17 |
+
# # # pinecone_api_key = '555c0e70-331d-4b43-aac7-5b3aac5078d6'
|
18 |
+
# # pinecone_environment = st.secrets["pinecone_environment"]
|
19 |
+
|
20 |
+
# # # AUTHENTICATE/INITIALIZE PINCONE SERVICE
|
21 |
+
# from pinecone import Pinecone
|
22 |
+
# # # pc = Pinecone(api_key=PINECONE_API_KEY)
|
23 |
+
# # pc = Pinecone (api_key= 'YOUR_API_KEY')
|
24 |
+
|
25 |
+
# PINECONE_API_KEY = "555c0e70-331d-4b43-aac7-5b3aac5078d6"
|
26 |
+
# pc = Pinecone(api_key=PINECONE_API_KEY)
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
import os
|
31 |
+
# from pathlib import Path
|
32 |
+
# Import specific functions from python-dotenv package (i.e., used to read key-value pairs from a .env file and add them to the environment variables.)
|
33 |
+
from dotenv import load_dotenv, find_dotenv
|
34 |
+
# Find and load .env file, override existing environment variables
|
35 |
+
load_dotenv(find_dotenv(), override=True)
|
36 |
+
|
37 |
+
# Retrieve OpenAI API key from environment variables
|
38 |
+
openai_api_key = os.getenv('OPENAI_API_KEY')
|
39 |
+
if not openai_api_key:
|
40 |
+
raise ValueError("OPENAI_API_KEY not set in environment variables")
|
41 |
# Initialize the OpenAI service with API key
|
42 |
openai.api_key = openai_api_key
|
43 |
|
44 |
+
# Hardcode the OpenAI API key
|
45 |
+
# openai_api_key = "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"
|
|
|
|
|
46 |
|
47 |
+
# AUTHENTICATE/INITIALIZE PINCONE SERVICE
|
48 |
from pinecone import Pinecone
|
49 |
+
pc = Pinecone()
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
|
|
|
|
|
54 |
|
55 |
# # Define the name of the Pinecone index
|
56 |
index_name = 'mimtssinkqa'
|