Skip to content
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

ENG-1094: Validate prompt variables #317

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

thiago-aixplain
Copy link
Collaborator

No description provided.

@thiago-aixplain thiago-aixplain changed the title Validate prompt variables ENG-1094: Validate prompt variables Nov 21, 2024
@thiago-aixplain thiago-aixplain marked this pull request as ready for review November 21, 2024 19:38
Comment on lines 242 to 254
variables = re.findall(r"(?<!{){([^}]+)}(?!})", self.description)
input_data = {"input": FileFactory.to_link(query)}
for variable in variables:
if isinstance(data, dict):
assert (
variable in data or variable in parameters
), f"Variable '{variable}' not found in data or parameters. This variable is required by the agent according to its description ('{self.description}')."
input_data[variable] = data.pop(variable) if variable in data else parameters.pop(variable)
else:
assert (
variable in parameters
), f"Variable '{variable}' not found in parameters. This variable is required by the agent according to its description ('{self.description}')."
input_data[variable] = parameters.pop(variable)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add this piece of code to a method and call it here and in the team agent class. Also, we could test separately in the unit tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@thiago-aixplain thiago-aixplain merged commit f4b251a into development Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants