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

Runnable lambdas

The RunnableLambda class is a crucial component in a hybrid retrieval chain. Before you use it to execute a vector retriever, let's first practice using it to convert a Python function into an LCEL runnable.

The user-defined reverse() function takes a string and returns it in reverse order. Update the code to return the input string in reverse.

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

Graph RAG with LangChain and Neo4j

Kursa Göz Atın

Egzersiz talimatları

  • Convert the reverse() function into an LCEL runnable.
  • Call the reverse_chain runnable to reverse the string provided.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

def reverse(input):
    return input[::-1]

# Convert reverse() into a runnable
reverse_chain = ____

# Reverse the input
output = reverse_chain.____("Hello, world!")
print(output)
Kodu Düzenle ve Çalıştır