From a513fb36a7f9c9d538abbca0d24111a633f12175 Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Wed, 26 Jun 2024 21:15:23 +0530 Subject: [PATCH] fix defaults for translation workflow, remove metadata and prefer admin saved data --- recipes/Translation.py | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/recipes/Translation.py b/recipes/Translation.py index 99769b88b..4d4335eb7 100644 --- a/recipes/Translation.py +++ b/recipes/Translation.py @@ -1,43 +1,38 @@ import typing + from pydantic import BaseModel, Field, HttpUrl import gooey_ui as st -from daras_ai_v2.base import BasePage from bots.models import Workflow - from daras_ai_v2.asr import ( TranslationModels, translation_model_selector, translation_language_selector, run_translate, ) +from daras_ai_v2.base import BasePage from daras_ai_v2.field_render import field_title_desc from daras_ai_v2.glossary import glossary_input from daras_ai_v2.text_output_widget import text_outputs -from recipes.DocSearch import render_documents - -META_IMG = "https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/f2c0056a-2c88-11ef-9c40-02420a0001b3/Translation.jpg" -EXPLORE_IMG = "https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/fce91234-2c88-11ef-9862-02420a0001b2/square_translations.png" class TranslationPage(BasePage): - title = "Compare Translations" - explore_image = EXPLORE_IMG + title = "Compare AI Translations" workflow = Workflow.TRANSLATION - slug_versions = ["translate"] - - sane_defaults = dict( - translation_model=TranslationModels.google.name, translation_target="en" - ) + slug_versions = ["translate", "translation", "compare-ai-translation"] class RequestModel(BaseModel): - texts: list[str] + texts: list[str] = Field([]) + + translation_model: ( + typing.Literal[tuple(e.name for e in TranslationModels)] + ) | None = Field(TranslationModels.google.name) - translation_model: typing.Literal[tuple(e.name for e in TranslationModels)] translation_source: str | None = Field( title="Source Translation Language", ) translation_target: str = Field( + "en", title="Target Translation Language", ) @@ -57,15 +52,6 @@ def get_example_preferred_fields(cls, state: dict) -> list[str]: "translation_target", ] - def preview_image(self, state: dict) -> str | None: - return META_IMG - - def preview_description(self, state: dict): - return "Compare the best AI translation models in the world from Google, Azure, Meta and LLMs to determine which work best you." - - def render_description(self): - st.markdown(self.preview_description(st.session_state)) - def related_workflows(self) -> list: from recipes.asr_page import AsrPage from recipes.VideoBots import VideoBotsPage