Skip to content

Commit

Permalink
🔧 Update retrieval_chain input handling
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Feb 15, 2024
1 parent 175e1b2 commit dae1a38
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/decorator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from operator import itemgetter

from funcchain.syntax import chain, runnable
from langchain_community.vectorstores.faiss import FAISS
from langchain_core.runnables import Runnable, RunnablePassthrough
Expand All @@ -23,8 +25,8 @@ def generate_poem(topic: str, context: str) -> str:
retriever = vectorstore.as_retriever(search_kwargs={"k": 1})

retrieval_chain: Runnable = {
"context": retriever,
"context": itemgetter("topic") | retriever,
"topic": RunnablePassthrough(),
} | generate_poem

print(retrieval_chain.invoke("love"))
print(retrieval_chain.invoke({"topic": "love"}))

0 comments on commit dae1a38

Please sign in to comment.