Commit a92bedc
Add config to allow to use other AI providers (#7)
This commit introduces a new configuration system, allowing users to
customize parameters such as `model`, `max_tokens`, and `temperature`
through a `config.yaml` file located at
`~/.config/pipe-gpt/config.yaml`.
Previously, these parameters were hardcoded constants or relied solely
on environment variables. The new system provides:
- A structured `AppConfig` struct to hold configuration values.
- A `load_config` function that reads from the YAML file, applying
default values for any missing fields.
- Robust error handling for missing or malformed configuration files,
falling back to sensible defaults.
- Integration of the new configuration throughout the application's API
interaction and CLI argument parsing.
This change also involved adding new dependencies (`dirs`, `memoize`,
`serde`, `serde_yaml`, `tempfile`) and updating various existing
dependencies in `Cargo.lock` to support the new features and ensure
compatibility.
The configuration loading and parsing logic within `load_config` has
been extracted into a new private helper function `get_config`. This
improves modularity, readability, and allows for more direct testing of
the configuration parsing independent of environment variable setup.
The unit tests have been updated to utilize `get_config` and new helper
functions for setting up and writing to temporary config files, leading
to clearer and more isolated test cases. Redundant comments were also
removed.
---------
Co-authored-by: Elio <elio@localhost.localdomain>
Co-authored-by: Craig Mayhew <craig@mayhew.io>1 parent f118105 commit a92bedc
File tree
5 files changed
+492
-85
lines changed- src
- api
- cli
- config
5 files changed
+492
-85
lines changed
0 commit comments