Spaces:
Sleeping
Sleeping
Update excel_chat.py
Browse files- excel_chat.py +3 -4
excel_chat.py
CHANGED
@@ -85,7 +85,7 @@ def filter_df(df, column_name, keywords):
|
|
85 |
filtered_df = df
|
86 |
return filtered_df
|
87 |
|
88 |
-
def chat_with_mistral(source_cols, dest_col, prompt, excel_file, url, search_col, keywords, client, user):
|
89 |
new_prompts, new_keywords, new_user, conf_file_path = update_json(user, prompt, keywords)
|
90 |
print(f'xlsxfile = {excel_file}')
|
91 |
df = pd.read_excel(excel_file)
|
@@ -103,12 +103,11 @@ def chat_with_mistral(source_cols, dest_col, prompt, excel_file, url, search_col
|
|
103 |
|
104 |
for index, row in filtred_df.iterrows():
|
105 |
concatenated_content = "\n\n".join(f"{column_name}: {str(row[column_name])}" for column_name in source_cols)
|
106 |
-
print('test')
|
107 |
if not concatenated_content == "\n\n".join(f"{column_name}: nan" for column_name in source_cols):
|
108 |
-
print('c bon')
|
109 |
llm_answer = ask_llm(prompt[0], concatenated_content, client, user)
|
110 |
-
print(f"
|
111 |
df.at[index, dest_col] = llm_answer
|
|
|
112 |
|
113 |
df.to_excel(file_name, index=False)
|
114 |
|
|
|
85 |
filtered_df = df
|
86 |
return filtered_df
|
87 |
|
88 |
+
def chat_with_mistral(source_cols, dest_col, prompt, excel_file, url, search_col, keywords, client, user, progress=gr.Progress):
|
89 |
new_prompts, new_keywords, new_user, conf_file_path = update_json(user, prompt, keywords)
|
90 |
print(f'xlsxfile = {excel_file}')
|
91 |
df = pd.read_excel(excel_file)
|
|
|
103 |
|
104 |
for index, row in filtred_df.iterrows():
|
105 |
concatenated_content = "\n\n".join(f"{column_name}: {str(row[column_name])}" for column_name in source_cols)
|
|
|
106 |
if not concatenated_content == "\n\n".join(f"{column_name}: nan" for column_name in source_cols):
|
|
|
107 |
llm_answer = ask_llm(prompt[0], concatenated_content, client, user)
|
108 |
+
print(f"{index+1}/{len(df)}\nQUERY:\n{prompt[0]}\nCONTENT:\n{concatenated_content[:200]}...\n\nANSWER:\n{llm_answer}")
|
109 |
df.at[index, dest_col] = llm_answer
|
110 |
+
progress((index+1)/len(df),desc=f'Request {index+1}/{len(df)}')
|
111 |
|
112 |
df.to_excel(file_name, index=False)
|
113 |
|