File size: 1,102 Bytes
25fc3a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from csv_loader import CSVLoader
from embedding_generator import EmbeddingGenerator
from chroma_db_indexer import ChromaDBIndexer
from question_answerer import QuestionAnswerer
from answer_presenter import AnswerPresenter

def main():
    st.title("TAPAS LLM Application")
    
    csv_loader = CSVLoader()
    embedding_generator = EmbeddingGenerator()
    chroma_db_indexer = ChromaDBIndexer()
    question_answerer = QuestionAnswerer()
    answer_presenter = AnswerPresenter()
    
    uploaded_files = st.file_uploader("Upload CSV", type='csv', accept_multiple_files=True)
    if uploaded_files:
        dataframes = csv_loader.load_csvs(uploaded_files)
        embeddings = embedding_generator.generate_embeddings(dataframes)
        chroma_db_indexer.create_index(embeddings)
        
        query = st.text_input("Enter your question")
        if query:
            table = question_answerer.query_table(query)
            answer = question_answerer.answer_question(query, table)
            answer_presenter.present_answer(answer)

if __name__ == "__main__":
    main()