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

core[minor]: dict chat prompt template support #25674

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

baskaryan
Copy link
Collaborator

@baskaryan baskaryan commented Aug 22, 2024

  • Support passing dicts as templates to chat prompt template
  • Support making any attribute on a message a runtime variable
  • Significantly simpler than trying to update our existing prompt template classes
    template = ChatPromptTemplate(
        [
            {
                "role": "assistant",
                "content": [
                    {
                        "type": "text",
                        "text": "{text1}",
                        "cache_control": {"type": "ephemeral"},
                    },
                    {"type": "image_url", "image_url": {"path": "{local_image_path}"}},
                ],
                "name": "{name1}",
                "tool_calls": [
                    {
                        "name": "{tool_name1}",
                        "args": {"arg1": "{tool_arg1}"},
                        "id": "1",
                        "type": "tool_call",
                    }
                ],
            },
            {
                "role": "tool",
                "content": "{tool_content2}",
                "tool_call_id": "1",
                "name": "{tool_name1}",
            },
        ]
    )

will likely close #25514 if we like this idea and update to use this logic

@baskaryan baskaryan added the 08 RFC Request for Comment. Solicit design input from other contributors label Aug 22, 2024
from langchain_core.prompts.chat import ChatPromptTemplate


class BaseMessagePromptTemplate(Serializable, ABC):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no change, just moved

Copy link

vercel bot commented Aug 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Oct 26, 2024 9:26pm

return prompt + other


class _DictMessagePromptTemplate(BaseMessagePromptTemplate):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new type

@baskaryan baskaryan added the Ɑ: core Related to langchain-core label Aug 22, 2024
@baskaryan
Copy link
Collaborator Author

TODO:

  • make sure new prompt type can be opened in langsmith playground
  • make sure new prompt type can be saved in prompt hub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
08 RFC Request for Comment. Solicit design input from other contributors Ɑ: core Related to langchain-core
Projects
Status: Internal
Development

Successfully merging this pull request may close these issues.

1 participant