@maximai/maxim-js-langchain
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

Maxim SDK : Langchain wrapper

This is the langchain wrapper built for Maxim JS SDK.

Simplifies integrate Maxim logger with langchain

Install

npm install @maximai/maxim-js-langchain

Initialize Maxim logger

const maxim = new Maxim({apiKey: "maxim-api-key"});
const logger = await maxim.logger({ id: "log-repository-id" });

Start sending traces

logger.trace({ id: "trace-id" });
// Maxim tracer
const maximTracer = new MaximLangchainTracer({
	onGenerationStart: (generationInfo) => {
        logger.traceGeneration("trace-id", generationInfo);
    },
	onGenerationEnd: (generationId, result) => {
		logger.generationResult(generationId, result);
	},
	onGenerationError: (generationId, error) => {
		logger.generationError(generationId, error);
	},
});
const llm = new ChatOpenAI({
	openAIApiKey: openAIKey,
	modelName: "gpt-4o",
	temperature: 0,
	callbacks: [maximTracer],
});
const query = "What's the sum of 3 and 2?";
// Optional step to set input of the trace
trace.input = query
const result = await llm.invoke(query);
// Optional step to set output of the trace
trace.output = result
// Ending the trace
logger.traceEnd("trace-id")

Version changelog

0.0.4

  • Improvement: Changed pining for core Maxim SDK

0.0.3

  • Fix: Token usage were not getting captured for streaming responses

0.0.2

  • Fix: Adds empty tags as {}

0.0.1

  • Early preview

/@maximai/maxim-js-langchain/

    Package Sidebar

    Install

    npm i @maximai/maxim-js-langchain

    Weekly Downloads

    15

    Version

    0.0.4

    License

    UNLICENSED

    Unpacked Size

    16.7 kB

    Total Files

    11

    Last publish

    Collaborators

    • suresh-mxm
    • madhu-maxim
    • dhwanilatmaxim
    • maxim-dev