Kushwanth Chowday Kandala commited on
Commit
a969331
1 Parent(s): c6c7741

updated the top5 reponses in sidebar

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -87,19 +87,29 @@ def chat_actions():
87
  query_vector = query_embedding.tolist()
88
  # now query vector database
89
  result = index.query(query_vector, top_k=5, include_metadata=True) # xc is a list of tuples
 
 
 
 
 
 
 
 
 
 
 
90
  with st.sidebar:
91
- st.text(result["matches"])
92
 
93
  for res in result['matches']:
94
  st.session_state["chat_history"].append(
95
  {
96
  "role": "assistant",
97
- "content": f"{round(res['score'],2)}: {res['metadata']['text']}",
98
  }, # This can be replaced with your chat response logic
99
  )
100
  break;
101
 
102
-
103
  if "chat_history" not in st.session_state:
104
  st.session_state["chat_history"] = []
105
 
 
87
  query_vector = query_embedding.tolist()
88
  # now query vector database
89
  result = index.query(query_vector, top_k=5, include_metadata=True) # xc is a list of tuples
90
+
91
+ # Create a list of lists
92
+ data = []
93
+ i = 0
94
+ for res in result['matches']
95
+ i = i + 1
96
+ data.append([f"{i}⭐", res['score'], res['metadata']['text']])
97
+
98
+ # Create a DataFrame from the list of lists
99
+ resdf = pd.DataFrame(data, columns=['TopRank', 'Score', 'Text'])
100
+
101
  with st.sidebar:
102
+ st.dataframe(result["matches"])
103
 
104
  for res in result['matches']:
105
  st.session_state["chat_history"].append(
106
  {
107
  "role": "assistant",
108
+ "content": f"{res['metadata']['text']}",
109
  }, # This can be replaced with your chat response logic
110
  )
111
  break;
112
 
 
113
  if "chat_history" not in st.session_state:
114
  st.session_state["chat_history"] = []
115