Update streamlit_app.py
Browse files- streamlit_app.py +7 -52
streamlit_app.py
CHANGED
|
@@ -20,8 +20,13 @@ import chromadb
|
|
| 20 |
def list_of_collections():
|
| 21 |
client = chromadb.Client(CHROMA_SETTINGS)
|
| 22 |
return (client.list_collections())
|
| 23 |
-
|
| 24 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
st.title("PrivateGPT App: Document Embedding and Retrieval")
|
| 26 |
|
| 27 |
# Document upload section
|
|
@@ -39,53 +44,3 @@ def main():
|
|
| 39 |
query = st.text_input("Query")
|
| 40 |
if st.button("Retrieve"):
|
| 41 |
retrieve_documents(query, selected_collection)
|
| 42 |
-
|
| 43 |
-
# def embed_documents(files:List[st.runtime.uploaded_file_manager.UploadedFile], collection_name:str):
|
| 44 |
-
# endpoint = f"{API_BASE_URL}/embed"
|
| 45 |
-
# files_data = [("files", file) for file in files]
|
| 46 |
-
# data = {"collection_name": collection_name}
|
| 47 |
-
|
| 48 |
-
# response = requests.post(endpoint, files=files_data, data=data)
|
| 49 |
-
# if response.status_code == 200:
|
| 50 |
-
# st.success("Documents embedded successfully!")
|
| 51 |
-
# else:
|
| 52 |
-
# st.error("Document embedding failed.")
|
| 53 |
-
# st.write(response.text)
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
def get_collection_names():
|
| 57 |
-
|
| 58 |
-
collections = list_of_collections()
|
| 59 |
-
return [collection.name for collection in collections]
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
# def retrieve_documents(query: str, collection_name: str):
|
| 64 |
-
# endpoint = f"{API_BASE_URL}/retrieve"
|
| 65 |
-
# data = {"query": query, "collection_name": collection_name}
|
| 66 |
-
|
| 67 |
-
# # Modify socket options for the HTTPConnection class
|
| 68 |
-
# HTTPConnection.default_socket_options = (
|
| 69 |
-
# HTTPConnection.default_socket_options + [
|
| 70 |
-
# (socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
|
| 71 |
-
# (socket.SOL_TCP, socket.TCP_KEEPIDLE, 45),
|
| 72 |
-
# (socket.SOL_TCP, socket.TCP_KEEPINTVL, 10),
|
| 73 |
-
# (socket.SOL_TCP, socket.TCP_KEEPCNT, 6)
|
| 74 |
-
# ]
|
| 75 |
-
# )
|
| 76 |
-
|
| 77 |
-
# response = requests.post(endpoint, params=data)
|
| 78 |
-
# if response.status_code == 200:
|
| 79 |
-
# result = response.json()
|
| 80 |
-
# st.subheader("Results")
|
| 81 |
-
# st.text(result["results"])
|
| 82 |
-
|
| 83 |
-
# st.subheader("Documents")
|
| 84 |
-
# for doc in result["docs"]:
|
| 85 |
-
# st.text(doc)
|
| 86 |
-
# else:
|
| 87 |
-
# st.error("Failed to retrieve documents.")
|
| 88 |
-
# st.write(response.text)
|
| 89 |
-
|
| 90 |
-
if __name__ == '__main__':
|
| 91 |
-
main()
|
|
|
|
| 20 |
def list_of_collections():
|
| 21 |
client = chromadb.Client(CHROMA_SETTINGS)
|
| 22 |
return (client.list_collections())
|
| 23 |
+
|
| 24 |
+
def get_collection_names():
|
| 25 |
+
|
| 26 |
+
collections = list_of_collections()
|
| 27 |
+
return [collection.name for collection in collections]
|
| 28 |
+
|
| 29 |
+
if __name__ == '__main__':
|
| 30 |
st.title("PrivateGPT App: Document Embedding and Retrieval")
|
| 31 |
|
| 32 |
# Document upload section
|
|
|
|
| 44 |
query = st.text_input("Query")
|
| 45 |
if st.button("Retrieve"):
|
| 46 |
retrieve_documents(query, selected_collection)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|