File size: 2,460 Bytes
ac2020e
 
 
 
 
eeef8f5
ac2020e
 
 
 
 
 
eeef8f5
 
c75f2fc
 
 
ac2020e
eeef8f5
 
 
ac2020e
c75f2fc
eeef8f5
c75f2fc
eeef8f5
 
 
ac2020e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Sidebar components for LegisQA"""

import streamlit as st
import os
from legisqa_local.config.settings import get_chroma_config
from legisqa_local.core.vectorstore import get_vectorstore


def render_chromadb_status():
    """Render ChromaDB status in sidebar"""
    st.subheader("๐Ÿ—„๏ธ Vector Database")
    
    vectorstore = get_vectorstore()
    if vectorstore is not None:
        # Use cached count from session state to avoid network calls on every rerun
        count = st.session_state.get("vectorstore_count")
        if count is not None:
            st.success("โœ… ChromaDB Ready")
            st.caption(f"๐Ÿ“Š {count:,} documents loaded")
            
            config = get_chroma_config()
            st.caption(f"๐Ÿ“ Collection: {config['collection_name']}")
        else:
            st.warning("โš ๏ธ ChromaDB Loaded (verification failed)")
            st.caption("Could not retrieve document count")
    else:
        st.info("โณ ChromaDB Loading...")
        st.caption("Vectorstore is being initialized")


def render_outreach_links():
    """Render links to external resources"""
    nomic_base_url = "https://atlas.nomic.ai/data/gabrielhyperdemocracy"
    nomic_map_name = "us-congressional-legislation-s1024o256nomic-1"
    nomic_url = f"{nomic_base_url}/{nomic_map_name}/map"
    hf_url = "https://huggingface.co/hyperdemocracy"
    chroma_url = "https://www.trychroma.com/"
    together_url = "https://www.together.ai/"
    google_gemini_url = "https://ai.google.dev/gemini-api"
    anthropic_url = "https://www.anthropic.com/api"
    openai_url = "https://platform.openai.com/docs/overview"
    langchain_url = "https://www.langchain.com/"
    
    st.subheader(f":world_map: Visualize [nomic atlas]({nomic_url})")
    st.subheader(f":hugging_face: Raw [huggingface datasets]({hf_url})")
    st.subheader(f":card_file_box: Vector DB [chromadb]({chroma_url})")
    st.subheader(f":pancakes: Inference [together.ai]({together_url})")
    st.subheader(f":eyeglasses: Inference [google-gemini]({google_gemini_url})")
    st.subheader(f":hut: Inference [anthropic]({anthropic_url})")
    st.subheader(f":sparkles: Inference [openai]({openai_url})")
    st.subheader(f":parrot: Orchestration [langchain]({langchain_url})")


def render_sidebar():
    """Render the complete sidebar"""
    with st.container(border=True):
        render_chromadb_status()
    
    with st.container(border=True):
        render_outreach_links()