Skip to content

Commit

Permalink
Refactor: Change asserts into rasing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SverreNystad committed Sep 20, 2023
1 parent e98259a commit f1f4975
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/agents/dungeon_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ def narrate(prompt: str) -> str:
)

def run_dungeon_master(prompt) -> str:
"""Run the dungeon master agent."""
assert isinstance(prompt, str), "Prompt must be a string."
"""Run the dungeon master agent."""
if not isinstance(prompt, str):
raise TypeError("Prompt must be a string.")

if (len(prompt) < 1) or (len(prompt) > 1000):
raise ValueError("Prompt must be at least 1 character or less than 1000 characters.")

Expand Down
4 changes: 3 additions & 1 deletion src/text_generation/text_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def get_default_text_generator(temperature: float = 0.7, is_llm: bool = True) ->
Returns:
:return: A text generator.
"""
assert 0.0 <= temperature <= 1.0, "Temperature must be between 0.0 and 1.0"
if not 0.0 <= temperature <= 1.0:
raise ValueError("Temperature must be between 0.0 and 1.0")

if is_llm:
return LLM(temperature=temperature)
else:
Expand Down

0 comments on commit f1f4975

Please sign in to comment.