Spaces:
Sleeping
Sleeping
updated main.py
Browse files
main.py
CHANGED
@@ -16,11 +16,9 @@ from llama_index.core import Document
|
|
16 |
|
17 |
PERSIST_DIR = "./storage"
|
18 |
EMBED_MODEL = "./all-MiniLM-L6-v2"
|
19 |
-
EMBED_MODEL = "./all-MiniLM-L6-v2"
|
20 |
-
EMBED_MODEL = "./all-MiniLM-L6-v2"
|
21 |
LLM_MODEL = "llama3-8b-8192"
|
22 |
CSV_FILE_PATH = "shl_assessments.csv"
|
23 |
-
GROQ_API_KEY = st.secrets["GROQ_API_KEY"] or
|
24 |
|
25 |
|
26 |
def load_data_from_csv(csv_path):
|
@@ -43,7 +41,6 @@ def load_data_from_csv(csv_path):
|
|
43 |
def load_groq_llm():
|
44 |
try:
|
45 |
api_key = st.secrets.get("GROQ_API_KEY") or os.getenv("GROQ_API_KEY")
|
46 |
-
api_key = st.secrets.get("GROQ_API_KEY") or os.getenv("GROQ_API_KEY")
|
47 |
except KeyError:
|
48 |
raise ValueError("GROQ_API_KEY not found in Streamlit secrets.")
|
49 |
|
@@ -52,13 +49,11 @@ def load_groq_llm():
|
|
52 |
|
53 |
|
54 |
def load_embeddings():
|
55 |
-
return HuggingFaceEmbedding(model_name="all-MiniLM-L6-v2")
|
56 |
-
return HuggingFaceEmbedding(model_name="all-MiniLM-L6-v2")
|
57 |
|
58 |
def build_index(data):
|
59 |
"""Builds the vector index from the provided assessment data."""
|
60 |
return HuggingFaceEmbedding(model_name=EMBED_MODEL)
|
61 |
-
return HuggingFaceEmbedding(model_name=EMBED_MODEL)
|
62 |
Settings.llm = load_groq_llm()
|
63 |
|
64 |
documents = [Document(text=f"Name: {item['Assessment Name']}, URL: {item['URL']}, Remote Testing: {item['Remote Testing Support']}, Adaptive/IRT: {item['Adaptive/IRT Support']}, Duration: {item['Duration (min)']}, Type: {item['Test Type']}") for item in data]
|
@@ -144,16 +139,9 @@ def main():
|
|
144 |
"role": "assistant",
|
145 |
"content": "Hello! I'm your SHL assessment assistant. How can I help you?"
|
146 |
}]
|
147 |
-
st.session_state.messages = [{
|
148 |
-
"role": "assistant",
|
149 |
-
"content": "Hello! I'm your SHL assessment assistant. How can I help you?"
|
150 |
-
}]
|
151 |
if "index_built" not in st.session_state:
|
152 |
st.session_state["index_built"] = False
|
153 |
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
if not st.session_state["index_built"]:
|
158 |
try:
|
159 |
with st.spinner("Loading data and building index..."):
|
|
|
16 |
|
17 |
PERSIST_DIR = "./storage"
|
18 |
EMBED_MODEL = "./all-MiniLM-L6-v2"
|
|
|
|
|
19 |
LLM_MODEL = "llama3-8b-8192"
|
20 |
CSV_FILE_PATH = "shl_assessments.csv"
|
21 |
+
GROQ_API_KEY = st.secrets["GROQ_API_KEY"] or os.getenv("GROQ_API_KEY")
|
22 |
|
23 |
|
24 |
def load_data_from_csv(csv_path):
|
|
|
41 |
def load_groq_llm():
|
42 |
try:
|
43 |
api_key = st.secrets.get("GROQ_API_KEY") or os.getenv("GROQ_API_KEY")
|
|
|
44 |
except KeyError:
|
45 |
raise ValueError("GROQ_API_KEY not found in Streamlit secrets.")
|
46 |
|
|
|
49 |
|
50 |
|
51 |
def load_embeddings():
|
52 |
+
return HuggingFaceEmbedding(model_name="all-MiniLM-L6-v2")
|
|
|
53 |
|
54 |
def build_index(data):
|
55 |
"""Builds the vector index from the provided assessment data."""
|
56 |
return HuggingFaceEmbedding(model_name=EMBED_MODEL)
|
|
|
57 |
Settings.llm = load_groq_llm()
|
58 |
|
59 |
documents = [Document(text=f"Name: {item['Assessment Name']}, URL: {item['URL']}, Remote Testing: {item['Remote Testing Support']}, Adaptive/IRT: {item['Adaptive/IRT Support']}, Duration: {item['Duration (min)']}, Type: {item['Test Type']}") for item in data]
|
|
|
139 |
"role": "assistant",
|
140 |
"content": "Hello! I'm your SHL assessment assistant. How can I help you?"
|
141 |
}]
|
|
|
|
|
|
|
|
|
142 |
if "index_built" not in st.session_state:
|
143 |
st.session_state["index_built"] = False
|
144 |
|
|
|
|
|
|
|
145 |
if not st.session_state["index_built"]:
|
146 |
try:
|
147 |
with st.spinner("Loading data and building index..."):
|