refactor: optimize output
Browse files
app.py
CHANGED
@@ -18,7 +18,7 @@ def auto_tabulator_completion(
|
|
18 |
str_api_keys: str,
|
19 |
base_url: str,
|
20 |
) -> tuple[str, str, str, pd.DataFrame]:
|
21 |
-
output_file_name = "
|
22 |
autotab = AutoTab(
|
23 |
in_file_path=in_file_path,
|
24 |
out_file_path=output_file_name,
|
@@ -33,9 +33,18 @@ def auto_tabulator_completion(
|
|
33 |
)
|
34 |
start = time.time()
|
35 |
autotab.run()
|
36 |
-
time_taken = time.
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
|
41 |
# Gradio interface
|
@@ -45,7 +54,7 @@ inputs = [
|
|
45 |
value="You are a helpful assistant. Help me finish the task.",
|
46 |
label="Instruction",
|
47 |
),
|
48 |
-
gr.Slider(value=
|
49 |
gr.Textbox(value="Qwen/Qwen2-7B-Instruct", label="Model Name"),
|
50 |
gr.Textbox(
|
51 |
value='{"temperature": 0, "max_tokens": 128}',
|
@@ -61,7 +70,7 @@ inputs = [
|
|
61 |
]
|
62 |
|
63 |
outputs = [
|
64 |
-
gr.Textbox(label="
|
65 |
gr.File(label="Output Excel File"),
|
66 |
gr.Textbox(label="Query Example"),
|
67 |
gr.Dataframe(label="First 15 rows."),
|
|
|
18 |
str_api_keys: str,
|
19 |
base_url: str,
|
20 |
) -> tuple[str, str, str, pd.DataFrame]:
|
21 |
+
output_file_name = f"output_{time.strftime('%Y%m%d%H%M%S')}.xlsx"
|
22 |
autotab = AutoTab(
|
23 |
in_file_path=in_file_path,
|
24 |
out_file_path=output_file_name,
|
|
|
33 |
)
|
34 |
start = time.time()
|
35 |
autotab.run()
|
36 |
+
time_taken = time.time() - start
|
37 |
|
38 |
+
report = f"Total data points: {autotab.num_data}\n" + \
|
39 |
+
f"Total missing (before): {autotab.num_missing}\n" + \
|
40 |
+
f"Total missing (after): {autotab.failed_count}\n" + \
|
41 |
+
f"Total queries made: {autotab.request_count}\n" + \
|
42 |
+
f"Time taken: {time.strftime('%H:%M:%S', time.gmtime(time.time() - start))}\n" + \
|
43 |
+
f"Prediction per second: {autotab.num_missing / time_taken:.2f}\n" + \
|
44 |
+
f"Query per second: {autotab.request_count / time_taken:.2f}"
|
45 |
+
|
46 |
+
query_example = autotab.query_example if autotab.request_count > 0 else "No queries made."
|
47 |
+
return report, output_file_name, query_example, autotab.data[:15]
|
48 |
|
49 |
|
50 |
# Gradio interface
|
|
|
54 |
value="You are a helpful assistant. Help me finish the task.",
|
55 |
label="Instruction",
|
56 |
),
|
57 |
+
gr.Slider(value=4, minimum=1, maximum=50, step=1, label="Max Examples"),
|
58 |
gr.Textbox(value="Qwen/Qwen2-7B-Instruct", label="Model Name"),
|
59 |
gr.Textbox(
|
60 |
value='{"temperature": 0, "max_tokens": 128}',
|
|
|
70 |
]
|
71 |
|
72 |
outputs = [
|
73 |
+
gr.Textbox(label="Report"),
|
74 |
gr.File(label="Output Excel File"),
|
75 |
gr.Textbox(label="Query Example"),
|
76 |
gr.Dataframe(label="First 15 rows."),
|