Spaces:
Runtime error
Runtime error
Commit
·
5d51144
1
Parent(s):
9ae0db9
black
Browse files- app.py +16 -5
- src/core.py +2 -1
app.py
CHANGED
|
@@ -9,15 +9,19 @@ from src.core import (
|
|
| 9 |
MAX_ROWS = 10
|
| 10 |
|
| 11 |
import pandas as pd
|
|
|
|
|
|
|
| 12 |
def generate_step_markdown(step_number: int, subtitle: str, description: str = None):
|
| 13 |
return gr.Markdown(f"# Step {step_number}\n\n ### {subtitle}\n{description}")
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
| 16 |
def load_example_template(template_df, example_df):
|
| 17 |
return template_df.update(example_df)
|
| 18 |
|
| 19 |
|
| 20 |
-
|
| 21 |
# TODO: use tempfile
|
| 22 |
def export_csv(df, filename):
|
| 23 |
df.to_csv(filename, index=False)
|
|
@@ -31,7 +35,6 @@ def export_text(content, filename):
|
|
| 31 |
return gr.File.update(value=filename, visible=True)
|
| 32 |
|
| 33 |
|
| 34 |
-
|
| 35 |
with gr.Blocks() as demo:
|
| 36 |
gr.Markdown(
|
| 37 |
"# LLM Data Mapper\n\nThis tool will help you map a source CSV to a template CSV, and then generate python code to transform the source CSV into the template CSV. You can edit all of the values, re-run the processes, and download files along the way."
|
|
@@ -58,7 +61,11 @@ with gr.Blocks() as demo:
|
|
| 58 |
upload_template_btn.upload(
|
| 59 |
fn=process_csv_text, inputs=upload_template_btn, outputs=template_df
|
| 60 |
)
|
| 61 |
-
load_template_btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
with gr.Column():
|
| 63 |
upload_source_button = gr.UploadButton(
|
| 64 |
label="Upload Source File",
|
|
@@ -74,7 +81,11 @@ with gr.Blocks() as demo:
|
|
| 74 |
upload_source_button.upload(
|
| 75 |
fn=process_csv_text, inputs=upload_source_button, outputs=source_df
|
| 76 |
)
|
| 77 |
-
load_source_button.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
# STEP 2
|
| 80 |
generate_step_markdown(
|
|
|
|
| 9 |
MAX_ROWS = 10
|
| 10 |
|
| 11 |
import pandas as pd
|
| 12 |
+
|
| 13 |
+
|
| 14 |
def generate_step_markdown(step_number: int, subtitle: str, description: str = None):
|
| 15 |
return gr.Markdown(f"# Step {step_number}\n\n ### {subtitle}\n{description}")
|
| 16 |
|
| 17 |
+
|
| 18 |
+
example_df = pd.read_csv("./src/data/synthetic/legal_entries_a.csv")
|
| 19 |
+
|
| 20 |
+
|
| 21 |
def load_example_template(template_df, example_df):
|
| 22 |
return template_df.update(example_df)
|
| 23 |
|
| 24 |
|
|
|
|
| 25 |
# TODO: use tempfile
|
| 26 |
def export_csv(df, filename):
|
| 27 |
df.to_csv(filename, index=False)
|
|
|
|
| 35 |
return gr.File.update(value=filename, visible=True)
|
| 36 |
|
| 37 |
|
|
|
|
| 38 |
with gr.Blocks() as demo:
|
| 39 |
gr.Markdown(
|
| 40 |
"# LLM Data Mapper\n\nThis tool will help you map a source CSV to a template CSV, and then generate python code to transform the source CSV into the template CSV. You can edit all of the values, re-run the processes, and download files along the way."
|
|
|
|
| 61 |
upload_template_btn.upload(
|
| 62 |
fn=process_csv_text, inputs=upload_template_btn, outputs=template_df
|
| 63 |
)
|
| 64 |
+
load_template_btn.click(
|
| 65 |
+
lambda _: pd.read_csv("./src/data/actual/template.csv"),
|
| 66 |
+
upload_template_btn,
|
| 67 |
+
template_df,
|
| 68 |
+
)
|
| 69 |
with gr.Column():
|
| 70 |
upload_source_button = gr.UploadButton(
|
| 71 |
label="Upload Source File",
|
|
|
|
| 81 |
upload_source_button.upload(
|
| 82 |
fn=process_csv_text, inputs=upload_source_button, outputs=source_df
|
| 83 |
)
|
| 84 |
+
load_source_button.click(
|
| 85 |
+
lambda _: pd.read_csv("./src/data/actual/table_A.csv"),
|
| 86 |
+
upload_source_button,
|
| 87 |
+
source_df,
|
| 88 |
+
)
|
| 89 |
|
| 90 |
# STEP 2
|
| 91 |
generate_step_markdown(
|
src/core.py
CHANGED
|
@@ -14,9 +14,10 @@ from src.prompt import (
|
|
| 14 |
SPEC_WRITER_PROMPT_STR,
|
| 15 |
ENGINEER_PROMPT_STR,
|
| 16 |
)
|
|
|
|
| 17 |
load_dotenv()
|
| 18 |
|
| 19 |
-
if os.environ.get(
|
| 20 |
os.environ["LANGCHAIN_WANDB_TRACING"] = "true"
|
| 21 |
os.environ["WANDB_PROJECT"] = "llm-data-mapper"
|
| 22 |
|
|
|
|
| 14 |
SPEC_WRITER_PROMPT_STR,
|
| 15 |
ENGINEER_PROMPT_STR,
|
| 16 |
)
|
| 17 |
+
|
| 18 |
load_dotenv()
|
| 19 |
|
| 20 |
+
if os.environ.get("DEBUG") == "true":
|
| 21 |
os.environ["LANGCHAIN_WANDB_TRACING"] = "true"
|
| 22 |
os.environ["WANDB_PROJECT"] = "llm-data-mapper"
|
| 23 |
|