mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 11:19:56 +00:00
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
When loading config from .env, the assertions like `assert api_key is
not None, "Azure OpenAI API key not found in .env file"` don't catch
anything. While `dotenv_values(".env")` does put None values for keys
with missing values, that's only if there's no equals sign after the
key. For example, this file:
```
OPENAI_API_KEY=""
OPENAI_ORG_ID="org_id"
AZURE_OPENAI_DEPLOYMENT_NAME=
AZURE_OPENAI_ENDPOINT
```
Would be parsed like this:
```
OrderedDict([('OPENAI_API_KEY', ''), ('OPENAI_ORG_ID', 'org_id'), ('AZURE_OPENAI_DEPLOYMENT_NAME', ''), ('AZURE_OPENAI_ENDPOINT', None)])
```
As you can see, OPENAI_API_KEY and AZURE_OPENAI_DEPLOYMENT_NAME are
loaded with empty strings, not None.
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
---------
Co-authored-by: Shawn Callegari <[email protected]>