Skip to content

Commit

Permalink
fix: provide fallback value when option is missing in config
Browse files Browse the repository at this point in the history
Prevents crash when default value should be used.
  • Loading branch information
Realiserad committed Jul 16, 2024
1 parent b4d9ef9 commit 5ffd1b7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/fish_ai/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,12 @@ def get_config(key):
# Just return 'None' here to simplify testing.
return None

active_section = config.get(
section='fish-ai', option='configuration') or 'fish-ai'
active_section = config.get(section='fish-ai', option='configuration')

return config.get(section=active_section, option=key) or config.get(
section='fish-ai', option=key)
if config.has_option(section=active_section, option=key):
return config.get(section=active_section, option=key)

return config.get(section='fish-ai', option=key, fallback=None)


def get_openai_client():
Expand Down

0 comments on commit 5ffd1b7

Please sign in to comment.