Spaces:
Running
Running
Update src/app.py
Browse filesadded support structure for new embedding scheme
- src/app.py +32 -8
src/app.py
CHANGED
|
@@ -202,19 +202,43 @@ with st.sidebar:
|
|
| 202 |
|
| 203 |
# 2. SAFETY CHECK VISUAL
|
| 204 |
if selected_index:
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
|
| 211 |
# 3. CREATE NEW INDEX
|
| 212 |
with st.expander("Create New Index"):
|
| 213 |
new_idx_name = st.text_input("Index Name")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
if st.button("Create"):
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
else:
|
| 219 |
st.warning("No Pinecone Key Found")
|
| 220 |
|
|
|
|
| 202 |
|
| 203 |
# 2. SAFETY CHECK VISUAL
|
| 204 |
if selected_index:
|
| 205 |
+
# Get current model dimension dynamically
|
| 206 |
+
# (We import get_embedding_func to check the active model)
|
| 207 |
+
try:
|
| 208 |
+
emb_fn = rag_engine.get_embedding_func()
|
| 209 |
+
test_vec = emb_fn.embed_query("test")
|
| 210 |
+
active_model_dim = len(test_vec)
|
| 211 |
+
|
| 212 |
+
is_compatible = pm.check_dimension_compatibility(selected_index, active_model_dim)
|
| 213 |
+
if is_compatible:
|
| 214 |
+
st.caption(f"✅ Compatible with Model ({active_model_dim}d)")
|
| 215 |
+
else:
|
| 216 |
+
st.error(f"❌ Mismatch! Model is {active_model_dim}d, Index is not.")
|
| 217 |
+
except Exception as e:
|
| 218 |
+
st.caption(f"⚠️ Could not verify dims: {e}")
|
| 219 |
|
| 220 |
# 3. CREATE NEW INDEX
|
| 221 |
with st.expander("Create New Index"):
|
| 222 |
new_idx_name = st.text_input("Index Name")
|
| 223 |
+
|
| 224 |
+
# NEW: Dimension Selector
|
| 225 |
+
new_idx_dim = st.selectbox(
|
| 226 |
+
"Vector Dimension",
|
| 227 |
+
[384, 768, 1024, 1536, 3072],
|
| 228 |
+
index=0, # Defaults to 384
|
| 229 |
+
help="384=All-MiniLM, 768=MPNet/Nomic, 1536=OpenAI-Small, 3072=OpenAI-Large"
|
| 230 |
+
)
|
| 231 |
+
|
| 232 |
if st.button("Create"):
|
| 233 |
+
with st.spinner("Provisioning Cloud Index..."):
|
| 234 |
+
# We pass the selected dimension to the manager
|
| 235 |
+
ok, msg = pm.create_index(new_idx_name, dimension=new_idx_dim)
|
| 236 |
+
if ok:
|
| 237 |
+
st.success(msg)
|
| 238 |
+
time.sleep(2) # Give Pinecone a moment to propagate
|
| 239 |
+
st.rerun()
|
| 240 |
+
else:
|
| 241 |
+
st.error(msg)
|
| 242 |
else:
|
| 243 |
st.warning("No Pinecone Key Found")
|
| 244 |
|