Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,12 @@ from pathlib import Path
|
|
8 |
from calendar_rag import (
|
9 |
create_default_config,
|
10 |
AcademicCalendarRAG,
|
11 |
-
PipelineConfig
|
|
|
|
|
|
|
|
|
|
|
12 |
)
|
13 |
# Custom CSS for enhanced styling
|
14 |
def load_custom_css():
|
@@ -88,28 +93,18 @@ def load_custom_css():
|
|
88 |
</style>
|
89 |
""", unsafe_allow_html=True)
|
90 |
|
|
|
91 |
def initialize_pipeline():
|
92 |
"""Initialize RAG pipeline with enhanced configurations"""
|
93 |
try:
|
94 |
openai_api_key = os.getenv('OPENAI_API_KEY') or st.secrets['OPENAI_API_KEY']
|
95 |
|
96 |
-
# Create
|
97 |
-
config =
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
temperature=0.3
|
103 |
-
),
|
104 |
-
retriever=RetrieverConfig(top_k=5),
|
105 |
-
cache=CacheConfig(
|
106 |
-
enabled=True,
|
107 |
-
cache_dir=Path("./cache"),
|
108 |
-
ttl=86400
|
109 |
-
),
|
110 |
-
processing=ProcessingConfig(batch_size=32),
|
111 |
-
localization=LocalizationConfig(enable_thai_normalization=True)
|
112 |
-
)
|
113 |
|
114 |
pipeline = AcademicCalendarRAG(config)
|
115 |
|
|
|
8 |
from calendar_rag import (
|
9 |
create_default_config,
|
10 |
AcademicCalendarRAG,
|
11 |
+
PipelineConfig,
|
12 |
+
ModelConfig, # Import ModelConfig
|
13 |
+
RetrieverConfig, # Import RetrieverConfig
|
14 |
+
CacheConfig, # Import CacheConfig
|
15 |
+
ProcessingConfig, # Import ProcessingConfig
|
16 |
+
LocalizationConfig # Import LocalizationConfig
|
17 |
)
|
18 |
# Custom CSS for enhanced styling
|
19 |
def load_custom_css():
|
|
|
93 |
</style>
|
94 |
""", unsafe_allow_html=True)
|
95 |
|
96 |
+
|
97 |
def initialize_pipeline():
|
98 |
"""Initialize RAG pipeline with enhanced configurations"""
|
99 |
try:
|
100 |
openai_api_key = os.getenv('OPENAI_API_KEY') or st.secrets['OPENAI_API_KEY']
|
101 |
|
102 |
+
# Create configuration using create_default_config
|
103 |
+
config = create_default_config(openai_api_key)
|
104 |
+
|
105 |
+
# Customize any specific settings if needed
|
106 |
+
config.model.embedder_model = "sentence-transformers/paraphrase-multilingual-mpnet-base-v2"
|
107 |
+
config.model.openai_model = "gpt-4o"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
pipeline = AcademicCalendarRAG(config)
|
110 |
|