Skip to main content

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="http://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()
)

Release files for dewy-langchain 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dewy-langchain 0.3.0
File Size Uploaded
dewy_langchain-0.3.0.tar.gz 2.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dewy-langchain 0.3.0
File Interpreter ABI Platform
dewy_langchain-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 4.6 kB

Release files / dewy_langchain-0.3.0.tar.gz

Download URL dewy_langchain-0.3.0.tar.gz
Size 2.0 kB
Tags Source
SHA-256 checksum
How to use checksums
37110deb5d7c6358a419f57e316ae71cdd8ee1b81849ad932876e0bba2035f0c
BLAKE2b-256 checksum
How to use checksums
e0d87574529bb82ef2beb897bee85adb6b62bc3ecb61ca8b5b07bf463721df92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.8

Release files / dewy_langchain-0.3.0-py3-none-any.whl

Download URL dewy_langchain-0.3.0-py3-none-any.whl
Size 2.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b7519509ca1f8404935271b02c6da701179d845dd587509b818f4610c0bb56e
BLAKE2b-256 checksum
How to use checksums
0dfb76570af4e1d3f806619364d94ccb8a021b5fcef6a7f4ffc47480233f2950
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.8

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page