Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

2 participants