-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: added response conversion node #318
base: main
Are you sure you want to change the base?
Conversation
Note(s) for PR Auther:
Note(s) for PR Reviewer(s):
|
def _parse_yamls(self, yaml_config: str) -> Any | None: | ||
""" | ||
Parse YAML string into Python object with error handling. | ||
Attempts two parsing methods: | ||
1. First check: if yaml markers available | ||
- tries parsing after removing yaml markers | ||
2. Else, tries parsing the raw string | ||
|
||
Args: | ||
yaml_config: YAML configuration string | ||
|
||
Returns: | ||
Parsed YAML object or None if parsing fails | ||
""" | ||
try: | ||
# First check: if yaml markers available | ||
if yaml_config[:7] == "```yaml": | ||
# parsing after removing yaml markers | ||
parsed_yaml = yaml.safe_load(yaml_config[8:-4]) | ||
else: | ||
# Parse raw string | ||
parsed_yaml = yaml.safe_load(yaml_config) | ||
|
||
except Exception as e: | ||
logger.error( | ||
f"Error while parsing the yaml : {yaml_config} , Exception : {e}" | ||
) | ||
|
||
return None | ||
|
||
return parsed_yaml |
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.
let's use TypedDict or Pydantic to parse:
class YAMLMetadata(TypedDict):
namespace: str
name: str
class YAMLConfig(TypedDict):
metadata: YAMLMetadata
kind: str
def _parse_yamls(self, yaml_config: str) -> Optional[YAMLConfig]:
"""
Parse YAML string into Python object with error handling.
Returns None if parsing fails.
Args:
yaml_config: YAML configuration string
Returns:
Parsed YAML object or None if parsing fails
Example:
>>> result = converter._parse_yamls("```yaml\\nkind: Deployment\\n```")
>>> if result:
>>> print(f"Parsed YAML: {result}")
>>> else:
>>> print("Failed to parse YAML")
"""
try:
if yaml_config[:7] == "```yaml":
parsed_yaml = yaml.safe_load(yaml_config[8:-4])
else:
parsed_yaml = yaml.safe_load(yaml_config)
return parsed_yaml
except Exception as e:
logger.error(
f"Error while parsing the yaml : {yaml_config} , Exception : {e}"
)
return None
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.
As I see if a yaml is generated but doesn't fit the schema, it returns None.
Have you observed the cases where partial yaml resources are generated? We can discuss this.
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.
As agreed will skip this
src/agents/supervisor/agent.py
Outdated
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.
are both _generate_final_response
and _convert_final_response
methods are shown in Langfuse?
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.
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.
Please rebase on main, there is conflict.
I'd add such instructions for prompts so that LLM outputs fit your logic. We can discuss this.
1. For new resource deployments, wrap the YAML in <YAML-NEW> </YAML-NEW> tags
2. For modifications to existing resources, wrap the YAML in <YAML-UPDATE> </YAML-UPDATE> tags
3. Each YAML configuration must include:
- apiVersion
- kind
- metadata (with at least name and namespace)
4. Multiple YAML configurations should be separated into individual blocks with appropriate tags
Example:
<YAML-NEW>
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-new-app
namespace: default
spec:
...
</YAML-NEW>
<YAML-UPDATE>
apiVersion: v1
kind: Service
metadata:
name: existing-service
namespace: production
spec:
...
</YAML-UPDATE>
Description
Changes proposed in this pull request:
Related issue(s)
#276