| import os |
| import streamlit as st |
| import requests |
| from typing import List |
| import json |
| import socket |
| from urllib3.connection import HTTPConnection |
| from app import embed_documents, retrieve_documents |
|
|
| |
|
|
|
|
| embeddings_model_name = "all-MiniLM-L6-v2" |
| persist_directory = "db" |
| model = "tiiuae/falcon-7b-instruct" |
|
|
| from constants import CHROMA_SETTINGS |
| import chromadb |
|
|
| def list_of_collections(): |
| client = chromadb.Client(CHROMA_SETTINGS) |
| return (client.list_collections()) |
|
|
| def get_collection_names(): |
|
|
| collections = list_of_collections() |
| return [collection.name for collection in collections] |
|
|
| if __name__ == '__main__': |
| st.title("PrivateGPT App: Document Embedding and Retrieval") |
| |
| |
| st.header("Document Upload") |
| files = st.file_uploader("Upload document", accept_multiple_files=True) |
| |
| if st.button("Embed"): |
| embed_documents(files, "collection_name") |
| |
| |
| st.header("Document Retrieval") |
| collection_names = get_collection_names() |
| selected_collection = st.selectbox("Select a document", collection_names) |
| if selected_collection: |
| query = st.text_input("Query") |
| if st.button("Retrieve"): |
| retrieve_documents(query, selected_collection) |
|
|