-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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] Accept non-dict if only 1 prompt input variable #19156
Changes from 5 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -533,3 +533,16 @@ def test_chat_prompt_message_placeholder_partial() -> None: | |
assert prompt.format_messages() == [] | ||
prompt = prompt.partial(history=[("system", "foo")]) | ||
assert prompt.format_messages() == [SystemMessage(content="foo")] | ||
|
||
|
||
def test_messages_prompt_accepts_list() -> None: | ||
prompt = ChatPromptTemplate.from_messages([MessagesPlaceholder("history")]) | ||
value = prompt.invoke([("user", "Hi there")]) # type: ignore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. his is confusing -- are we sure we want to support?, why is it a list of 2-tuples rather than only a 2-tuple? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already support |
||
assert value.to_messages() == [HumanMessage(content="Hi there")] | ||
|
||
# Assert still raises a nice error | ||
prompt = ChatPromptTemplate.from_messages( | ||
[("system", "You are a {foo}"), MessagesPlaceholder("history")] | ||
) | ||
with pytest.raises(TypeError): | ||
prompt.invoke([("user", "Hi there")]) # type: ignore |
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.
@baskaryan do you think this formatting would work?
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.
this should be indented at same level as Examples: (L564)