Skip to content

Commit

Permalink
Move num_outputs pricing logic to base.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nikochiko authored and devxpy committed Feb 27, 2024
1 parent 306a685 commit df4d1a9
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 16 deletions.
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)

@classmethod
def get_example_preferred_fields(cls, state: dict) -> list[str]:
Expand Down
3 changes: 0 additions & 3 deletions recipes/DocSummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ def run(self, state: dict) -> typing.Iterator[str | None]:
case _:
raise NotImplementedError(f"{chain_type} not implemented")

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


MAP_REDUCE_PROMPT = """
{documents}
Expand Down
3 changes: 0 additions & 3 deletions recipes/GoogleGPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,3 @@ def run_v2(
max_tokens=request.max_tokens,
avoid_repetition=request.avoid_repetition,
)

def get_raw_price(self, state: dict) -> float:
return self.price * state.get("num_outputs", 1)
3 changes: 0 additions & 3 deletions recipes/GoogleImageGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,3 @@ def render_example(self, state: dict):

def preview_description(self, state: dict) -> str:
return "Enter a Google Image Search query + your Img2Img text prompt describing how to alter the result to create a unique, relevant ai generated images for any search query."

def get_raw_price(self, state: dict) -> float:
return super().get_raw_price(state) * state.get("num_outputs", 1)
3 changes: 0 additions & 3 deletions recipes/SmartGPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,6 @@ def render_steps(self):
def preview_description(self, state: dict) -> str:
return "SmartGPT is a cutting-edge AI technology that can be used to generate natural language responses to any given input. We have combined the power of [CoT](https://arxiv.org/abs/2305.02897), [Reflexion](https://arxiv.org/abs/2303.11366) & [DERA](https://arxiv.org/abs/2303.17071) into one pipeline so that you can use ChatGPT to its full potential! Input your prompt + a reflection/research prompt + a resolver prompt to use SmartGPT for enhanced text generation, natural language and incredible question-answer results."

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


def answers_as_prompt(texts: list[str], sep="\n\n") -> str:
return sep.join(
Expand Down
3 changes: 0 additions & 3 deletions recipes/Text2Audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ def render_example(self, state: dict):
def preview_description(self, state: dict) -> str:
return "Generate AI Music with text instruction prompts. AudiLDM is capable of generating realistic audio samples by process any text input. Learn more [here](https://huggingface.co/cvssp/audioldm-m-full)."

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


def _render_output(state):
selected_models = state.get("selected_models", [])
Expand Down

0 comments on commit df4d1a9

Please sign in to comment.