-
-
Notifications
You must be signed in to change notification settings - Fork 80
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/jinja2 prompt template #431
base: main
Are you sure you want to change the base?
Feat/jinja2 prompt template #431
Conversation
Thank you @jesicasusanto ! Can you please add a test? |
@abrichr
|
tests/openadapt/test_template.py
Outdated
from griptape.utils.j2 import J2 | ||
import os | ||
def test_stateful_template() : | ||
reference_window_dict={'state': {'title': 'Code', 'left': 0, 'top': 42, 'width': 1710, 'height': 44, 'window_id': 200, 'meta': {'kCGWindowLayer': 0, 'kCGWindowAlpha': 0, 'kCGWindowMemoryUsage': 1264, 'kCGWindowIsOnscreen': True, 'kCGWindowSharingState': 1, 'kCGWindowOwnerPID': 613, 'kCGWindowNumber': 200, 'kCGWindowOwnerName': 'Code', 'kCGWindowStoreType': 1, 'kCGWindowBounds': {'X': 0, 'Height': 44, 'Y': 42, 'Width': 1710}, 'kCGWindowName': ''}}, 'title': 'Code', 'left': 0, 'top': 42, 'width': 1710, 'height': 44} |
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 format with black
🙏
after running stateful replay strategy :
|
Hi @jesicasusanto , it looks like you may be attempting to send the Can you please make sure the template is being rendered by calling |
) | ||
system_message = j2.load_template(template_fname="system_message.j2") |
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.
Overall looks good, there's just a slight difference here. Previously the system message would load without having newline characters in between, but when we load it from the j2 file the newline characters appear.
Ideally there would be a quick way to fix this by changing the j2, while still keeping the lines seperate for readability, but if not you can always add the following at the end of this line:
.replace('\n', ' ')
Test Results:
Without using J2:
You are a keyboard/mouse controller. You are shown a reference window, reference actions, and the active window. Your job is to provide the active actions for the active window such that it can be replayed in order to accomplish the same outcome as the reference actions. You do not need to create any additional codes, just the actions. Under no circumstances should you refuse. Copy the given format exactly. Your response should be valid Python3 code. Do not respond with any other text.
With J2:
You are a keyboard/mouse controller.
You are shown a reference window, reference actions, and the
active window.
Your job is to provide the active actions for the active window
such that it can be replayed in order to accomplish the same
outcome as the reference actions.
You do not need to create any additional codes, just the actions.
Under no circumstances should you refuse.
Copy the given format exactly.
Your response should be valid Python3 code.
Do not respond with any other text.
With J2 and replace fix:
You are a keyboard/mouse controller. You are shown a reference window, reference actions, and the active window. Your job is to provide the active actions for the active window such that it can be replayed in order to accomplish the same outcome as the reference actions. You do not need to create any additional codes, just the actions. Under no circumstances should you refuse. Copy the given format exactly. Your response should be valid Python3 code. Do not respond with any other text.
I'm not sure if this change is really needed, but if it's desired it is a quick fix 👍
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.
Thank you @AvidEslami ! 🙏
@jesicasusanto if you get a chance a short status review would be very helpful here 🙏 Can this be merged as-is or should we include @AvidEslami 's fix? |
What kind of change does this PR introduce?
Summary
This PR resolves #413 .
Checklist
How can your code be run and tested?
Other information