openai-pythonの型
#openai(Pythonライブラリ)
#Pydantic のBaseModelを使っている
client.chat.completions.create
https://github.com/openai/openai-python/blob/v1.36.1/src/openai/resources/chat/completions.py#L609-L642
引数
messages: Iterable[ChatCompletionMessageParam]
https://github.com/openai/openai-python/blob/v1.36.1/src/openai/types/chat/chat_completion_message_param.py#L15
返り値は ChatCompletion(streamはいまは考えていない)
openai.types.chat.ChatCompletion
https://github.com/openai/openai-python/blob/v1.36.1/src/openai/types/chat/chat_completion.py#L40
choices
ChatCompletionMessage
https://github.com/openai/openai-python/blob/v1.36.1/src/openai/types/chat/chat_completion_message.py#L25-L26
contentはstr | None
IMO:だいたい文字列が返ってくる印象なのでNoneが型ヒントされているのは意外だった
usage
CompletionUsage | None
openai.types.CompletionUsage https://github.com/openai/openai-python/blob/v1.36.1/src/openai/types/completion_usage.py#L10