LordFarquaad42 commited on
Commit
5914582
1 Parent(s): 52e6e50

added database interaction

Browse files
Files changed (1) hide show
  1. app.py +29 -4
app.py CHANGED
@@ -1,7 +1,32 @@
1
  import streamlit as st
 
 
 
2
 
3
- NAME = "Groove-GPT"
4
- st.title(NAME)
 
 
 
 
 
 
 
 
5
 
6
- user_question = st.text_area("Enter your groovy questions here")
7
- access_key = st.text_input("Enter your gpt key here", type="password")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import chromadb
3
+ from chromadb.utils import embedding_functions
4
+ from sentence_transformers import SentenceTransformer
5
 
6
+ client = chromadb.PersistentClient(path="./chromadb/")
7
+ MODEL_NAME: str = "mixedbread-ai/mxbai-embed-large-v1" # ~ 0.5 gb
8
+ COLLECTION_NAME: str = "scheme"
9
+ EMBEDDING_FUNC = embedding_functions.SentenceTransformerEmbeddingFunction(model_name=MODEL_NAME)
10
+ schemer = client.get_collection(
11
+ name=COLLECTION_NAME,
12
+ embedding_function=EMBEDDING_FUNC,
13
+ )
14
+ DATA_AVAL: bool = schemer.count() > 0
15
+ APP_NAME: str = "Groove-GPT"
16
 
17
+ st.title(APP_NAME)
18
+
19
+ user_question: str = st.text_area("Enter your groovy questions here")
20
+ access_key: str = st.text_input("Enter your gpt key here", type="password")
21
+
22
+ if (user_question == ""):
23
+ st.stop()
24
+ else:
25
+ st.header("Results")
26
+ # Perform the Chromadb query.
27
+ results = schemer.query(
28
+ query_texts=[user_question],
29
+ n_results=10,
30
+ include = ['documents']
31
+ )
32
+ st.write(results)