Spaces:
Sleeping
Sleeping
Merge pull request #3 from Janarthanam/streamlit
Browse files- README.md +1 -1
- api/routes/search.py +2 -1
- fe/app.py +7 -4
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title:
|
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, "
|
|
|
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 |
-
|
20 |
-
timeout=5000 )
|
|
|
21 |
|
22 |
-
|
23 |
-
|
|
|
|
|
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!")
|