Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from typing import List, Dict, Any, Optional
|
| 3 |
import asyncio
|
|
@@ -102,7 +103,8 @@ def initialize_components():
|
|
| 102 |
question_gen = QuestionGenerator(config.gemini_api_key)
|
| 103 |
rag = GeminiRAG(config.gemini_api_key)
|
| 104 |
user_manager = UserManager(config.user_data_file)
|
| 105 |
-
|
|
|
|
| 106 |
except Exception as e:
|
| 107 |
st.error(f"Error initializing components: {str(e)}")
|
| 108 |
raise e
|
|
@@ -111,16 +113,7 @@ def load_initial_database():
|
|
| 111 |
"""Load the default database"""
|
| 112 |
if not st.session_state.initialized:
|
| 113 |
try:
|
| 114 |
-
config, logger, question_gen, rag, user_manager = initialize_components()
|
| 115 |
-
|
| 116 |
-
db = ProductDatabase(config)
|
| 117 |
-
# Here, you would process your markdown files to create the database
|
| 118 |
-
# Replace 'path/to/your/markdown/files' with the actual path
|
| 119 |
-
for filename in os.listdir("blogs"):
|
| 120 |
-
if filename.endswith(".md"):
|
| 121 |
-
with open(os.path.join("blogs", filename), "r", encoding="utf-8") as f:
|
| 122 |
-
markdown_content = f.read()
|
| 123 |
-
db.process_markdown(markdown_content)
|
| 124 |
|
| 125 |
st.session_state.db = db
|
| 126 |
st.session_state.config = config
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
import streamlit as st
|
| 3 |
from typing import List, Dict, Any, Optional
|
| 4 |
import asyncio
|
|
|
|
| 103 |
question_gen = QuestionGenerator(config.gemini_api_key)
|
| 104 |
rag = GeminiRAG(config.gemini_api_key)
|
| 105 |
user_manager = UserManager(config.user_data_file)
|
| 106 |
+
db = ProductDatabase(config) # Initialize the database here
|
| 107 |
+
return config, logger, question_gen, rag, user_manager, db
|
| 108 |
except Exception as e:
|
| 109 |
st.error(f"Error initializing components: {str(e)}")
|
| 110 |
raise e
|
|
|
|
| 113 |
"""Load the default database"""
|
| 114 |
if not st.session_state.initialized:
|
| 115 |
try:
|
| 116 |
+
config, logger, question_gen, rag, user_manager, db = initialize_components()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
st.session_state.db = db
|
| 119 |
st.session_state.config = config
|