Skip to content

Commit

Permalink
better chat interface, added answer generation bot and fixed previous…
Browse files Browse the repository at this point in the history
…ly mysteriously deleted files
  • Loading branch information
SubhadityaMukherjee committed Aug 23, 2024
1 parent d8a19ab commit 52042bc
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion backend/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"search_type" : "similarity",
"reranking" : false,
"long_context_reorder" : false,
"structured_query": false,
"structured_query": true,
"use_chroma_for_saving_metadata": false,
"chunk_size": 1000,
"chroma_metadata_dir": "../data/chroma_db_metadata"
Expand Down
2 changes: 1 addition & 1 deletion structured_query/chroma_store_utilis.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ def load_chroma_metadata():
if collec.get(ids=ids) == []:
collec.add(ids=ids, documents=documents, metadatas=metadatas)

return collec
return collec
26 changes: 20 additions & 6 deletions structured_query/llm_service_structured_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@

app = FastAPI()

print("[INFO] Starting structured query service.")
try:
print("[INFO] Sending first query to structured query llm to avoid cold start.")

query = "mushroom data with 2 classess"
response = chain.invoke({"query": query})
obj = ChromaTranslator()
filter_condition = obj.visit_structured_query(structured_query=response)[1]
print(response, filter_condition)

except Exception as e:
print("Error in first query: ", e)


# Create port
Expand All @@ -33,10 +43,14 @@ async def get_structured_query(query: str):
query = query.replace("%20", " ")
response = chain.invoke({"query": query})
print(response)
# obj = ChromaTranslator()
# filter_condition = obj.visit_structured_query(structured_query=response)[1]
return JSONResponse(content=str(response))
obj = ChromaTranslator()
filter_condition = obj.visit_structured_query(structured_query=response)[1]

except Exception as e:
print(f"An error occurred: {e}")
raise HTTPException(status_code=500, detail=f"An error occurred: {e}")
print(f"An error occurred: ", HTTPException(status_code=500, detail=f"An error occurred: {e}"))

return response, filter_condition




2 changes: 1 addition & 1 deletion structured_query/llm_service_structured_query_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def create_query_structuring_chain(
fix_invalid=True,
)

return chain
return chain
2 changes: 1 addition & 1 deletion structured_query/structuring_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@
def structuring_query(query: str):
structured_query = chain.invoke(query)

return structured_query.query, structured_query.filter
return structured_query.query, structured_query.filter

0 comments on commit 52042bc

Please sign in to comment.