40
40
worksheet = None
41
41
result_book = None
42
42
result_sheet = None
43
- result_placement = None
43
+ result_placement = "r"
44
44
input_pos = ""
45
45
cache = dict ()
46
46
limit = 0
@@ -110,7 +110,7 @@ def reset_globals():
110
110
worksheet = None
111
111
result_book = None
112
112
result_sheet = None
113
- result_placement = None
113
+ result_placement = "r"
114
114
input_pos = ""
115
115
cache = dict ()
116
116
limit = 0
@@ -167,7 +167,7 @@ def process_item(current_pos, current_col, current_row, input_values):
167
167
input_hash = str (hash (frozenset (input_values )))
168
168
result_value = get_cell_value (worksheet = result_sheet , cell = (current_col + current_row ))
169
169
170
- if result_value == None or str (result_value ).strip () == "" or not skip :
170
+ if result_value is None or str (result_value ).strip () == "" or not skip :
171
171
answer = ""
172
172
processed_count = 0
173
173
@@ -183,7 +183,7 @@ def process_item(current_pos, current_col, current_row, input_values):
183
183
answer = res [0 ]
184
184
processed_count = res [1 ]
185
185
186
- set_cell_value (worksheet = result_sheet , cell = (current_col + current_row ), value = answer )
186
+ set_cell_value (worksheet = result_sheet , cell = (str ( current_col ) + str ( current_row ) ), value = answer )
187
187
188
188
print ("Answer: " + answer )
189
189
@@ -739,7 +739,7 @@ def output_placement_changed(e):
739
739
ft .dropdown .Option ("Place on the next column" )
740
740
],
741
741
col = {"md" : 4 },
742
- value = "Place on the next row"
742
+ value = "Place on the next row" if result_placement == "r" else "Place on the next column"
743
743
)
744
744
745
745
def api_key_changed (e ):
@@ -876,6 +876,28 @@ def on_skip_changed(e):
876
876
on_change = on_skip_changed
877
877
)
878
878
879
+ def clear_fields (e ):
880
+ reset_globals ()
881
+
882
+ limit_field .value = limit
883
+ api_key_field .value = api_key
884
+ prompt_field .value = prompt
885
+ system_prompt_field .value = DEFAULT_SYSTEM_PROMPT
886
+ until_field .value = until
887
+ inputs_field .value = "," .join (inputs )
888
+ input_pos_field .value = input_pos
889
+ output_col_field .value = result_col
890
+ output_row_field .value = result_row
891
+ output_placement_dropdown .value = "Place on the next row"
892
+ model_dropdown .value = model
893
+ sheet_dropdown .value = None
894
+ input_text .value = "No input file selected"
895
+ output_text .value = "No output file selected"
896
+ skip_switch .value = skip
897
+
898
+ page .update ()
899
+ check_validity ()
900
+
879
901
def start_processing (e ):
880
902
global file_path
881
903
global result_path
@@ -929,6 +951,8 @@ def start_processing(e):
929
951
sheet_dropdown .disabled = True
930
952
input_button .disabled = True
931
953
output_button .disabled = True
954
+ reset_button .visible = False
955
+ reset_button .disabled = True
932
956
933
957
page .update ()
934
958
@@ -963,34 +987,18 @@ def start_processing(e):
963
987
api_key_field .disabled = False
964
988
prompt_field .disabled = False
965
989
system_prompt_field .disabled = False
966
- until_field .disabled = True
990
+ until_field .disabled = False
967
991
inputs_field .disabled = False
968
- input_pos_field .disabled = True
992
+ input_pos_field .disabled = False
969
993
output_col_field .disabled = False
970
994
output_row_field .disabled = False
971
995
output_placement_dropdown .disabled = False
972
996
model_dropdown .disabled = False
973
- sheet_dropdown .disabled = True
997
+ sheet_dropdown .disabled = False
974
998
input_button .disabled = False
975
- output_button .disabled = True
976
-
977
- reset_globals ()
978
-
979
- limit_field .value = limit
980
- api_key_field .value = api_key
981
- prompt_field .value = prompt
982
- system_prompt_field .value = DEFAULT_SYSTEM_PROMPT
983
- until_field .value = until
984
- inputs_field .value = "," .join (inputs )
985
- input_pos_field .value = input_pos
986
- output_col_field .value = result_col
987
- output_row_field .value = result_row
988
- output_placement_dropdown .value = "Place on the next row"
989
- model_dropdown .value = model
990
- sheet_dropdown .value = None
991
- input_text .value = "No input file selected"
992
- output_text .value = "No output file selected"
993
- skip_switch .value = skip
999
+ output_button .disabled = False
1000
+ reset_button .visible = True
1001
+ reset_button .disabled = False
994
1002
995
1003
page .update ()
996
1004
check_validity ()
@@ -1017,6 +1025,14 @@ def start_processing(e):
1017
1025
col = {"md" : 3 }
1018
1026
)
1019
1027
1028
+ reset_button = ft .ElevatedButton (
1029
+ "Clear fields" ,
1030
+ disabled = True ,
1031
+ on_click = clear_fields ,
1032
+ col = {"md" : 3 },
1033
+ visible = False
1034
+ )
1035
+
1020
1036
stop_button = ft .OutlinedButton (
1021
1037
"Stop processing" ,
1022
1038
disabled = True ,
@@ -1129,6 +1145,7 @@ def start_processing(e):
1129
1145
[
1130
1146
stop_button ,
1131
1147
process_button ,
1148
+ reset_button ,
1132
1149
ft .Row (
1133
1150
[process_message ],
1134
1151
col = {"md" : 8 },
0 commit comments