BaşlayınÜcretsiz Başlayın

Implementing few-shot prompting

Time to combine your components together into a chain! The few-shot prompt you created in the previous exercise is still available for you to use, along with examples and example_prompt.

All of the LangChain classes necessary for completing this exercise have been pre-loaded for you.

Bu egzersiz

Developing LLM Applications with LangChain

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Instantiate an OpenAI chat LLM using the ChatOpenAI class.
  • Create a chain from the prompt template and LLM using the | operator, then invoke it using the .invoke() method.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

prompt_template = FewShotPromptTemplate(
    examples=examples,
    example_prompt=example_prompt,
    suffix="Question: {input}",
    input_variables=["input"],
)

# Create an OpenAI chat LLM
llm = ____(model="gpt-4o-mini", api_key='')

# Create and invoke the chain
llm_chain = ____
print(____({"input": "What is Jack's favorite technology on DataCamp?"}))
Kodu Düzenle ve Çalıştır