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

Use function instead of FunctionCall in FunctionResultMessage #110

Merged
merged 5 commits into from
Feb 19, 2024

Conversation

jackmpcollins
Copy link
Owner

@jackmpcollins jackmpcollins commented Feb 19, 2024

Warning

Breaking Change: FunctionResultMessage init param function_call: FunctionCall replaced by function: Callable

Only the name of the function is needed when serializing the FunctionResultMessage so we do not need the whole FunctionCall. This simplifies creating @chatprompt function where the chat contains a function call. e.g.

from magentic import (
    chatprompt,
    AssistantMessage,
    UserMessage,
    FunctionCall,
    FunctionResultMessage,
)


def plus(a: int, b: int) -> int:
    return a + b


@chatprompt(
    UserMessage("Use the plus function to add 1 and 2."),
    AssistantMessage(FunctionCall(plus, 1, 2)),
    FunctionResultMessage(3, plus),
)
def do_math() -> str:
    ...


do_math()
# 'The sum of 1 and 2 is 3.'

Also

  • Add test for message_to_openai_message
  • Fix: function name when serializing FunctionResultMessage

@jackmpcollins jackmpcollins self-assigned this Feb 19, 2024
@jackmpcollins jackmpcollins merged commit f66feaf into main Feb 19, 2024
1 check passed
@jackmpcollins jackmpcollins deleted the split-async-from-function-result-message branch February 19, 2024 07:32
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.

1 participant