Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when locating config.yaml #96

Closed

Conversation

PeterDaveHello
Copy link
Contributor

@PeterDaveHello PeterDaveHello commented May 12, 2024

Implements a fallback mechanism for configuration loading in azure/init.go to enhance robustness when config.yaml is not found.

  • Checks for config.yaml existence: Before attempting to read config.yaml, the code now checks if the file exists. If not, it logs a message and tries to read configuration from environment variables instead.
  • Updates error messaging: Modifies the error message when failing to read config.yaml to suggest checking the file's existence or using environment variables for configuration.

For more details, open the Copilot Workspace session.

@PeterDaveHello
Copy link
Contributor Author

Please note that this PR is fully generated by GitHub's Copilot Workspace 😄 Using #95 as its task.

@PeterDaveHello
Copy link
Contributor Author

So it looks like there's an error during running go vet ./...:

Error: azure/init.go:107:10: InitFromEnvironmentVariables(viper.GetString(constant.ENV_AZURE_OPENAI_API_VER), viper.GetString(constant.ENV_AZURE_OPENAI_ENDPOINT), viper.GetString(constant.ENV_AZURE_OPENAI_MODEL_MAPPER)) (no value) used as value

Implements a fallback mechanism for configuration loading and improves error handling in `azure/init.go`.

- Adds a check for the existence of `config.yaml` before attempting to read it. If the file does not exist, the application now falls back to loading configuration from environment variables instead of terminating with an error.
- Updates the error message when `config.yaml` cannot be located to suggest checking the file's existence or using environment variables for configuration.
- Ensures that if both the configuration file is missing and required environment variables are not set, a clear error is returned indicating the absence of both configuration sources.


---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/stulzq/azure-openai-proxy?shareId=906b60bd-c6a9-40b1-b401-639f8a386023).
@PeterDaveHello
Copy link
Contributor Author

Looks like AI can't replace me yet 😈 See #95 for details, and sorry for the invalid PR.

@PeterDaveHello PeterDaveHello deleted the fix-config-loading branch May 12, 2024 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant