import sys import toml from omegaconf import OmegaConf from query import VectaraQuery import os import streamlit as st from PIL import Image from functools import partial def set_query(q: str): st.session_state['query'] = q def launch_bot(): def get_answer(question): response = vq.submit_query(question) return response corpus_ids = list(eval(os.environ['corpus_ids'])) questions = list(eval(os.environ['examples'])) cfg = OmegaConf.create({ 'customer_id': os.environ['customer_id'], 'corpus_ids': corpus_ids, 'api_key': os.environ['api_key'], 'title': os.environ['title'], 'description': os.environ['description'], 'examples': questions, 'source_data_desc': os.environ['source_data_desc'] }) vq = VectaraQuery(cfg.api_key, cfg.customer_id, cfg.corpus_ids) st.set_page_config(page_title=cfg.title, layout="wide") # left side content with st.sidebar: image = Image.open('Vectara-logo.png') st.markdown(f"## Welcome to {cfg.title}\n\n" f"With this demo uses Retieval Augmented Generation to ask questions about {cfg.source_data_desc}\n\n") st.markdown("---") st.markdown( "## How this works?\n" "This app was built with [Vectara](https://vectara.com).\n" "Vectara's [Indexing API](https://docs.vectara.com/docs/api-reference/indexing-apis/indexing) was used to ingest the data into a Vectara corpus (or index).\n\n" "This app uses Vectara API to query the corpus and present the results to you, answering your question.\n\n" ) st.markdown("---") st.image(image, width=250) st.markdown(f"