-
Notifications
You must be signed in to change notification settings - Fork 447
Feat/webui code genesis #837
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
Open
vinci-grape
wants to merge
5
commits into
main
Choose a base branch
from
feat/webui_code_genesis
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # Copyright (c) ModelScope Contributors. All rights reserved. | ||
| # Copyright (c) Alibaba, Inc. and its affiliates. | ||
| import argparse | ||
| import os.path | ||
| from abc import abstractmethod | ||
|
|
@@ -108,7 +108,10 @@ def fill_missing_fields(config: DictConfig) -> DictConfig: | |
| @staticmethod | ||
| def is_workflow(config: DictConfig) -> bool: | ||
| assert config.name is not None, 'Cannot find a valid name in this config' | ||
| return config.name in ['workflow.yaml', 'workflow.yml'] | ||
| return config.name in [ | ||
| 'workflow.yaml', 'workflow.yml', 'simple_workflow.yaml', | ||
| 'simple_workflow.yml' | ||
| ] | ||
|
|
||
| @staticmethod | ||
| def parse_args() -> Dict[str, Any]: | ||
|
|
@@ -124,15 +127,6 @@ def parse_args() -> Dict[str, Any]: | |
| _dict_config[key[2:]] = value | ||
| return _dict_config | ||
|
|
||
| @staticmethod | ||
| def safe_get_config(config: DictConfig, keys: str) -> Any: | ||
| node = config | ||
| for key in keys.split('.'): | ||
| if not hasattr(node, key): | ||
| return None | ||
| node = getattr(node, key) | ||
| return node | ||
|
|
||
| @staticmethod | ||
| def _update_config(config: Union[DictConfig, ListConfig], | ||
| extra: Dict[str, str] = None): | ||
|
|
@@ -151,14 +145,42 @@ def traverse_config(_config: Union[DictConfig, ListConfig, Any], | |
| if current_path in extra: | ||
| logger.info( | ||
| f'Replacing {current_path} with extra value.') | ||
| setattr(_config, name, extra[current_path]) | ||
| # Convert temperature to float and max_tokens to int if they're numeric strings | ||
| value_to_set = extra[current_path] | ||
| if name == 'temperature' and isinstance( | ||
| value_to_set, str): | ||
| try: | ||
| value_to_set = float(value_to_set) | ||
| except (ValueError, TypeError): | ||
| pass | ||
| elif name == 'max_tokens' and isinstance( | ||
| value_to_set, str): | ||
| try: | ||
| value_to_set = int(value_to_set) | ||
| except (ValueError, TypeError): | ||
| pass | ||
| setattr(_config, name, value_to_set) | ||
| # Find the key in extra that matches name (case-insensitive) | ||
| elif (key_match := next( | ||
| (key | ||
| for key in extra if key.lower() == name.lower()), | ||
| None)) is not None: | ||
| logger.info(f'Replacing {name} with extra value.') | ||
| setattr(_config, name, extra[key_match]) | ||
| # Convert temperature to float and max_tokens to int if they're numeric strings | ||
| value_to_set = extra[key_match] | ||
| if name == 'temperature' and isinstance( | ||
| value_to_set, str): | ||
| try: | ||
| value_to_set = float(value_to_set) | ||
| except (ValueError, TypeError): | ||
| pass | ||
| elif name == 'max_tokens' and isinstance( | ||
| value_to_set, str): | ||
| try: | ||
| value_to_set = int(value_to_set) | ||
| except (ValueError, TypeError): | ||
| pass | ||
| setattr(_config, name, value_to_set) | ||
|
Comment on lines
+169
to
+183
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| # Handle placeholder replacement like <api_key> | ||
| elif (isinstance(value, str) and value.startswith('<') | ||
| and value.endswith('>') | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The logic for converting
temperatureto float andmax_tokensto int is duplicated here and in theelifblock below. Consider extracting this conversion logic into a small helper function to improve maintainability and reduce redundancy.