What's Changed
The @prompt_chain
decorator can now accept a sequence of Message
as input, like @chatprompt
.
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.'
PRs
- Allow Messages as input to prompt_chain by @jackmpcollins in #403
Full Changelog: v0.36.0...v0.37.0