OpenAI API で学ぶプロンプトエンジニアリング
Fouad Trad
Machine Learning Engineer


prompt = "Compose a travel blog"
print(get_response(prompt))
Title: アイスランドの幻想的な景観を巡って
Introduction: 私の旅行ブログへようこそ。本日は、アイスランドでの忘れがたい旅をご紹介します。
Day 1: レイキャビク — 魅力的な首都 [...]
Day 2: ゴールデンサークル — 自然の驚異 [...]
Day 3: 南海岸 — 氷と火の旅 [...]
Day 4: 氷河湖 — 凍てつくワンダーランド [...]
Day 5: ブルーラグーン — しめくくりの癒やし [...]
prompt = """Compose a travel blog as follows:
Step 1: Introduce the destination.
Step 2: Share personal adventures during the trip.
Step 3: Summarize the journey.
"""
print(get_response(prompt))
Title: バルセロナの魅力的な街並みを巡ってStep 1: 目的地を紹介する。 バルセロナへようこそ。スペインの地中海沿岸にある活気あふれる街です [...]Step 2: 旅の体験を共有する。 ゴシック地区の細く曲がりくねった路地を歩き、曲がるたびに隠れた名所を見つけました。 [...]Step 3: 旅を要約する。 旅の終わりに、数々の素晴らしい体験と思い出に心から感謝しました [...]

確認対象の典型的な解答
calculator = """
def add(a, b):
return a + b
def subtract(a, b):
return a - b
def multiply(a, b):
return a * b
def divide(a, b):
return a / b
"""
prompt = f"""Determine if the code delimited
by triple backticks is correct or not.
Answer by yes or no.
```{calculator}```"""
print(get_response(prompt))
Yes
prompt = f"""Determine the correctness of the code delimited by triple backticks
as follows:
Step 1: Check the code correctness in each function.
Step 2: Verify if the divide function handles the case when dividing by 0.
Code: ```{calculator}```"""
print(get_response(prompt))
コードは概ね正しいです。add、subtract、multiply、divide の4関数を定義し、対応する演算を行い結果を返します。ただし、0で割る場合の扱いがなく、ZeroDivisionError になる可能性があります。
ステップ

ステップ

ショット

OpenAI API で学ぶプロンプトエンジニアリング