dammy commited on
Commit
065d9fd
·
1 Parent(s): e4c0c14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -18
app.py CHANGED
@@ -44,34 +44,34 @@ def local_query(query, context):
44
 
45
  def run_query(btn, history, query):
46
 
47
- # file_name = btn.name
48
 
49
- # loader = PDFMinerLoader(file_name)
50
- # doc = loader.load()
51
 
52
- # text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
53
- # texts = text_splitter.split_documents(doc)
54
 
55
- # texts = [i.page_content for i in texts]
56
 
57
- # doc_emb = st_model.encode(texts)
58
- # doc_emb = doc_emb.tolist()
59
 
60
- # ids = [str(uuid.uuid1()) for _ in doc_emb]
61
 
62
- # client = chromadb.Client()
63
- # collection = client.create_collection("test_db")
64
 
65
- # collection.add(
66
- # embeddings=doc_emb,
67
- # documents=texts,
68
- # ids=ids
69
- # )
70
 
71
 
72
 
73
- # context = get_context(query, collection)
74
- context = 'My name is damla'
75
 
76
  print('calling local query')
77
  result = local_query(query, context)
 
44
 
45
  def run_query(btn, history, query):
46
 
47
+ file_name = btn.name
48
 
49
+ loader = PDFMinerLoader(file_name)
50
+ doc = loader.load()
51
 
52
+ text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
53
+ texts = text_splitter.split_documents(doc)
54
 
55
+ texts = [i.page_content for i in texts]
56
 
57
+ doc_emb = st_model.encode(texts)
58
+ doc_emb = doc_emb.tolist()
59
 
60
+ ids = [str(uuid.uuid1()) for _ in doc_emb]
61
 
62
+ client = chromadb.Client()
63
+ collection = client.create_collection("test_db")
64
 
65
+ collection.add(
66
+ embeddings=doc_emb,
67
+ documents=texts,
68
+ ids=ids
69
+ )
70
 
71
 
72
 
73
+ context = get_context(query, collection)
74
+ # context = 'My name is damla'
75
 
76
  print('calling local query')
77
  result = local_query(query, context)