بتل کد Battle Codeدارد باز می‌شود…

جواب «Step 1: The Prompt with Borders» چالش 1 از جلسه‌ی 72

سؤال

تابع build_prompt(question, context) را بنویس که دقیقاً این چهار بخش را در چند خط برگرداند: خط دستور RULE، خط <context>، متن زمینه، خط </context>، و Question: <question>. خروجی:
Answer ONLY from the context below. If the answer is not there, say "I don't know".
<context>
Condensation is when the vapour cools high in the sky and forms clouds.
</context>
Question: What is condensation?

راهنما

با "\n".join([...]) پنج خط را به هم بچسبان: [RULE, "<context>", context, "</context>", "Question: " + question].

یک جواب درست

RULE = 'Answer ONLY from the context below. If the answer is not there, say "I don\'t know".'


def build_prompt(question, context):
    lines = [RULE, "<context>", context, "</context>", "Question: " + question]
    return "\n".join(lines)


chunk = "Condensation is when the vapour cools high in the sky and forms clouds."
print(build_prompt("What is condensation?", chunk))

اول خودت امتحان کن؛ جواب‌های دیگر هم قبول است. برگرد و خودت حلش کن