Spaces:
Build error
Build error
Commit
·
607292d
1
Parent(s):
8509a28
fix: update potential record to json conversion
Browse files
app.py
CHANGED
|
@@ -33,13 +33,17 @@ def process_fields(fields):
|
|
| 33 |
def process_records_gradio(records, fields, question, example_records=None):
|
| 34 |
try:
|
| 35 |
# Convert string inputs to dictionaries
|
| 36 |
-
records = json.loads(records)
|
| 37 |
-
example_records =
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
if not fields and not question:
|
| 42 |
-
|
| 43 |
|
| 44 |
runtime_parameters = {"fields": fields, "question": question}
|
| 45 |
if example_records:
|
|
@@ -110,6 +114,7 @@ interface = gr.Interface(
|
|
| 110 |
gr.Code(label="Question (JSON, optional)", language="json"),
|
| 111 |
],
|
| 112 |
examples=examples,
|
|
|
|
| 113 |
outputs=gr.Code(label="Suggestions", language="json", lines=10),
|
| 114 |
title="Distilabel - ArgillaLabeller - Record Processing Interface",
|
| 115 |
description=description,
|
|
|
|
| 33 |
def process_records_gradio(records, fields, question, example_records=None):
|
| 34 |
try:
|
| 35 |
# Convert string inputs to dictionaries
|
| 36 |
+
records = json.loads(records) if isinstance(records, str) else records
|
| 37 |
+
example_records = (
|
| 38 |
+
json.loads(example_records)
|
| 39 |
+
if example_records and isinstance(example_records, str)
|
| 40 |
+
else example_records
|
| 41 |
+
)
|
| 42 |
+
fields = process_fields(fields) if isinstance(fields, str) else fields
|
| 43 |
+
question = json.loads(question) if isinstance(question, str) else question
|
| 44 |
|
| 45 |
if not fields and not question:
|
| 46 |
+
raise Exception("Error: Either fields or question must be provided")
|
| 47 |
|
| 48 |
runtime_parameters = {"fields": fields, "question": question}
|
| 49 |
if example_records:
|
|
|
|
| 114 |
gr.Code(label="Question (JSON, optional)", language="json"),
|
| 115 |
],
|
| 116 |
examples=examples,
|
| 117 |
+
cache_examples=True,
|
| 118 |
outputs=gr.Code(label="Suggestions", language="json", lines=10),
|
| 119 |
title="Distilabel - ArgillaLabeller - Record Processing Interface",
|
| 120 |
description=description,
|