Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pricing for num_outputs>1 #281

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion daras_ai_v2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,7 @@ def get_price_roundoff(self, state: dict) -> int:
return max(1, math.ceil(self.get_raw_price(state)))

def get_raw_price(self, state: dict) -> float:
return self.price
return self.price * state.get("num_outputs", 1)

def get_example_response_body(
self,
Expand Down
2 changes: 1 addition & 1 deletion recipes/CompareText2Img.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,4 @@ def get_raw_price(self, state: dict) -> int:
total += 15
case _:
total += 2
return total
return total * state.get("num_outputs", 1)
5 changes: 3 additions & 2 deletions recipes/DocSearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,10 @@ def run_v2(
def get_raw_price(self, state: dict) -> float:
name = state.get("selected_model")
try:
return llm_price[LargeLanguageModels[name]] * 2
unit_price = llm_price[LargeLanguageModels[name]] * 2
except KeyError:
return 10
unit_price = 10
return unit_price * state.get("num_outputs", 1)


def render_documents(state, label="**Documents**", *, key="documents"):
Expand Down
6 changes: 4 additions & 2 deletions recipes/FaceInpainting.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ def get_raw_price(self, state: dict) -> int:
selected_model = state.get("selected_model")
match selected_model:
case InpaintingModels.dall_e.name:
return 20
unit_price = 20
case _:
return 5
unit_price = 5

return unit_price * state.get("num_outputs", 1)
6 changes: 4 additions & 2 deletions recipes/Img2Img.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ def get_raw_price(self, state: dict) -> int:
selected_model = state.get("selected_model")
match selected_model:
case Img2ImgModels.dall_e.name:
return 20
unit_price = 20
case _:
return 5
unit_price = 5

return unit_price * state.get("num_outputs", 1)
6 changes: 4 additions & 2 deletions recipes/ObjectInpainting.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ def get_raw_price(self, state: dict) -> int:
selected_model = state.get("selected_model")
match selected_model:
case InpaintingModels.dall_e.name:
return 20
unit_price = 20
case _:
return 5
unit_price = 5

return unit_price * state.get("num_outputs", 1)
6 changes: 4 additions & 2 deletions recipes/VideoBots.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,11 +601,13 @@ def get_raw_price(self, state: dict):
"raw_tts_text", state.get("raw_output_text", [])
)
tts_state = {"text_prompt": "".join(output_text_list)}
return super().get_raw_price(state) + TextToSpeechPage().get_raw_price(
total = super().get_raw_price(state) + TextToSpeechPage().get_raw_price(
tts_state
)
case _:
return super().get_raw_price(state)
total = super().get_raw_price(state)

return total * state.get("num_outputs", 1)

def additional_notes(self):
tts_provider = st.session_state.get("tts_provider")
Expand Down
Loading