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

Assigning additional values to an input

While the RunnableLambda function returns a single value, you will also need to preserve the current state. RunnablePassthrough does this by appending new keys to a dictionary holding the user input, so the inputs and results from RunnableLambda can be stored alongside one another.

Complete the code to add an additional output key to the chain's input.

Bu egzersiz, kursun bir parçasıdır

Graph RAG with LangChain and Neo4j

Kursa Göz Atın

Egzersiz talimatları

  • Use the correct runnable class to append an output key to the chain's input.
  • Extract the correct key from the input to multiply by 2 to complete the lambda function.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

# Add an output key to the chain
chain = RunnablePassthrough.____(
  	# Multiply the input by 2
    output=lambda x: x[____] * 2
)

output = chain.invoke({"input": 2})
print(output)
Kodu Düzenle ve Çalıştır