v0.36.0
What's Changed
Document the Chat
class and make it importable from the top level.
docs: https://magentic.dev/chat/
from magentic import Chat, OpenaiChatModel, UserMessage
# Create a new Chat instance
chat = Chat(
messages=[UserMessage("Say hello")],
model=OpenaiChatModel("gpt-4o"),
)
# Append a new user message
chat = chat.add_user_message("Actually, say goodbye!")
print(chat.messages)
# [UserMessage('Say hello'), UserMessage('Actually, say goodbye!')]
# Submit the chat to the LLM to get a response
chat = chat.submit()
print(chat.last_message.content)
# 'Hello! Just kidding—goodbye!'
PRs
- Use public import for ChatCompletionStreamState by @jackmpcollins in #398
- Make Chat class public and add docs by @jackmpcollins in #401
- Remove unused content None from openai messages by @jackmpcollins in #402
Full Changelog: v0.35.0...v0.36.0