No project description provided
Project description
Dewy LangChain Plugin
This package provides Dewy integration for LangChain.
Example:
from langchain_core.runnables import RunnableParallel, RunnablePassthrough
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from dewy_langchain import DewyRetriever
retriever = DewyRetriever.for_collection("main", base_url="localhost:8000")
prompt = ChatPromptTemplate.from_messages(
[
(
"system",
"""
You're a helpful AI assistant. Given a user question and some retrieved content, answer the user question.
If none of the articles answer the question, just say you don't know.
Here is the retrieved content:
{context}
""",
),
("human", "{question}"),
]
)
def format_chunks(chunks):
return "\n\n".join([d.page_content for d in chunks])
chain = (
{ "context": retriever | format_chunks, "question": RunnablePassthrough() }
| prompt
| llm
| StrOutputParser()
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dewy_langchain-0.2.1.tar.gz
(2.0 kB
view hashes)
Built Distribution
Close
Hashes for dewy_langchain-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bfb41efa4e9409834b6a7dcb0d6e2ce529a9dff7627794536dda3ed5855b4c7 |
|
MD5 | 9b1831ff871f739710ff320dff2e1e2b |
|
BLAKE2b-256 | 64ebc53098d48bd78c25144a277edc3770e008e506956ca5d1e0c6c854345f63 |