-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Update config_list_from_json function to support YAML parsing #2560
Conversation
@microsoft-github-policy-service agree company="Mediatek" |
Idk why there is no yaml module, i thought it was a default module for Python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Could you also update the documentation: website/docs/topics/llm_configuration.ipynb
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2560 +/- ##
===========================================
- Coverage 33.11% 15.75% -17.37%
===========================================
Files 86 86
Lines 9108 9109 +1
Branches 1938 2090 +152
===========================================
- Hits 3016 1435 -1581
- Misses 5837 7626 +1789
+ Partials 255 48 -207
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
oh sorry, it is my first time to use |
|
GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
---|---|---|---|---|---|
10404695 | Triggered | Generic High Entropy Secret | b97b99d | test/oai/test_utils.py | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
@ekzhu BTW, I have added Additionally, I have implemented pytest for the YAML version. Specifically, I utilized |
See https://microsoft.github.io/autogen/docs/contributor-guide/documentation, the |
@@ -25,6 +25,7 @@ | |||
# Disallowing 2.6.0 can be removed when this is fixed https://github.com/pydantic/pydantic/issues/8705 | |||
"pydantic>=1.10,<3,!=2.6.0", # could be both V1 and V2 | |||
"docker", | |||
"pyyaml", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add pyyaml
to test dependencies. But for install dependency let's move this to an optional dependency like those below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually I dont see any of test dependency or optional dependency under setup.py
should I put it under test from extra_require?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add it like here:
Lines 60 to 70 in 82903f5
extra_require = { | |
"test": [ | |
"ipykernel", | |
"nbconvert", | |
"nbformat", | |
"pre-commit", | |
"pytest-cov>=5", | |
"pytest-asyncio", | |
"pytest>=6.1.1,<8", | |
"pandas", | |
], |
else: | ||
# Else, it should be a JSON string by itself. | ||
json_str = env_str | ||
config_list = json.loads(json_str) | ||
json_or_yaml_str = env_str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the yaml dependency is not installed, we can fall back to use json
module. We can do this by checking for yaml import error during import, and use that information to choose whether to use yaml load or json load.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, it sounds good
autogen/oai/openai_utils.py
Outdated
@@ -475,21 +476,38 @@ def config_list_from_json( | |||
|
|||
Args: | |||
env_or_file (str): The name of the environment variable, the filename, or the environment variable of the filename | |||
that containing the JSON data. | |||
that containing the JSON/YAML data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add explanation for installing pyyaml
.
…from environment variable or file
Some tests failed, could you fix them? For documentation, you can follow https://microsoft.github.io/autogen/docs/contributor-guide/documentation to check it locally. |
Why are these changes needed?
Add Yaml file supported for OAI_CONFIG_LIST by simply changing from
json.load
toyaml.safe_load
Related issue number
#2559
Checks