Skip to content

Message param type design, why no default value for role in ChatCompletionSystemMessageParam? #844

Closed Answered by antont
antont asked this question in Q&A
Discussion options

You must be logged in to vote

Ok so TypedDict does not work like that, so am using this. I guess the reason for TypedDict vs. Pydantic there is that people are used to writing dict literals with strings.

#class SystemMessage(ChatCompletionSystemMessageParam):
#    role: Required[Literal["system"]] = "system"
def system_message(content: str):
    return ChatCompletionSystemMessageParam(
        content=content,
        role="system"
    )

def user_message(content: str):
    return ChatCompletionUserMessageParam(
        content=content,
        role="user"
    )

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@RobertCraigie
Comment options

Answer selected by antont
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants