janar commited on
Commit
9efcf1c
β€’
2 Parent(s): b63c216 413848c

Merge pull request #3 from Janarthanam/streamlit

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. api/routes/search.py +2 -1
  3. fe/app.py +7 -4
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Toypdf
3
  emoji: πŸ“‰
4
  colorFrom: blue
5
  colorTo: red
 
1
  ---
2
+ title: retrieval_aug_llm
3
  emoji: πŸ“‰
4
  colorFrom: blue
5
  colorTo: red
api/routes/search.py CHANGED
@@ -30,7 +30,8 @@ async def answer(name: str, query: str):
30
  docs = _db.similarity_search_with_score(query=query)
31
  print(docs)
32
  answer = _chain.run(input_documents=[tup[0] for tup in docs], question=query)
33
- return JSONResponse(status_code=200, content={"answer": answer, "file_score": [[f"{d[0].metadata['file']} : {d[0].metadata['page']}", d[1]] for d in docs]})
 
34
 
35
 
36
  @router.get("/v1/datasets")
 
30
  docs = _db.similarity_search_with_score(query=query)
31
  print(docs)
32
  answer = _chain.run(input_documents=[tup[0] for tup in docs], question=query)
33
+ return JSONResponse(status_code=200, content={"answer": answer, "metadata": [
34
+ {"file": d[0].metadata['file'], "page" : d[0].metadata['page'], "score": d[1]} for d in docs]})
35
 
36
 
37
  @router.get("/v1/datasets")
fe/app.py CHANGED
@@ -16,10 +16,13 @@ if ds:
16
  query = st.text_input("Enter your search query",
17
  placeholder="Ask your question")
18
  if query:
19
- answer = requests.get(f"http://localhost:8080/v1/datasets/{ds}/answer?query={query}",
20
- timeout=5000 )
 
21
 
22
- print(answer.json()["answer"])
23
- st.write(answer.json()["answer"])
 
 
24
  else:
25
  st.write("Choose your dataset!")
 
16
  query = st.text_input("Enter your search query",
17
  placeholder="Ask your question")
18
  if query:
19
+ res = requests.get(f"{BE}/v1/datasets/{ds}/answer?query={query}",
20
+ timeout=5000 ).json()
21
+ answer = res["answer"]
22
 
23
+ st.write(answer)
24
+ files = [f"{f['file']}, page {f['page']}" for f in res["metadata"]]
25
+ for fi in files:
26
+ st.markdown(f"- {fi}")
27
  else:
28
  st.write("Choose your dataset!")