Kushwanth Chowday Kandala commited on
Commit
dcb00f7
1 Parent(s): a37e99b

top 5 result display in json

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -3,6 +3,7 @@ import os
3
  from streamlit_chat import message
4
  import numpy as np
5
  import pandas as pd
 
6
 
7
  # st.config(PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION="python")
8
 
@@ -81,11 +82,16 @@ def chat_actions():
81
  {"role": "user", "content": st.session_state["chat_input"]},
82
  )
83
 
84
- response = model.encode(st.session_state["chat_input"])
 
 
 
 
 
85
  st.session_state["chat_history"].append(
86
  {
87
  "role": "assistant",
88
- "content": pd.DataFrame(response),
89
  }, # This can be replaced with your chat response logic
90
  )
91
 
 
3
  from streamlit_chat import message
4
  import numpy as np
5
  import pandas as pd
6
+ import json
7
 
8
  # st.config(PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION="python")
9
 
 
82
  {"role": "user", "content": st.session_state["chat_input"]},
83
  )
84
 
85
+ query_embedding = model.encode(st.session_state["chat_input"])
86
+ # create the query vector
87
+ query_vector = model.encode(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
  st.session_state["chat_history"].append(
92
  {
93
  "role": "assistant",
94
+ "content": json.dumps(result, indent=4),
95
  }, # This can be replaced with your chat response logic
96
  )
97