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

feat: use xml tags in system prompts #43

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion bin/generator/prompts.py
Original file line number Diff line number Diff line change
@@ -11,9 +11,13 @@ def __init__(self, prompt_file_name: str, template_data: dict = dict()):
self._template_data = template_data
self._template_data["date"] = date.today().strftime("%A %B %d, %Y")
self._template = template_env.get_template("{}.txt".format(prompt_file_name))
self._debug = False

def generate(self):
return self._template.render(self._template_data)
rendered_prompt = self._template.render(self._template_data)
if self._debug:
print(rendered_prompt)
return rendered_prompt

# Used to generate a new blog post
class GeneratePrompt(PromptTemplate):
@@ -34,3 +38,13 @@ def __init__(self, template_data: dict = dict()):
class ContinuePrompt(PromptTemplate):
def __init__(self, template_data: dict = dict()):
super().__init__("continue", template_data)

if __name__ == "__main__":
rendered_prompt = GeneratePrompt({"title": "Test Title"}).generate()
print(rendered_prompt)
rendered_prompt = ExtendPrompt({"title": "Test Title", "date": date.today().strftime("%A %B %d, %Y")}).generate()
print(rendered_prompt)
rendered_prompt = SummarizePrompt({"title": "Test Title", "date": date.today().strftime("%A %B %d, %Y"), "summary": "This is a test summary."}).generate()
print(rendered_prompt)
rendered_prompt = ContinuePrompt({"title": "Test Title", "date": date.today().strftime("%A %B %d, %Y"), "summary": "This is a test summary.", "continue_text": "This is a test continue text."}).generate()
print(rendered_prompt)
4 changes: 2 additions & 2 deletions bin/generator/prompts/continue.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% extends "base.txt" %}

{% block robot_description %}
{% block robot_description -%}
writing follow-up blog posts in Markdown based on instructions
{% endblock %}
{%- endblock %}

{% block body %}
{% include "shared-body.txt" %}
4 changes: 2 additions & 2 deletions bin/generator/prompts/extend.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% extends "base.txt" %}

{% block robot_description %}
{% block robot_description -%}
extending or reworking blog posts in Markdown based on instructions
{% endblock %}
{%- endblock %}

{% block body %}
{% include "shared-body.txt" %}
4 changes: 2 additions & 2 deletions bin/generator/prompts/generate.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% extends "base.txt" %}

{% block robot_description %}
{% block robot_description -%}
writing blog posts in Markdown based on instructions
{% endblock %}
{%- endblock %}

{% block body %}
{% include "shared-body.txt" %}