Spaces:
Sleeping
Sleeping
Update excel_chat.py
Browse files- excel_chat.py +9 -6
excel_chat.py
CHANGED
@@ -234,14 +234,17 @@ def chat_with_mistral(source_cols, dest_col, prompt, excel_file, url, search_col
|
|
234 |
print(f"{cpt}/{len(filtred_df)}\nQUERY:\n{prompt[0]}\nCONTENT:\n{concatenated_content[:200]}...\n\nANSWER:\n{llm_answer}")
|
235 |
df.at[index, dest_col] = llm_answer
|
236 |
|
237 |
-
|
238 |
-
df.to_excel("checkpointfile", index=False)
|
239 |
-
|
240 |
-
checkpoint += 50
|
241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
|
243 |
cpt += 1
|
244 |
-
# progress((index+1)/len(df),desc=f'Request {index+1}/{len(df)}')
|
245 |
|
246 |
df.to_excel(file_name, index=False)
|
247 |
|
@@ -253,7 +256,7 @@ def chat_with_mistral(source_cols, dest_col, prompt, excel_file, url, search_col
|
|
253 |
with zipfile.ZipFile(zip_file_path, 'w') as zipf:
|
254 |
zipf.write(conf_file_path, os.path.basename(conf_file_path))
|
255 |
|
256 |
-
return file_name, df.head(5), new_prompts, new_keywords, new_user, zip_file_path, "
|
257 |
|
258 |
|
259 |
def get_columns(file,progress=gr.Progress()):
|
|
|
234 |
print(f"{cpt}/{len(filtred_df)}\nQUERY:\n{prompt[0]}\nCONTENT:\n{concatenated_content[:200]}...\n\nANSWER:\n{llm_answer}")
|
235 |
df.at[index, dest_col] = llm_answer
|
236 |
|
237 |
+
try:
|
|
|
|
|
|
|
238 |
|
239 |
+
if cpt == checkpoint:
|
240 |
+
df.to_excel("checkpointfile", index=False)
|
241 |
+
|
242 |
+
checkpoint += 50
|
243 |
+
except Exception:
|
244 |
+
print("no checkpoint")
|
245 |
|
246 |
cpt += 1
|
247 |
+
# progress((index+1)/len(df),desc=f'Request {index+1}/{len(df)}!')
|
248 |
|
249 |
df.to_excel(file_name, index=False)
|
250 |
|
|
|
256 |
with zipfile.ZipFile(zip_file_path, 'w') as zipf:
|
257 |
zipf.write(conf_file_path, os.path.basename(conf_file_path))
|
258 |
|
259 |
+
return file_name, df.head(5), new_prompts, new_keywords, new_user, zip_file_path, "checkpointfile"
|
260 |
|
261 |
|
262 |
def get_columns(file,progress=gr.Progress()):
|