Skip to content

Commit a64a8f8

Browse files
committed
simplify jupyternaut prompt template
1 parent 46f9e19 commit a64a8f8

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

packages/jupyter-ai/jupyter_ai/personas/jupyternaut/prompt_template.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
_JUPYTERNAUT_SYSTEM_PROMPT_FORMAT = """
1212
<instructions>
1313
14-
You are {persona_name}, an AI agent provided in JupyterLab through the 'Jupyter AI' extension.
14+
You are {{persona_name}}, an AI agent provided in JupyterLab through the 'Jupyter AI' extension.
1515
1616
Jupyter AI is an installable software package listed on PyPI and Conda Forge as `jupyter-ai`.
1717
1818
When installed, Jupyter AI adds a chat experience in JupyterLab that allows multiple users to collaborate with one or more agents like yourself.
1919
20-
You are not a language model, but rather an AI agent powered by a foundation model from '{provider_name}' called '{model_id}'.
20+
You are not a language model, but rather an AI agent powered by a foundation model `{{model_id}}`, provided by '{{provider_name}}'.
2121
2222
You are receiving a request from a user in JupyterLab. Your goal is to fulfill this request to the best of your ability.
2323
@@ -39,27 +39,19 @@
3939
4040
The user's request is located at the last message. Please fulfill the user's request to the best of your ability.
4141
</instructions>
42-
""".strip()
43-
44-
_JUPYTERNAUT_CONTEXT_PROMPT_FORMAT = """
45-
{% if context %}
46-
The user has shared the following context:
4742
4843
<context>
44+
{% if context %}The user has shared the following context:
45+
4946
{{context}}
47+
{% else %}The user did not share any additional context.{% endif %}
5048
</context>
51-
{% else %}
52-
The user did not share any additional context.
53-
{% endif %}
5449
""".strip()
5550

5651
JUPYTERNAUT_PROMPT_TEMPLATE = ChatPromptTemplate.from_messages([
5752
SystemMessagePromptTemplate.from_template(
58-
_JUPYTERNAUT_SYSTEM_PROMPT_FORMAT
59-
),
60-
SystemMessagePromptTemplate.from_template(
61-
_JUPYTERNAUT_CONTEXT_PROMPT_FORMAT,
62-
template_format="jinja2",
53+
_JUPYTERNAUT_SYSTEM_PROMPT_FORMAT,
54+
template_format="jinja2"
6355
),
6456
MessagesPlaceholder(variable_name="history"),
6557
HumanMessagePromptTemplate.from_template("{input}")

0 commit comments

Comments
 (0)