# dewy-langchainjs

> Langchain.js integrations for Dewy

Latest version **0.4.0** (published 2024-03-07) · 0 weekly downloads

## Install

```sh
npm install dewy-langchainjs
pnpm add dewy-langchainjs
yarn add dewy-langchainjs
bun add dewy-langchainjs
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2024-03-07 |
| First published | 2024-02-15 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 26.4 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Ryan Michael |
| Maintainers | kerinin |

## Links

- npm: https://www.npmjs.com/package/dewy-langchainjs
- Repository: https://github.com/DewyKB/dewy_langchainjs
- Homepage: https://github.com/DewyKB/dewy-langchainjs#readme
- Issues: https://github.com/DewyKB/dewy-langchainjs/issues
- npm.io page: https://npm.io/package/dewy-langchainjs

## Dependencies (3)

- [dewy-ts](https://npm.io/package/dewy-ts.md) ^0.4
- [langchain](https://npm.io/package/langchain.md) ^0.1
- [@scarf/scarf](https://npm.io/package/@scarf/scarf.md) ^1.3.0

## Recent versions

- 0.4.0 (latest) — 2024-03-07
- 0.2.0 — 2024-02-15

## README

# Dewy Langchain Integration

This package provides Dewy integration for Langchain.js.

Example:

```typescript
import { ChatOpenAI } from "@langchain/openai";
import { PromptTemplate } from "@langchain/core/prompts";
import { RunnablePassthrough, RunnableSequence } from "@langchain/core/runnables";
import { formatDocumentsAsString } from "langchain/util/document";
import { StringOutputParser } from "@langchain/core/output_parsers";

import { Dewy } from 'dewy-ts'; 
import { DewyRetriever } from 'dewy-langchain'; 

const model = new ChatOpenAI({
    openAIApiKey: process.env.OPENAI_API_KEY
});
const dewy = new Dewy({
    BASE: process.env.DEWY_ENDPOINT
});

collection_id = 1;
const retriever = new DewyRetriever({ dewy, collection_id });

const prompt =
PromptTemplate.fromTemplate(`Answer the question based only on the following context:
{context}

Question: {question}`);

const chain = RunnableSequence.from([
    {
        context: retriever.pipe(formatDocumentsAsString),
        question: new RunnablePassthrough(),
    },
    prompt,
    model,
    new StringOutputParser(),
]);
```

---
_Source: https://npm.io/package/dewy-langchainjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
