With latest write csv
Browse files
app.py
CHANGED
@@ -133,20 +133,34 @@ def write_log(query,url, score, ans, ts):
|
|
133 |
return
|
134 |
|
135 |
logfile='querylog.csv'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
try:
|
137 |
-
df_log = pd.read_csv("hf://datasets/sujitb/data/querylog.csv", encoding="utf-8")
|
138 |
except:
|
139 |
df_log=pd.DataFrame(columns=['query','url','score','ans', 'ts'])
|
140 |
|
141 |
st.title('CLLM Answering Machine')
|
142 |
with st.sidebar:
|
143 |
-
|
144 |
-
st.
|
145 |
-
|
146 |
-
|
|
|
147 |
st.write(q)
|
148 |
|
149 |
-
|
150 |
# Initialize chat history
|
151 |
if "messages" not in st.session_state:
|
152 |
st.session_state.messages = []
|
@@ -156,6 +170,7 @@ for message in st.session_state.messages:
|
|
156 |
st.markdown(message["content"])
|
157 |
|
158 |
|
|
|
159 |
QUESTION = st.chat_input('Ask a question -e.g How to prepare for Verbal section for CAT?')
|
160 |
|
161 |
|
@@ -261,10 +276,12 @@ if QUESTION:
|
|
261 |
|
262 |
now= str(datetime.utcnow())
|
263 |
url = top_2[0]['url'] + ' ; '+top_2[1]['url']
|
|
|
264 |
df_log.loc[len(df_log)]=[QUESTION,url,score,ans,now]
|
265 |
-
write_log(QUESTION,url, score, ans, now)
|
266 |
#df.to_csv("hf://datasets/sujitb/data/test.csv")
|
267 |
-
|
|
|
268 |
|
269 |
else: ## Zero response from pinecone query
|
270 |
#st.write("No matches for query")
|
@@ -275,5 +292,6 @@ if QUESTION:
|
|
275 |
|
276 |
now= str(datetime.utcnow())
|
277 |
df_log.loc[len(df_log)]=[QUESTION,'No match',0,'-',now]
|
278 |
-
|
279 |
-
|
|
|
|
133 |
return
|
134 |
|
135 |
logfile='querylog.csv'
|
136 |
+
|
137 |
+
qlist=[
|
138 |
+
'What are the best books for VARC in CAT?',
|
139 |
+
'What is the XAT exam pattern? How many sections ? How many questions?',
|
140 |
+
'I want to know about Personalized coaching for IGSE/IB ',
|
141 |
+
'Which IIMs accept admissions under the IPM exam?',
|
142 |
+
'What topics are covered under CAT exam syllabus?',
|
143 |
+
'For CAT preparation which is better - online classes or classroom program?',
|
144 |
+
'What programs are offered under CUET exam by Central University of Jharkhand?',
|
145 |
+
'What is the pattern of the IPM exam?',
|
146 |
+
'When is the CAT 2024 exam going to be held?',
|
147 |
+
'What are program benefits of the MBA 2024 Online Classes?'
|
148 |
+
]
|
149 |
+
|
150 |
try:
|
151 |
+
df_log = pd.read_csv("hf://datasets/sujitb/data/querylog.csv", encoding="utf-8", index_col=0)
|
152 |
except:
|
153 |
df_log=pd.DataFrame(columns=['query','url','score','ans', 'ts'])
|
154 |
|
155 |
st.title('CLLM Answering Machine')
|
156 |
with st.sidebar:
|
157 |
+
dispstr= 'Search History '+str(len(df_log))
|
158 |
+
st.markdown('*{}*'.format(dispstr))
|
159 |
+
#st.write('Past Queries')
|
160 |
+
qlist = df_log.tail(10)['query'].tolist()
|
161 |
+
for q in qlist[::-1]:
|
162 |
st.write(q)
|
163 |
|
|
|
164 |
# Initialize chat history
|
165 |
if "messages" not in st.session_state:
|
166 |
st.session_state.messages = []
|
|
|
170 |
st.markdown(message["content"])
|
171 |
|
172 |
|
173 |
+
|
174 |
QUESTION = st.chat_input('Ask a question -e.g How to prepare for Verbal section for CAT?')
|
175 |
|
176 |
|
|
|
276 |
|
277 |
now= str(datetime.utcnow())
|
278 |
url = top_2[0]['url'] + ' ; '+top_2[1]['url']
|
279 |
+
|
280 |
df_log.loc[len(df_log)]=[QUESTION,url,score,ans,now]
|
281 |
+
#write_log(QUESTION,url, score, ans, now)
|
282 |
#df.to_csv("hf://datasets/sujitb/data/test.csv")
|
283 |
+
storage_options={"token":token}
|
284 |
+
df_log.to_csv("hf://datasets/sujitb/data/"+logfile,storage_options= storage_options)
|
285 |
|
286 |
else: ## Zero response from pinecone query
|
287 |
#st.write("No matches for query")
|
|
|
292 |
|
293 |
now= str(datetime.utcnow())
|
294 |
df_log.loc[len(df_log)]=[QUESTION,'No match',0,'-',now]
|
295 |
+
storage_options={"token":token}
|
296 |
+
df_log.to_csv("hf://datasets/sujitb/data/"+logfile,storage_options= storage_options)
|
297 |
+
#write_log(QUESTION,'No match', 0, '-', now)
|