How to use ClearRun with LangChain
Run your chain or model as usual, take the final answer text, and pass it with the prompt to clearrun.evaluate(). ClearRun works on the text, so any LangChain model works.
Last updated
Steps
Install
npm install @langchain/openai @clearrun/sdkScore the final answer
import { ChatOpenAI } from '@langchain/openai'; import { createKernelClient } from '@clearrun/sdk'; const clearrun = createKernelClient(); // reads CLEARRUN_API_KEY const model = new ChatOpenAI({ model: process.env.OPENAI_MODEL }); const prompt = 'When was the Eiffel Tower finished?'; const message = await model.invoke(prompt); const answer = typeof message.content === 'string' ? message.content : JSON.stringify(message.content); const { verdict } = await clearrun.evaluate({ prompt, responseText: answer });
Where to score
Score the answer a person or system will act on. Skip middle steps. Each call uses credits. See Where should ClearRun go in an AI pipeline?