davidmezzetti
commited on
Commit
•
d7483f7
1
Parent(s):
08d28ec
Update app.py
Browse files
app.py
CHANGED
@@ -451,13 +451,14 @@ class Application:
|
|
451 |
|
452 |
return [x.strip() for x in text.split(",")]
|
453 |
|
454 |
-
def options(self, component, workflow):
|
455 |
"""
|
456 |
Extracts component settings into a component configuration dict.
|
457 |
|
458 |
Args:
|
459 |
component: component type
|
460 |
workflow: existing workflow, can be None
|
|
|
461 |
|
462 |
Returns:
|
463 |
dict with component settings
|
@@ -466,6 +467,8 @@ class Application:
|
|
466 |
# pylint: disable=R0912, R0915
|
467 |
options = {"type": component}
|
468 |
|
|
|
|
|
469 |
# Lookup component configuration
|
470 |
# - Runtime components have config defined within tasks
|
471 |
# - Pipeline components have config defined at workflow root
|
@@ -481,16 +484,17 @@ class Application:
|
|
481 |
config = workflow.get(component)
|
482 |
|
483 |
if component == "embeddings":
|
484 |
-
st.markdown("**Embeddings Index** \n*Index workflow output*")
|
|
|
485 |
options["path"] = self.text("Embeddings model path", component, config, "path", "sentence-transformers/nli-mpnet-base-v2")
|
486 |
options["upsert"] = self.boolean("Upsert", component, config, "upsert")
|
487 |
options["content"] = self.boolean("Content", component, config, "content")
|
488 |
|
489 |
elif component in ("segmentation", "textractor"):
|
490 |
if component == "segmentation":
|
491 |
-
st.markdown("**Segment** \n*Split text into semantic units*")
|
492 |
else:
|
493 |
-
st.markdown("**Textract** \n*Extract text from documents*")
|
494 |
|
495 |
options["sentences"] = self.boolean("Split sentences", component, config, "sentences")
|
496 |
options["lines"] = self.boolean("Split lines", component, config, "lines")
|
@@ -499,7 +503,7 @@ class Application:
|
|
499 |
options["minlength"] = self.number("Min section length", component, config, "minlength")
|
500 |
|
501 |
elif component == "service":
|
502 |
-
st.markdown("**Service** \n*Extract data from an API*")
|
503 |
options["url"] = self.text("URL", component, config, "url")
|
504 |
options["method"] = self.select("Method", component, config, "method", ["get", "post"], 0)
|
505 |
options["params"] = self.text("URL parameters", component, config, "params")
|
@@ -512,13 +516,13 @@ class Application:
|
|
512 |
options["extract"] = self.split(options["extract"])
|
513 |
|
514 |
elif component == "summary":
|
515 |
-
st.markdown("**Summary** \n*Abstractive text summarization*")
|
516 |
options["path"] = self.text("Model", component, config, "path", "sshleifer/distilbart-cnn-12-6")
|
517 |
options["minlength"] = self.number("Min length", component, config, "minlength")
|
518 |
options["maxlength"] = self.number("Max length", component, config, "maxlength")
|
519 |
|
520 |
elif component == "tabular":
|
521 |
-
st.markdown("**Tabular** \n*Split tabular data into rows and columns*")
|
522 |
options["idcolumn"] = self.text("Id columns", component, config, "idcolumn")
|
523 |
options["textcolumns"] = self.text("Text columns", component, config, "textcolumns")
|
524 |
options["content"] = self.text("Content", component, config, "content")
|
@@ -532,11 +536,9 @@ class Application:
|
|
532 |
options["content"] = options["content"][0]
|
533 |
|
534 |
elif component == "translation":
|
535 |
-
st.markdown("**Translate** \n*Machine translation*")
|
536 |
options["target"] = self.text("Target language code", component, config, "args", "en")
|
537 |
|
538 |
-
st.markdown("---")
|
539 |
-
|
540 |
return options
|
541 |
|
542 |
def yaml(self, components):
|
@@ -683,7 +685,7 @@ class Application:
|
|
683 |
selected, workflow = self.load(components)
|
684 |
if selected:
|
685 |
# Get selected options
|
686 |
-
components = [self.options(component, workflow) for component in selected]
|
687 |
|
688 |
if selected:
|
689 |
# Process current action
|
|
|
451 |
|
452 |
return [x.strip() for x in text.split(",")]
|
453 |
|
454 |
+
def options(self, component, workflow, index):
|
455 |
"""
|
456 |
Extracts component settings into a component configuration dict.
|
457 |
|
458 |
Args:
|
459 |
component: component type
|
460 |
workflow: existing workflow, can be None
|
461 |
+
index: task index
|
462 |
|
463 |
Returns:
|
464 |
dict with component settings
|
|
|
467 |
# pylint: disable=R0912, R0915
|
468 |
options = {"type": component}
|
469 |
|
470 |
+
st.markdown("---")
|
471 |
+
|
472 |
# Lookup component configuration
|
473 |
# - Runtime components have config defined within tasks
|
474 |
# - Pipeline components have config defined at workflow root
|
|
|
484 |
config = workflow.get(component)
|
485 |
|
486 |
if component == "embeddings":
|
487 |
+
st.markdown(f"** {index + 1}.) Embeddings Index** \n*Index workflow output*")
|
488 |
+
options["index"] = self.text("Embeddings storage path", component, config, "index")
|
489 |
options["path"] = self.text("Embeddings model path", component, config, "path", "sentence-transformers/nli-mpnet-base-v2")
|
490 |
options["upsert"] = self.boolean("Upsert", component, config, "upsert")
|
491 |
options["content"] = self.boolean("Content", component, config, "content")
|
492 |
|
493 |
elif component in ("segmentation", "textractor"):
|
494 |
if component == "segmentation":
|
495 |
+
st.markdown(f"** {index + 1}.) Segment** \n*Split text into semantic units*")
|
496 |
else:
|
497 |
+
st.markdown(f"** {index + 1}.) Textract** \n*Extract text from documents*")
|
498 |
|
499 |
options["sentences"] = self.boolean("Split sentences", component, config, "sentences")
|
500 |
options["lines"] = self.boolean("Split lines", component, config, "lines")
|
|
|
503 |
options["minlength"] = self.number("Min section length", component, config, "minlength")
|
504 |
|
505 |
elif component == "service":
|
506 |
+
st.markdown(f"** {index + 1}.) Service** \n*Extract data from an API*")
|
507 |
options["url"] = self.text("URL", component, config, "url")
|
508 |
options["method"] = self.select("Method", component, config, "method", ["get", "post"], 0)
|
509 |
options["params"] = self.text("URL parameters", component, config, "params")
|
|
|
516 |
options["extract"] = self.split(options["extract"])
|
517 |
|
518 |
elif component == "summary":
|
519 |
+
st.markdown(f"** {index + 1}.) Summary** \n*Abstractive text summarization*")
|
520 |
options["path"] = self.text("Model", component, config, "path", "sshleifer/distilbart-cnn-12-6")
|
521 |
options["minlength"] = self.number("Min length", component, config, "minlength")
|
522 |
options["maxlength"] = self.number("Max length", component, config, "maxlength")
|
523 |
|
524 |
elif component == "tabular":
|
525 |
+
st.markdown(f"** {index + 1}.) Tabular** \n*Split tabular data into rows and columns*")
|
526 |
options["idcolumn"] = self.text("Id columns", component, config, "idcolumn")
|
527 |
options["textcolumns"] = self.text("Text columns", component, config, "textcolumns")
|
528 |
options["content"] = self.text("Content", component, config, "content")
|
|
|
536 |
options["content"] = options["content"][0]
|
537 |
|
538 |
elif component == "translation":
|
539 |
+
st.markdown(f"** {index + 1}.) Translate** \n*Machine translation*")
|
540 |
options["target"] = self.text("Target language code", component, config, "args", "en")
|
541 |
|
|
|
|
|
542 |
return options
|
543 |
|
544 |
def yaml(self, components):
|
|
|
685 |
selected, workflow = self.load(components)
|
686 |
if selected:
|
687 |
# Get selected options
|
688 |
+
components = [self.options(component, workflow, x) for x, component in enumerate(selected)]
|
689 |
|
690 |
if selected:
|
691 |
# Process current action
|