From 00cb694e3b71bb60555ea4ed6cf3d4676fb89ecf Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Wed, 8 Nov 2023 20:17:57 +0530 Subject: [PATCH 1/6] move t&c out of sticky container --- daras_ai_v2/base.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/daras_ai_v2/base.py b/daras_ai_v2/base.py index f8899b172..c02834778 100644 --- a/daras_ai_v2/base.py +++ b/daras_ai_v2/base.py @@ -479,10 +479,12 @@ def render_submit_button(self, key="--submit-1"): col2.node.props[ "className" ] += " d-flex justify-content-end align-items-center" + col1.node.props[ + "className" + ] += " d-flex flex-column justify-content-center" with col1: st.caption( - f"Run cost = [{self.get_price_roundoff(st.session_state)} credits]({self.get_credits_click_url()}) \\\n" - f"_By submitting, you agree to Gooey.AI's [terms](https://gooey.ai/terms) & [privacy policy](https://gooey.ai/privacy)._ ", + f"Run cost = [{self.get_price_roundoff(st.session_state)} credits]({self.get_credits_click_url()})" ) additional_notes = self.additional_notes() if additional_notes: @@ -632,6 +634,10 @@ def _render_input_col(self): st.text_input("Title", key=StateKeys.page_title) st.text_area("Notes", key=StateKeys.page_notes) submitted = self.render_submit_button() + st.caption( + "_By submitting, you agree to Gooey.AI's [terms](https://gooey.ai/terms) &" + "[privacy policy](https://gooey.ai/privacy)._" + ) return submitted def _render_output_col(self, submitted: bool): From b9f08a9610c72e86f7b5e163fa3c576101f88155 Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Wed, 8 Nov 2023 20:41:47 +0530 Subject: [PATCH 2/6] run black formatter --- daras_ai_v2/base.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/daras_ai_v2/base.py b/daras_ai_v2/base.py index c02834778..be68ce72c 100644 --- a/daras_ai_v2/base.py +++ b/daras_ai_v2/base.py @@ -479,9 +479,7 @@ def render_submit_button(self, key="--submit-1"): col2.node.props[ "className" ] += " d-flex justify-content-end align-items-center" - col1.node.props[ - "className" - ] += " d-flex flex-column justify-content-center" + col1.node.props["className"] += " d-flex flex-column justify-content-center" with col1: st.caption( f"Run cost = [{self.get_price_roundoff(st.session_state)} credits]({self.get_credits_click_url()})" From 6dc3a008c48567d57347ff64160b5db7509e3143 Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Wed, 8 Nov 2023 21:20:39 +0530 Subject: [PATCH 3/6] Add cost note for presenting text in parens after showing run cost --- daras_ai_v2/base.py | 9 ++++++++- recipes/DeforumSD.py | 8 ++++---- recipes/Lipsync.py | 6 ++---- recipes/LipsyncTTS.py | 22 ++++++++++++++-------- recipes/TextToSpeech.py | 6 ++---- recipes/asr.py | 6 ++---- 6 files changed, 32 insertions(+), 25 deletions(-) diff --git a/daras_ai_v2/base.py b/daras_ai_v2/base.py index be68ce72c..bb81ce045 100644 --- a/daras_ai_v2/base.py +++ b/daras_ai_v2/base.py @@ -481,8 +481,12 @@ def render_submit_button(self, key="--submit-1"): ] += " d-flex justify-content-end align-items-center" col1.node.props["className"] += " d-flex flex-column justify-content-center" with col1: + cost_note = self.get_cost_note() or "" + if cost_note: + cost_note = f"({cost_note.strip()})" st.caption( f"Run cost = [{self.get_price_roundoff(st.session_state)} credits]({self.get_credits_click_url()})" + f" {cost_note}" ) additional_notes = self.additional_notes() if additional_notes: @@ -633,7 +637,7 @@ def _render_input_col(self): st.text_area("Notes", key=StateKeys.page_notes) submitted = self.render_submit_button() st.caption( - "_By submitting, you agree to Gooey.AI's [terms](https://gooey.ai/terms) &" + "_By submitting, you agree to Gooey.AI's [terms](https://gooey.ai/terms) & " "[privacy policy](https://gooey.ai/privacy)._" ) return submitted @@ -1145,6 +1149,9 @@ def get_example_response_body( def additional_notes(self) -> str | None: pass + def get_cost_note(self) -> str | None: + pass + def is_current_user_admin(self) -> bool: if not self.request or not self.request.user: return False diff --git a/recipes/DeforumSD.py b/recipes/DeforumSD.py index c2ebd231c..b5ab1c327 100644 --- a/recipes/DeforumSD.py +++ b/recipes/DeforumSD.py @@ -229,11 +229,11 @@ def render_form_v2(self): """ ) + def get_cost_note(self) -> str | None: + return f"{CREDITS_PER_FRAME} / frame" + def additional_notes(self) -> str | None: - return f""" -*Cost ≈ {CREDITS_PER_FRAME} credits per frame* \\ -*Process Run Time ≈ 5 seconds per frame* - """ + return "Render Time ≈ 3s / frame" def get_raw_price(self, state: dict) -> float: max_frames = state.get("max_frames", 100) or 0 diff --git a/recipes/Lipsync.py b/recipes/Lipsync.py index 44e2af76f..68ac496a0 100644 --- a/recipes/Lipsync.py +++ b/recipes/Lipsync.py @@ -126,10 +126,8 @@ def render_usage_guide(self): def preview_description(self, state: dict) -> str: return "Create high-quality, realistic Lipsync animations from any audio file. Input a sample face gif/video + audio and we will automatically generate a lipsync animation that matches your audio." - def additional_notes(self) -> str | None: - return f""" - *Cost ≈ {CREDITS_PER_MB} credits per MB* - """ + def get_cost_note(self) -> str | None: + return f"{CREDITS_PER_MB} credits per MB" def get_raw_price(self, state: dict) -> float: total_bytes = 0 diff --git a/recipes/LipsyncTTS.py b/recipes/LipsyncTTS.py index 279dd8b15..17a02d15b 100644 --- a/recipes/LipsyncTTS.py +++ b/recipes/LipsyncTTS.py @@ -167,15 +167,21 @@ def get_raw_price(self, state: dict): else: return LipsyncPage.get_raw_price(self, state) + def get_cost_note(self): + return "Lipsync cost + TTS cost" + def additional_notes(self): - lipsync_notes = LipsyncPage.additional_notes(self) - if tts_notes := TextToSpeechPage.additional_notes(self): - notes = f""" - - *Lipsync* {lipsync_notes.strip()} - - *TTS* {tts_notes.strip()} - """ - else: - notes = lipsync_notes + cost_notes = { + "Lipsync": LipsyncPage.get_cost_note(self), + "TTS": TextToSpeechPage.get_cost_note(self), + } + notes = "\n".join([ + f"- *{k} cost: {v.strip()}*" if v else "" + for k, v in cost_notes.items() + ]) + + notes += LipsyncPage.additional_notes(self) or "" + notes += TextToSpeechPage.additional_notes(self) or "" return notes diff --git a/recipes/TextToSpeech.py b/recipes/TextToSpeech.py index de8178cee..e1753bf1d 100644 --- a/recipes/TextToSpeech.py +++ b/recipes/TextToSpeech.py @@ -136,12 +136,10 @@ def _get_tts_provider(self, state: dict): # TODO: validate tts_provider before lookup? return TextToSpeechProviders[tts_provider] - def additional_notes(self): + def get_cost_note(self): tts_provider = st.session_state.get("tts_provider") if tts_provider == TextToSpeechProviders.ELEVEN_LABS.name: - return """ - *Eleven Labs cost ≈ 4 credits per 10 words* - """ + return "Eleven Labs ≈ 4 credits per 10 words" else: return "" diff --git a/recipes/asr.py b/recipes/asr.py index a11f4c762..3798683fa 100644 --- a/recipes/asr.py +++ b/recipes/asr.py @@ -169,10 +169,8 @@ def run(self, state: dict): # Save the raw ASR text for details view state["output_text"] = asr_output - def additional_notes(self) -> str | None: - return """ -*Cost ≈ 1 credit for 12.5 words ≈ 0.08 credits per word* - """ + def get_cost_note(self) -> str | None: + return "1 credit for 12.5 words ≈ 0.08 per word" def get_raw_price(self, state: dict): texts = state.get("output_text", []) From f5322d8b298d0f48dc1d9347dee711f64516f596 Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Wed, 8 Nov 2023 21:24:55 +0530 Subject: [PATCH 4/6] fix linting --- recipes/LipsyncTTS.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/recipes/LipsyncTTS.py b/recipes/LipsyncTTS.py index 17a02d15b..56a185f11 100644 --- a/recipes/LipsyncTTS.py +++ b/recipes/LipsyncTTS.py @@ -175,10 +175,9 @@ def additional_notes(self): "Lipsync": LipsyncPage.get_cost_note(self), "TTS": TextToSpeechPage.get_cost_note(self), } - notes = "\n".join([ - f"- *{k} cost: {v.strip()}*" if v else "" - for k, v in cost_notes.items() - ]) + notes = "\n".join( + [f"- *{k} cost: {v.strip()}*" if v else "" for k, v in cost_notes.items()] + ) notes += LipsyncPage.additional_notes(self) or "" notes += TextToSpeechPage.additional_notes(self) or "" From 7e821bf1a367db2e4965a32f996037c55720abcf Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Thu, 9 Nov 2023 18:16:35 +0530 Subject: [PATCH 5/6] Make zero-margin for caption in sticky submit section --- daras_ai_v2/base.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/daras_ai_v2/base.py b/daras_ai_v2/base.py index bb81ce045..578c67e65 100644 --- a/daras_ai_v2/base.py +++ b/daras_ai_v2/base.py @@ -485,11 +485,15 @@ def render_submit_button(self, key="--submit-1"): if cost_note: cost_note = f"({cost_note.strip()})" st.caption( - f"Run cost = [{self.get_price_roundoff(st.session_state)} credits]({self.get_credits_click_url()})" - f" {cost_note}" + f""" +

+ Run cost = {self.get_price_roundoff(st.session_state)} credits + {cost_note} +

+ """, + unsafe_allow_html=True, ) - additional_notes = self.additional_notes() - if additional_notes: + if additional_notes := self.additional_notes(): st.caption(additional_notes) with col2: submitted = st.button( From 05489175cc125b07c967e4a2f8cba2b6feeb6e09 Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Sun, 12 Nov 2023 17:39:20 +0530 Subject: [PATCH 6/6] right align privacy and terms fix alignment of run cost --- daras_ai_v2/base.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/daras_ai_v2/base.py b/daras_ai_v2/base.py index 578c67e65..e74acc160 100644 --- a/daras_ai_v2/base.py +++ b/daras_ai_v2/base.py @@ -486,15 +486,11 @@ def render_submit_button(self, key="--submit-1"): cost_note = f"({cost_note.strip()})" st.caption( f""" -

- Run cost = {self.get_price_roundoff(st.session_state)} credits - {cost_note} -

+Run cost = {self.get_price_roundoff(st.session_state)} credits {cost_note} +{self.additional_notes() or ""} """, unsafe_allow_html=True, ) - if additional_notes := self.additional_notes(): - st.caption(additional_notes) with col2: submitted = st.button( "🏃 Submit", @@ -640,10 +636,11 @@ def _render_input_col(self): st.text_input("Title", key=StateKeys.page_title) st.text_area("Notes", key=StateKeys.page_notes) submitted = self.render_submit_button() - st.caption( - "_By submitting, you agree to Gooey.AI's [terms](https://gooey.ai/terms) & " - "[privacy policy](https://gooey.ai/privacy)._" - ) + with st.div(style={"textAlign": "right"}): + st.caption( + "_By submitting, you agree to Gooey.AI's [terms](https://gooey.ai/terms) & " + "[privacy policy](https://gooey.ai/privacy)._" + ) return submitted def _render_output_col(self, submitted: bool):