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

Allow Messages as input to prompt_chain #403

Merged
merged 4 commits into from
Jan 15, 2025

Conversation

jackmpcollins
Copy link
Owner

@jackmpcollins jackmpcollins commented Jan 15, 2025

Also update docs for this.

Closes #389
Closes #391
Closes #392

Thanks to @alexchandel for the suggestion!

Example

from magentic import prompt_chain, UserMessage

def get_current_weather(location, unit="fahrenheit"):
    """Get the current weather in a given location"""
    return {"temperature": "72", "forecast": ["sunny", "windy"]}

@prompt_chain(
    template=[UserMessage("What's the weather like in {city}?")],
    functions=[get_current_weather],
)
def describe_weather(city: str) -> str: ...

describe_weather("Boston")
'The weather in Boston is currently 72°F with sunny and windy conditions.'

@jackmpcollins jackmpcollins self-assigned this Jan 15, 2025
@jackmpcollins jackmpcollins merged commit 596d77d into main Jan 15, 2025
1 check passed
@jackmpcollins jackmpcollins deleted the add-messages-to-promptchain branch January 15, 2025 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] Add chatprompt_chain decorator SystemMessage / UserMessage / AssistantMessage with @prompt_chain
1 participant