読み方のヒント
矢印ボタン(または ← → キー)でページを移動できます。
midori/first_call.py の中心は、次の部分です。
def draft_reply(client: OpenAI, inquiry: str) -> str:
response = client.responses.create(
model=model_main(),
instructions="あなたは茶園のネットショップの担当です。丁寧な敬語で、5文以内の返信の下書きを書きます。",
input=inquiry,
max_output_tokens=800,
)
return response.output_text
| 引数 | 意味 |
|---|---|
model | 使うモデルの名前。環境変数 MIDORI_MODEL_MAIN から読む |
instructions | モデルに守らせる前提(役割、書き方) |
input | 頼む文。ここでは問い合わせの本文 |
max_output_tokens | 返させる長さの上限(トークン) |
response.output_text には、モデルが書いた文がまとめて入っています。
python -m midori.first_call
instructions の「5文以内」を「3文以内」に変え、max_output_tokens=800 を max_output_tokens=500 に変えます。
11 / 20