Skip to content

Commit

Permalink
Fix pricing for more recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
nikochiko committed Feb 20, 2024
1 parent 1b3ca5b commit e981542
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 8 deletions.
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
3 changes: 3 additions & 0 deletions recipes/DocSummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ 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
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)
3 changes: 3 additions & 0 deletions recipes/GoogleImageGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,6 @@ 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)
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)
3 changes: 3 additions & 0 deletions recipes/SmartGPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ 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: 3 additions & 0 deletions recipes/Text2Audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ 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 e981542

Please sign in to comment.