|
import streamlit as st |
|
import os |
|
import sys |
|
from dotenv import load_dotenv |
|
|
|
from task6_model_deployment.scripts.query_engine import index_connection, initialize_retriever, index_retrieval, load_config |
|
|
|
load_dotenv() |
|
|
|
|
|
script_dir = os.path.dirname(os.path.abspath(__file__)) |
|
base_dir = os.path.dirname(script_dir) |
|
print(base_dir) |
|
scripts_dir = os.path.join(base_dir, 'scripts') |
|
logo_path = os.path.join(base_dir,'TorontoCanadaChapter_CanPolicyInsight', 'task6_model_deployment', 'assets', 'logo.png') |
|
sys.path.append(scripts_dir) |
|
|
|
|
|
|
|
|
|
def main(): |
|
|
|
col1, col2 = st.columns([1, 5]) |
|
|
|
|
|
with col1: |
|
if os.path.exists(logo_path): |
|
st.image(logo_path, width=80) |
|
else: |
|
st.error(f"Logo not found at: {logo_path}") |
|
|
|
|
|
with col2: |
|
st.title("Canada Policy Explorer") |
|
|
|
|
|
config_path = os.path.join(base_dir,'TorontoCanadaChapter_CanPolicyInsight','task6_model_deployment','configs','config.yaml') |
|
config = load_config(config_path) |
|
pinecone_index = index_connection(config_path) |
|
retriever = initialize_retriever(pinecone_index) |
|
st.write("Welcome to the Canada Policy Navigator. Explore policy insights and more.") |
|
|
|
query_text = st.text_input("Enter your query:", "") |
|
|
|
if st.button("Submit"): |
|
if query_text: |
|
response = index_retrieval(retriever, query_text) |
|
st.write(response.response) |
|
else: |
|
st.warning("Please enter a query.") |
|
|
|
if __name__ == "__main__": |
|
main() |
|
|