Update app.py
Browse files
app.py
CHANGED
|
@@ -1,25 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import openai
|
| 3 |
import random
|
| 4 |
import os
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# Fetch the OpenAI API key from Streamlit secrets
|
| 8 |
os.environ["OPENAI_API_KEY"] = st.secrets["OPENAI_API_KEY"]
|
| 9 |
-
#
|
| 10 |
-
# Retrieve the OpenAI API Key from secrets
|
| 11 |
-
# openai.api_key = st.secrets["OPENAI_API_KEY"]
|
| 12 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
|
|
|
| 13 |
openai.api_key = OPENAI_API_KEY
|
| 14 |
|
| 15 |
-
#
|
| 16 |
os.environ["PINECONE_API_KEY"] = st.secrets["PINECONE_API_KEY"]
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
#
|
| 20 |
from pinecone import Pinecone
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# # Define the name of the Pinecone index
|
| 25 |
index_name = 'mimtssinkqa'
|
|
|
|
| 1 |
+
#------------------------------------------------------------------------
|
| 2 |
+
# Import Modules
|
| 3 |
+
#------------------------------------------------------------------------
|
| 4 |
+
|
| 5 |
import streamlit as st
|
| 6 |
import openai
|
| 7 |
import random
|
| 8 |
import os
|
| 9 |
|
| 10 |
+
from pinecone import Pinecone
|
| 11 |
+
from langchain.chat_models import ChatOpenAI
|
| 12 |
+
from langsmith import Client
|
| 13 |
+
from langchain.smith import RunEvalConfig, run_on_dataset
|
| 14 |
+
|
| 15 |
+
from dotenv import load_dotenv, find_dotenv
|
| 16 |
+
# Find and load .env file, override existing environment variables
|
| 17 |
+
load_dotenv(find_dotenv(), override=True)
|
| 18 |
|
| 19 |
# Fetch the OpenAI API key from Streamlit secrets
|
| 20 |
os.environ["OPENAI_API_KEY"] = st.secrets["OPENAI_API_KEY"]
|
| 21 |
+
# Retrieve the OpenAI API Key from environment variable
|
|
|
|
|
|
|
| 22 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 23 |
+
# Initialize OpenAI Service
|
| 24 |
openai.api_key = OPENAI_API_KEY
|
| 25 |
|
| 26 |
+
# Fetch Pinecone API key from Streamlit secrets
|
| 27 |
os.environ["PINECONE_API_KEY"] = st.secrets["PINECONE_API_KEY"]
|
| 28 |
+
# Retrieve the Pinecone API Key from environment variable
|
| 29 |
+
PINECONE_API_KEY = os.getenv("PINECONE_API_KEY")
|
| 30 |
+
# Initialize Pinecone Service
|
| 31 |
from pinecone import Pinecone
|
| 32 |
+
pc = Pinecone(api_key=PINECONE_API_KEY)
|
| 33 |
+
|
| 34 |
+
# Fetch Pinecone API key from Streamlit secrets
|
| 35 |
+
os.environ["PINECONE_API_KEY"] = st.secrets["PINECONE_API_KEY"]
|
| 36 |
+
# Retrieve the Pinecone API Key from environment variable
|
| 37 |
+
PINECONE_API_KEY = os.getenv("PINECONE_API_KEY")
|
| 38 |
+
# Initialize Pinecone Service
|
| 39 |
+
# from pinecone import Pinecone
|
| 40 |
+
pc = Pinecone(api_key=PINECONE_API_KEY)
|
| 41 |
+
|
| 42 |
|
| 43 |
# # Define the name of the Pinecone index
|
| 44 |
index_name = 'mimtssinkqa'
|