Skip to content

LangChain Module

Overview

The LangChain module provides integration with the LangChain framework, enabling AI capabilities in the BidScript backend. It serves as an abstraction layer over language models and provides utilities for prompt engineering and response generation.

Module Structure

langchain/
├── langchain.module.ts  # Module definition and dependency configuration
└── langchain.service.ts # Core service with LangChain implementation

Key Components

LangchainModule

The root module that configures dependencies for LangChain functionality:

  • Imports: ConfigModule
  • Providers: LangchainService
  • Exports: LangchainService

LangchainService

The core service that implements LangChain functionality: - LLM initialization and configuration - Prompt template management - Answer generation with context - Integration with Azure OpenAI

Configuration

The module is configured through environment variables:

AZURE_OPENAI_API_KEY
AZURE_OPENAI_API_ENDPOINT
AZURE_OPENAI_API_VERSION
AZURE_OPENAI_API_DEPLOYMENT_NAME