-
Notifications
You must be signed in to change notification settings - Fork 378
feat(py): Added the render_system_prompt function and the dotprompt i… #3503
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
base: main
Are you sure you want to change the base?
Conversation
…nstance to registry
"""Renders a prompt using dotprompt.""" | ||
rendered = await prompt_function(input_) | ||
|
||
if 1 < len(rendered.messages): |
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.
if 1 < len(rendered.messages): | |
if len(rendered.messages) > 1: |
@hendrixmar can we please address the python checks that are failing? |
@@ -408,3 +437,53 @@ def _normalize_prompt_arg( | |||
return prompt | |||
else: | |||
return [prompt] | |||
|
|||
|
|||
async def render_system_prompt(registry: Registry, input_: Any, options: PromptConfig) -> Message: |
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.
input type can be str | Part | list[Part] | PartsResolver
, right?
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.
In the JS implementation I see that it is z.infer and in the Golang it use map[string]any
so not sure which one to use
|
||
elif isinstance(options.system, str): | ||
|
||
user_prompt = await registry.dotprompt.compile(input_) |
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.
It would be great to if we could cache the compiled dotprompt template. Otherwise we have to compile it on every invocation.
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.
…nstance to registry
Description here... Help the reviewer by:
Checklist (if applicable):