@l7mp/tivadar-ai-langchain-sdk
v0.1.1
Published
TypeScript client for the l7mp/langchain REST API.
Downloads
303
Readme
@l7mp/tivadar-ai-langchain-sdk
TypeScript client for the l7mp/langchain REST API. This wraps the L7mp.io RAG, LLM, and Azure Search APIs.
See full documentation here.
Install
npm install @l7mp/tivadar-ai-langchain-sdkUsage
import {LangChainSDK} from '@l7mp/tivadar-ai-langchain-sdk'
const client = new LangChainSDK({
baseUrl: 'http://localhost:8080',
apiKey: 'YOUR_LLM_API_KEY',
})
const response = await client.v1.llm.chat({
messages: [{role: 'user', content: 'Hello!'}],
})
// Access full generated client if needed:
// const response = await client.v1.api.llm.createChatCompletion('YOUR_LLM_API_KEY', { messages: [...] })RAG document upload
const org = 'acme'
const ragName = 'product-docs'
const file = new Blob(['hello world'], {type: 'text/plain'})
await client.v1.rag.addDocument(ragName, file, org, {
filename: 'hello.txt',
})Azure Search compatible endpoint
const results = await client.v1.azureSearch.search('my-index', {
search: 'find me something',
top: 5,
})Integration tests
The integration test expects bin/langchain to exist, starts a local server with fake providers, and runs a few sanity checks.
make build-all
RUN_LANGCHAIN_INTEGRATION=1 node --test test/integration.test.jsGenerate API types
npm run generateGenerate SDK docs
npm run docsBuild, test, publish
npm run build
npm test
RUN_LANGCHAIN_INTEGRATION=1 npm test
npm publish --access public