Contact Us WA Support

10 Tutorial Prompt Chaining Lanjutan yang Wajib Kamu Coba

Ahmad Syafaat

Tutorial Prompt Chaining Lanjutan
Tutorial Prompt Chaining Lanjutan

Pernah nggak sih kamu merasa kalau AI yang kamu pakai itu kurang peka sama konteks atau jawaban yang dihasilkan kadang ngawur? Banyak praktisi AI bahkan mengembangkan workflow prompt mereka lewat platform belajar dan eksperimen seperti Optimuster, biar proses prompting-nya lebih terstruktur dari nol sampai mahir.

Tapi tenang, tutorial prompt chaining lanjutan disini bakal bantu kamu bikin alur percakapan AI lebih canggih, presisi, dan adaptif.

DOWNLOAD EBOOK OPTIMUSTER

10 Tutorial Prompt Chaining Lanjutan

Mulai dari Prompt chaining Claude, Prompt chaining AWS, sampai contoh membuat Prompt ChatGPT, semua bakal dibahas dengan cara yang gampang dipahami tapi tetap powerfull. Dan tanpa basa basi lagi, yuk kita langsung masuk ke tutorialnya!

1. Menguasai Dasar Prompt Chaining Claude

Sebelum langsung eksekusi tutorial prompt chaining lanjutan, penting banget buat paham dulu dasar Prompt chaining Claude. Claude itu salah satu AI yang bisa bikin alur percakapan kompleks dengan rapi. Teknik dasarnya adalah menyusun rangkaian prompt di mana output satu prompt jadi input prompt berikutnya.

Contohnya, kalau kamu mau meringkas dokumen panjang, pertama, minta Claude bikin ringkasan tiap bagian dokumen, baru gabungkan semua ringkasan itu jadi satu. Hasilnya lebih rapi, jelas, dan nggak bikin pusing.

DOWNLOAD EBOOK OPTIMUSTER

2. Rantai Sekuensial untuk Alur Logis

Rantai sekuensial itu mirip kayak bikin cerita step by step. Setiap langkah tutorial prompt chaining lanjutan  dibangun dari output langkah sebelumnya, sehingga alurnya mengalir dan mudah diikuti. Dengan pendekatan ini, AI bisa diarahkan untuk menyelesaikan tugas secara bertahap tanpa kehilangan konteks.

Teknik ini sangat cocok buat tugas yang membutuhkan urutan logis. Misalnya, saat kamu ingin membuat ringkasan teks panjang, setiap bagian teks bisa diringkas terlebih dahulu, baru digabung menjadi satu ringkasan utuh. Dengan cara ini, hasil akhir lebih sistematis dan mudah dipahami.

Contoh penerapan lain adalah pembuatan kode Python. Misalnya kamu ingin membuat fungsi untuk menghitung faktorial.

Pertama, minta AI menulis definisi fungsi, kemudian minta implementasinya, dan terakhir buat case test untuk mengecek fungsi tersebut. Hasilnya jadi lebih rapi, mudah dicek, dan minim kesalahan.

Tutorial Prompt Chaining Lanjutan

3. Rantai Bersyarat: Alur Fleksibel

Rantai bersyarat bikin AI bisa ambil jalur berbeda berdasarkan output sebelumnya. Misalnya, setelah Claude menganalisis sentimen teks, kalau positif, AI kasih ide peluang kalau negatif, AI kasih solusi kalau netral, AI kasih fokus utama.

Dan berikut kode sederhana bisa yang bisa kamu lihat berdasarkan rantai bersyarat dalam tutorial prompt chaining lanjutan:

def check_completeness(text):

    prompt = f”Analyze the following text and respond with only ‘complete’ if it covers all necessary aspects, or ‘incomplete’ if more information is needed:\n\n{text}”

    response = get_completion(prompt)

    return response.strip().lower() == ‘complete’

def looping_prompt_chain(initial_prompt, max_iterations=5):

    current_response = get_completion(initial_prompt)

    if current_response is None:

        return “Initial prompt failed.”

    print(f”Initial output: {current_response}\n”)

    iteration = 0

    while iteration < max_iterations:

        if check_completeness(current_response):

            print(f”Complete response achieved after {iteration + 1} iterations.”)

            return current_response

        print(f”Iteration {iteration + 1}: Response incomplete. Expanding…”)

        expand_prompt = f”The following response is incomplete. Please expand on it to make it more comprehensive:\n\n{current_response}”

        new_response = get_completion(expand_prompt)

        if new_response is None:

            return f”Expansion failed at iteration {iteration + 1}.”

        current_response = new_response

        print(f”Expanded response: {current_response}\n”)

        iteration += 1

    print(f”Maximum iterations ({max_iterations}) reached without achieving completeness.”)

    return current_response

Dengan metode ini, dijamin AI nggak kaku dan responsif sama konteks.

4. Looping Chaining untuk Tugas Berulang

Looping chaining cocok buat proses berulang, misalnya ngecek kelengkapan teks atau data batch. AI bakal iterasi beberapa kali sampai respons dianggap lengkap. Dan berikut contoh implementasinya dalam lanjutan tutorial prompt chaining lanjutan:

def check_completeness(text):

    prompt = f”Analyze the following text and respond with only ‘complete’ if it covers all necessary aspects, or ‘incomplete’ if more information is needed:\n\n{text}”

    response = get_completion(prompt)

    return response.strip().lower() == ‘complete’

 

def looping_prompt_chain(initial_prompt, max_iterations=5):

    current_response = get_completion(initial_prompt)

    if current_response is None:

        return “Initial prompt failed.”

    print(f”Initial output: {current_response}\n”)

    iteration = 0

    while iteration < max_iterations:

        if check_completeness(current_response):

            print(f”Complete response achieved after {iteration + 1} iterations.”)

            return current_response

        print(f”Iteration {iteration + 1}: Response incomplete. Expanding…”)

        expand_prompt = f”The following response is incomplete. Please expand on it to make it more comprehensive:\n\n{current_response}”

        new_response = get_completion(expand_prompt)

        if new_response is None:

            return f”Expansion failed at iteration {iteration + 1}.”

        current_response = new_response

        print(f”Expanded response: {current_response}\n”)

        iteration += 1

    print(f”Maximum iterations ({max_iterations}) reached without achieving completeness.”)

    return current_response

Metode ini bikin AI bisa refine jawabannya terus sampai sempurna, cocok buat dokumen panjang atau teks yang butuh detail maksimal.

Belajar Dapetin Cuan Dari Envato? Klik Disini Sekarang

5. Prompt Chaining AWS untuk Integrasi Sistem

Kalau kamu mulai masuk ke ekosistem AWS, prompt chaining AWS jadi sangat berguna. Misalnya, output dari AI bisa langsung digunakan buat trigger Lambda, memproses data di S3, atau integrasi dengan DynamoDB. Adapun cara pembuatannya adalah sebegai berikut:

  • Step 1: Buat prompt awal untuk generate data.
  • Step 2: Output dari AI langsung di-push ke AWS Lambda untuk diproses.
  • Step 3: Hasil proses disimpan di database atau dikirim ke aplikasi front-end.

Dengan tutorial prompt chaining lanjutan ini, AI nggak cuma jawab pertanyaan, tapi juga bisa bekerja sebagai bagian sistem yang otomatis.

Banyak developer yang menggabungkan teknik ini dengan pendekatan prompting terstruktur seperti yang dibahas di Optimuster.

DOWNLOAD EBOOK OPTIMUSTER

6. Pertanyaan & Jawaban Dokumen Panjang

Prompt chaining tools juga jago banget buat ngerjain Q&A dari dokumen panjang. Caranya, pecah dokumen, ringkas tiap bagian, lalu gunakan ringkasan buat jawab pertanyaan spesifik. Dan untuk kodenya, kamu bisa niru kode berikut:

def document_qa(document, questions):

sections = split_document(document)

summaries = [summarize_section(s) for s in sections]

answers = [answer_question(summaries, q) for q in questions]

return answers

Ini cocok banget buat laporan penelitian, artikel panjang, atau dokumen internal perusahaan.

Tutorial Prompt Chaining Lanjutan

7. Pembuatan Teks dengan Verifikasi Fakta

Selain bikin teks, AI bisa sekalian ngecek fakta. Langkahnya, generate teks → ekstrak fakta → verifikasi fakta → revisi teks sesuai fakta.

def generate_text(topic):

    prompt = f”Write a short paragraph about {topic}.”

    return get_completion(prompt)

def extract_facts(text):

    prompt = f”Extract the key factual claims from the following text, listing each claim on a new line:\n\n{text}”

    return get_completion(prompt)

def verify_facts(facts):

    verified_facts = []

    for fact in facts.split(‘\n’):

        if fact.strip():

            prompt = f”Verify the following statement and respond with ‘True’ if it’s factually correct, ‘False’ if it’s incorrect, or ‘Uncertain’ if it can’t be verified without additional research: ‘{fact}'”

            verification = get_completion(prompt)

            verified_facts.append((fact, verification.strip()))

    return verified_facts

def revise_text(original_text, verified_facts):

    context = “Original text:\n” + original_text + “\n\nVerified facts:\n”

    for fact, verification in verified_facts:

        context += f”- {fact}: {verification}\n”

    prompt = f”{context}\n\nRewrite the original text, keeping the verified facts, removing or correcting any false information, and indicating any uncertain claims as ‘It is claimed that…’ or similar phrasing.”

    return get_completion(prompt)

def text_generation_with_verification(topic):

    print(f”Generating text about: {topic}”)

    # Step 1: Generate initial text

    initial_text = generate_text(topic)

    print(“\nInitial Text:”)

    print(initial_text)

    # Step 2: Extract facts

    extracted_facts = extract_facts(initial_text)

    print(“\nExtracted Facts:”)

    print(extracted_facts)

    # Step 3: Verify facts

    verified_facts = verify_facts(extracted_facts)

    print(“\nVerified Facts:”)

    for fact, verification in verified_facts:

        print(f”- {fact}: {verification}”)

    # Step 4: Revise text

    revised_text = revise_text(initial_text, verified_facts)

    print(“\nRevised Text:”)

    print(revised_text)

    return revised_text

Dengan tutorial prompt chaining lanjutan ini, konten yang kamu buat lebih terpercaya dan siap dipublikasikan.

8. Pembuatan Kode dengan Debugging Otomatis

Prompt chaining juga keren buat coding. Misalnya: minta AI buat kode → generate test case → jalankan tes → debug kode. Semua langkah ini saling terhubung, bikin proses coding lebih cepat dan rapi. Adapun kodenya, kamu bisa lihat di bawah ini:

def generate_code(task):

    prompt = f”Write a Python function to {task}. Include comments explaining the code.”

    return get_completion(prompt)

def generate_test_cases(code):

    prompt = f”Given the following Python code, generate 3 test cases to verify its functionality. Include both input and expected output for each test case:\n\n{code}”

    return get_completion(prompt)

def run_tests(code, test_cases):

    prompt = f”””

    Given the following Python code and test cases, run the tests and report the results.

    If any tests fail, explain why and suggest fixes.

    Code:

    {code}

    Test Cases:

    {test_cases}

    For each test case, respond with:

  1. “PASS” if the test passes
  2. “FAIL” if the test fails, along with an explanation of why it failed and a suggested fix

    “””

    return get_completion(prompt)

def debug_code(code, test_results):

    prompt = f”””

    Given the following Python code and test results, debug the code to fix any issues.

    Provide the corrected code along with explanations of the changes made.

    Original Code:

    {code}

    Test Results:

    {test_results}

    “””

    return get_completion(prompt)

def code_generation_with_debugging(task):

    print(f”Generating code for task: {task}”)

    # Step 1: Generate initial code

    initial_code = generate_code(task)

    print(“\nInitial Code:”)

    print(initial_code)

    # Step 2: Generate test cases

    test_cases = generate_test_cases(initial_code)

    print(“\nGenerated Test Cases:”)

    print(test_cases)

    # Step 3: Run tests

    test_results = run_tests(initial_code, test_cases)

    print(“\nTest Results:”)

    print(test_results)

    # Step 4: Debug code if necessary

    if “FAIL” in test_results:

        print(“\nDebugging code…”)

        debugged_code = debug_code(initial_code, test_results)

        print(“\nDebugged Code:”)

        print(debugged_code)   

        # Optionally, you can run tests again on the debugged code

        print(“\nRe-running tests on debugged code…”)

        final_test_results = run_tests(debugged_code, test_cases)

        print(“\nFinal Test Results:”)

        print(final_test_results)   

        return debugged_code

    else:

        print(“\nAll tests passed. No debugging necessary.”)

        return initial_code

Tutorial prompt chaining lanjutan ini sangat membantu buat programmer pemula yang pengin belajar step by step, atau buat yang pengin workflow codingnya lebih otomatis.

9. Kombinasi Multi Teknik

Kamu bisa menggabungkan beberapa teknik prompt chaining sekaligus, seperti sekuensial, bersyarat, dan looping, bahkan dengan integrasi AWS. Dengan cara ini, setiap langkah saling mendukung sehingga alur kerja AI menjadi lebih terstruktur dan efisien.

Misalnya, kamu bisa mulai dengan generate data, lalu memeriksa kelengkapan informasi menggunakan looping chaining, dan selanjutnya melakukan analisis sentimen dengan rantai bersyarat.

Setelah itu, hasil output bisa langsung di-push ke AWS untuk diproses lebih lanjut atau disimpan dalam database, sebelum akhirnya generate laporan akhir yang komprehensif.

Pendekatan multi-teknik ini membuat AI jadi super cerdas dan adaptif, mampu menyesuaikan responsnya berdasarkan konteks dan kebutuhan setiap langkah dalam alur yang kompleks.

10. Contoh Membuat Prompt ChatGPT yang Canggih

Tutorial prompt chaining lanjutan  yang terakhir, kita masuk ke contoh membuat Prompt ChatGPT. Teknik chaining di sini bisa bikin AI nyambung antar topik, tetap fokus, dan hasil akhirnya lebih presisi. Lalu, contohnya kamu bisa liat di bawah ini:

  • Step 1: Prompt awal untuk brainstorming ide.
  • Step 2: Prompt kedua buat memilah ide terbaik.
  • Step 3: Prompt ketiga buat menulis draft final.

Dengan tutorial prompt chaining lanjutan ini, ChatGPT bisa bikin teks panjang tapi tetap konsisten. Ini pas banget buat content creator atau penulis yang pengin output cepat tapi berkualitas.

Kalau kamu pengin belajar prompting dari nol sampai lanjutan dengan alur yang rapi dan praktis, kamu juga bisa mempelajarinya lewat Optimuster, yang fokus membangun mindset dan workflow prompting secara sistematis. Semoga informasi di atas bermanfaat!

Tutorial Prompt Chaining Lanjutan

DOWNLOAD EBOOK OPTIMUSTER

Bagikan:

Tags

Related Post

Diskon hingga 75% hanya hari ini!

Kuasai hardskill, softskill di era canggih sekarang ini dan dapatkan bimbingan karier terlengkap untuk menjadi talenta digital yang siap kerja.

Lihat Katalog Sekarang