Imagine a world where language barriers cease to exist, where communication is effortless, and understanding is universal. With LangServe, this vision becomes a reality. Leveraging the power of Retrieval Augmented Generation, LangServe enables seamless cross-lingual communication. Delve into this blog to explore how LangServe revolutionizes the way we connect and understand one another.
What Is LangServe & Why It Exists
LangServe
At LangChain, we understand the importance of making it easier for developers to take LangChain applications from development to production use. That's where LangServe comes in. LangServe is a Python package designed to simplify the deployment of any LangChain chain, agent, or runnable. Its primary goal is to streamline the process of deploying LangChain applications, making it easier for developers to get their applications into the hands of users and receive valuable feedback.
LangServe's Journey to Production
The journey to create LangServe began months ago when we released the LangChain Expression Language (LCEL) and the Runnable protocol. These tools were developed with the goal of supporting and transitioning prototypes from development to production seamlessly. The framework offers several key features that enable this transition, such as:
1. First-class support for streaming
LangChain applications built with LCEL can efficiently stream output from the Language Model (LLM) provider to the output parser, ensuring fast token delivery and optimal performance
2. First-class async support
LCEL chains can be called using both synchronous and asynchronous APIs, making it easy to transition from prototypes to production without code changes.
3. Optimized parallel execution
LCEL chains automatically execute steps in parallel when possible, minimizing latency and improving performance.
4. Support for retries and fallback
Developers can configure retries and fallbacks for any part of their LCEL chains, enhancing their reliability at scale.
5. Accessing intermediate results
Developers can access intermediate results during the execution of complex chains, providing visibility into the process and aiding debugging.
6. Input and output schemas
LCEL chains now feature input and output schemas, enabling validation of inputs and outputs using Pydantic and JSONSchema schemas.
With these features in place, LangServe leverages the capabilities of LCEL to facilitate the rapid transition from LLM ideas to scalable LLM applications in production.
How to Use LangServe to Build Rest APIs for Langchain Applications
LangServe
It is essential to create a new LangServe application within a project directory. During this process, the .env file should be created and integrated with your OpenAI API key.
Setting Up the Project Directory
Utilizing Python, a new project directory is set up to hold the application and necessary assets. The .env file should be created within this directory to define the OPENAI_API_KEY environment variable.
Installing Dependencies and Configuring the Application
Subsequently, you need to install the Langchain-cli package to access the langchain command line tool. Further, you will install poetry and update pip before initializing a LangChain project in the existing directory.
Development Steps
Creating the LangServe application involves opening the server.py file and replacing its contents with specific code for the application. Afterward, testing the application allows you to ensure its functionality by starting the application server.
Adjusting the Dockerfile
Modifying the Dockerfile is necessary to enable Koyeb to pass in the port for the application to run. This step includes updating the Dockerfile created when the new LangChain project was initialized.
Publishing the Repository to GitHub
A crucial step involves committing and pushing the repository to GitHub. This allows the application to be accessed and deployed through Koyeb.
Deployment on Koyeb
Deployment to Koyeb involves creating a web service and selecting GitHub as the deployment option. This method enables the use of a Dockerfile and setting environment variables to enhance the application’s functionality.
Serverless LLM Platform
ChatBees optimizes RAG for internal operations like customer support, employee support, etc., with the most accurate response and easily integrating into their workflows in a low-code, no-code manner. ChatBees' agentic framework automatically chooses the best strategy to improve the quality of responses for these use cases. This improves predictability/accuracy enabling these operations teams to handle higher volume of queries.
Try our Serverless LLM Platform today to 10x your internal operations. Get started for free, no credit card required — sign in with Google and get started on your journey with us today!
6 Benefits of Using LangServe to Deploy Langchain Applications
LangServe
1. Simplified Deployment
LangServe simplifies the transition of LangChain applications from development to deployment, offering a seamless integration journey that bridges the gap between complex AI functionalities and RESTful API exposure.
2. Effortless Integration
LangServe seamlessly integrates with existing LangChain code, allowing developers to leverage their current codebase and expertise without significant alterations, thereby enhancing efficiency and reducing development time.
3. Automatic API Endpoint Creation
LangServe automates the generation of necessary API endpoints, streamlining development efforts and significantly reducing the time required for deployment.
4. Schema Generation and Validation
With intelligent schema inference, LangServe ensures that APIs provide well-defined interfaces, making integration easier and enhancing the user experience.
5. Built-in Middleware
LangServe provides built-in middleware for CORS settings, ensuring secure communication between different domains when calling LangServe endpoints from the browser.
6. FastAPI Integration
LangServe is integrated with FastAPI, enriching the deployment process by simplifying the deployment of LangChain objects as REST APIs and offering built-in middleware for CORS settings.
Use ChatBees’ Serverless LLM to 10x Internal Operations
ChatBees is an innovative platform designed to optimize Response, Accuracy, and Grouping (RAG) for internal operations such as customer support, employee support, and more. This service provides the most accurate responses, seamlessly integrating into workflows with low-code or no-code requirements. The agentic framework within ChatBees automatically selects the best strategy to enhance the quality of responses, leading to improved predictability and accuracy.
This enables operations teams to handle higher query volumes efficiently. ChatBees offers a Serverless RAG feature, which includes secure and performant APIs to connect various data sources like PDFs, CSVs, websites, GDrive, Notion, and Confluence. This allows users to search, chat, and summarize with immediate access to the knowledge base without the need for DevOps deployment.
The benefits of ChatBees are diverse and impactful across various departments
Onboarding
Access onboarding materials and resources rapidly for both customers and internal employees in support, sales, and research teams.
Sales Enablement
Easily find product information and customer data to enhance sales competencies.
Customer Support
Respond to customer inquiries promptly and accurately, improving customer satisfaction
Product & Engineering
Quickly access project data, bug reports, discussions, and resources, promoting efficient collaboration within these teams.
ChatBees offers a call-to-action to try their Serverless LLM Platform today to accelerate internal operations by tenfold. It provides a free trial without the need for a credit card. Users can sign in with Google and embark on a journey of operational enhancement with ChatBees.