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

all blocks support jinja template #1288

Merged
merged 1 commit into from
Nov 29, 2024

Conversation

LawyZheng
Copy link
Collaborator

@LawyZheng LawyZheng commented Nov 29, 2024

Important

Adds Jinja template support for block parameters in block.py, enabling dynamic rendering using workflow context.

  • Behavior:
    • Adds format_block_parameter_template_from_workflow_run_context() to format block parameters using Jinja templates.
    • Applies format_potential_template_parameters() to dynamically render parameters in BaseTaskBlock, CodeBlock, TextPromptBlock, DownloadToS3Block, UploadToS3Block, SendEmailBlock, FileParserBlock, and ForLoopBlock.
  • Functions:
    • format_potential_template_parameters() now formats parameters like label, title, url, totp_identifier, navigation_goal, data_extraction_goal, complete_criterion, terminate_criterion, code, llm_key, prompt, sender, subject, body, file_url, and path using Jinja templates.
  • Misc:
    • Removes redundant format_task_block_parameter_template_from_workflow_run_context() method.

This description was created by Ellipsis for ee816e1. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to ee816e1 in 1 minute and 14 seconds

More details
  • Looked at 285 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_8qpD3wBz65jybILo


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

if not potential_template:
return potential_template
template = Template(potential_template)
return template.render(workflow_run_context.values)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding exception handling for template rendering to handle cases where the template is invalid or context keys are missing.

@LawyZheng LawyZheng merged commit d697023 into main Nov 29, 2024
2 checks passed
@LawyZheng LawyZheng deleted the lawy/all-blocks-support-jinja-template branch November 29, 2024 07:24
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.

1 participant