Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
klntsky committed Nov 17, 2024
1 parent 42ab47b commit 320629c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions python/src/parse_metaprompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def visitExpr(self, ctx: MetaPromptParser.ExprContext):
if ctx.COMMENT_KW() is not None:
exprs.append({"type": "text", "text": "#"})
elif ctx.META_PROMPT() is not None:
exprs.append({"type": "text", "text": ctx.META_PROMPT().getText()})
exprs.append(
{"type": "text", "text": ctx.META_PROMPT().getText()}
)
elif ctx.EQ_KW() is not None:
exprs.append({"type": "text", "text": "="})
elif ctx.VAR_NAME() is not None:
Expand Down Expand Up @@ -175,7 +177,7 @@ def visitMeta_body(self, ctx: MetaPromptParser.Meta_bodyContext):
for expr in ctx.exprs():
expr_items = self.visit(expr)
exprs.extend(expr_items)
res= {
res = {
"type": "meta",
"exprs": _join_text_pieces(exprs),
}
Expand Down
2 changes: 2 additions & 0 deletions python/tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,12 @@ def test_meta2():
result = parse_metaprompt("[$ []]")
assert result["exprs"] == [meta([t(" []")])]


def test_meta3():
result = parse_metaprompt("[var$ []]")
assert result["exprs"] == [meta([t(" []")], chat_id="var")]


def test_meta4():
result = parse_metaprompt("[VAR_FOO$ []]")
assert result["exprs"] == [meta([t(" []")], chat_id="VAR_FOO")]
Expand Down

0 comments on commit 320629c

Please sign in to comment.