Skip to content

Commit

Permalink
fix: declutter the config using defaults
Browse files Browse the repository at this point in the history
Allow default options to be specified in the fish-ai section of fish-ai.ini.
  • Loading branch information
Realiserad committed Jul 15, 2024
1 parent aad363a commit b0efaea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ to let `fish-ai` suggest a fix!

## 🤸 Additional options

You can tweak the behaviour of `fish-ai` by putting additional options in the
active section of your `fish-ai.ini` file.
You can tweak the behaviour of `fish-ai` by putting additional options in your
`fish-ai.ini` configuration file.

### Explain in a different language

Expand All @@ -162,9 +162,6 @@ to the name of the language. For example:

```ini
[fish-ai]
configuration = foo

[foo]
language = Swedish
```

Expand All @@ -181,9 +178,6 @@ Here is an example of how to increase the temperature to `0.5`.

```ini
[fish-ai]
configuration = foo

[foo]
temperature = 0.5
```

Expand All @@ -198,9 +192,6 @@ Here is an example of how you can increase the number of completions to `10`:

```ini
[fish-ai]
configuration = foo

[foo]
completions = 10
```

Expand All @@ -215,9 +206,6 @@ is `0` (do not send any commandline history).

```ini
[fish-ai]
configuration = foo

[foo]
history_size = 5
```

Expand Down
11 changes: 5 additions & 6 deletions src/fish_ai/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,16 @@ def get_system_prompt():


def get_config(key):
if config.has_section('fish-ai'):
active_section = config.get(section='fish-ai', option='configuration')
else:
if not config.has_section('fish-ai'):
# There is no configuration file or the user made a mistake.
# Just return 'None' here to simplify testing.
return None

if key not in config[active_section]:
return None
active_section = config.get(
section='fish-ai', option='configuration') or 'fish-ai'

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


def get_openai_client():
Expand Down

0 comments on commit b0efaea

Please sign in to comment.