-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Performed spell check across the rest of code base, and enahnced the …
…yaml paraser code a little (#895) * Performed spell check across the entire documentation Thank you once again! * Performed spell check across the most of code base Folders been checked: - agents - cli - memory - project - tasks - telemetry - tools - translations * Trying to add a max_token for the agents, so they limited by number of tokens. * Performed spell check across the rest of code base, and enahnced the yaml paraser code a little * Small change in the main agent doc * Improve _save_file method to handle both dict and str inputs - Add check for dict type input - Use json.dump for dict serialization - Convert non-dict inputs to string - Remove type ignore comments --------- Co-authored-by: João Moura <joaomdmoura@gmail.com>
- Loading branch information
1 parent
ef5ff71
commit 0a23e1d
Showing
9 changed files
with
78 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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 contains 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 contains 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 contains 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 contains 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 contains 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,17 +1,28 @@ | ||
import re | ||
|
||
|
||
class YamlParser: | ||
@staticmethod | ||
def parse(file): | ||
""" | ||
Parses a YAML file, modifies specific patterns, and checks for unsupported 'context' usage. | ||
Args: | ||
file (file object): The YAML file to parse. | ||
Returns: | ||
str: The modified content of the YAML file. | ||
Raises: | ||
ValueError: If 'context:' is used incorrectly. | ||
""" | ||
content = file.read() | ||
|
||
# Replace single { and } with doubled ones, while leaving already doubled ones intact and the other special characters {# and {% | ||
modified_content = re.sub(r"(?<!\{){(?!\{)(?!\#)(?!\%)", "{{", content) | ||
modified_content = re.sub( | ||
r"(?<!\})(?<!\%)(?<!\#)\}(?!})", "}}", modified_content | ||
) | ||
modified_content = re.sub(r"(?<!\})(?<!\%)(?<!\#)\}(?!})", "}}", modified_content) | ||
|
||
# Check for 'context:' not followed by '[' and raise an error | ||
if re.search(r"context:(?!\s*\[)", modified_content): | ||
raise ValueError( | ||
"Context is currently only supported in code when creating a task. Please use the 'context' key in the task configuration." | ||
"Context is currently only supported in code when creating a task. " | ||
"Please use the 'context' key in the task configuration." | ||
) | ||
|
||
return modified_content |
This file contains 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 contains 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 contains 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