LangSmith is a new platform designed to assist developers in building, debugging, and monitoring web applications powered by large language models (LLMs) like LangChain AI, offering tools for visualization, testing, and performance optimization.
Abstract
LangSmith emerges as a pivotal tool for developers working with LLM-powered web applications, providing a suite of features to navigate the complexities of LangChain AI. It facilitates quick debugging, visualization of components, and evaluation of prompts and LLMs. The platform also ensures quality assurance by testing chains over datasets and capturing usage traces for valuable insights. Although LangSmith is currently in closed beta, it promises to enhance the development process by enabling a deeper understanding of underlying abstraction methods and mitigating potential challenges associated with LLMs, such as high latency and token consumption. Integration with LangSmith requires access to its APIs and environment setup, followed by monitoring real-time run traces for performance optimization.
Opinions
The author acknowledges the impressive capabilities of LangChain AI but also points out significant drawbacks such as debugging difficulties and high latency periods.
LangSmith is recognized for its potential to alleviate some of the challenges faced when working with LLMs, particularly in the realm of web app development.
The platform's ability to provide real-time updates and intuitive visualizations is highly praised, emphasizing its utility in optimizing web applications.
The author expresses enthusiasm for the future of LangSmith, anticipating its role in developing cost-effective and robust language model-powered web apps.
There is an appreciation for the collaborative features of LangSmith, which allow developers to share insights and work together more effectively.
The author is open to sponsorships, affiliate links, and coding gigs, indicating a willingness to expand the content and capabilities of their platform with community support.
LangChain’s New Tool: LangSmith for ChatBots and Web Apps
Extract the “under-the-hood” information while running large language models (LLMs) with LangChain AI and Streamlit Web Apps
LangSmith is a recently launched platform that assists in working with large language model-powered web applications, offering valuable insights into LangChain AI’s abstraction methods. LangSmith empowers developers to navigate the complexities and challenges associated with utilizing LangChain AI.
While developers recognize the impressive capabilities of LangChain AI, they are no strangers to its significant drawbacks, including debugging difficulties arising from the intricate abstraction process, higher latency periods, and substantial token consumption. Though not all of these challenges can be entirely eliminated, LangSmith comes to the rescue, providing a comprehensive approach to building LLM-powered applications. At its core, LangSmith equips developers with a deep understanding of the underlying abstraction methods and unexpected outcomes, ensuring thorough testing and preparation of applications for production while mitigating potential hurdles.
Let’s explore the key features LangSmith has to offer:
Quick Debugging: Effortlessly debug new chains, agents, or sets of tools to enhance efficiency and performance.
Visualize Components: Gain insightful visualizations of how components such as chains, llms, and retrievers relate and are utilized within the application.
Evaluate Prompts and LLMs: Fine-tune and optimize individual components by evaluating different prompts and language models.
Quality Assurance: Rigorously test given chains over datasets to ensure consistent quality standards are met.
Usage Traces and Insights: Capture usage traces and utilize LLMs or analytics pipelines to generate invaluable insights.
Please take a look at the official blog post from the LangChain team announcing the release of LangSmith, here!
Using LangSmith to monitor LangChain powered Web Apps
Setting up the LangSmith Environment
Before we can integrate LangSmith into our web apps, we must first gain access to LangSmith APIs and endpoints.
To get started, we need to sign up with LangSmith. Keep in mind that LangSmith is currently in a closed beta state, with limited user access. In order to get access, we must sign up on their website and join the waitlist.
Once we’ve logged in with our LangSmith account, we’ll find a user-friendly UI divided into “Projects” and “Datasets & Testing” sections.
Image by Author| Screengrasp showing LangSmith’s minimalistic UI separated into Projects and Datasets & trainings. Lower left corner we will find space for generating API keys and link to the documentation.
Our next step involves creating API keys in the bottom left corner. These keys will grant our web apps access to the LangSmith platform. It’s important to copy and save the API key immediately for future use. To begin, we can create a new project by clicking the “New Project” icon and naming it accordingly. This will lead us to the Setup tab of our newly created project, which provides essential information about the environments required to connect to LangSmith.
Image by author | Screengrasp of the Setup tabs on any project creation within the LangSmith platform. The environment variables are necessary to connect with LangSmith.
We’ll then copy the environment variable information and paste it into our web app’s code. Please note that during this initial step, the “Traces” and “All Runs” tabs will be empty, as we have just begun our journey with LangSmith.
Integrating LangSmith into our Web App
To seamlessly integrate LangSmith into our web applications, we will be using two of our previously built web apps. If you need a quick refresher, you can follow the blog posts for each app:
For each of these use cases, we will create a new project in LangSmith and then copy the corresponding environment variables into the app’s code at the beginning. The following code snippet demonstrates how to use these variables:
import os
# Usually, these values will be the same for both projects
os.environ["LANGCHAIN_TRACING_V2"] = "true"
os.environ["LANGCHAIN_ENDPOINT"] = "https://api.smith.langchain.com"# Replace "YOUR API KEY" with the API key you created
os.environ["LANGCHAIN_API_KEY"] = "YOUR API KEY"# Make sure to use the correct project name
os.environ["LANGCHAIN_PROJECT"] = "Sequential-Chain"
Simply refer to the specific code block for each use case mentioned in the blog posts. With this integration, our web apps will be all set to leverage the power of LangSmith effectively!
Monitoring the Run Traces
As we run our web apps, we’ll notice real-time updates on the “Traces” or “All Run” tabs specific to each project. To gain a broader perspective, make sure to navigate to the corresponding projects. These traces are thoughtfully color-coded and intuitive, providing various attributes such as time-stamps, latency, and tokens usage (among many other key parameters).
Image by author | Traces for different runs for the Sequential chain project.
Exploring the different features available is essential as they allow us to delve into the intricate details of the abstraction methods utilized by LangChain Chain under the hood. Additionally, we can focus on specific “Run Types” to narrow down to individual run traces.
Image by author | Screen grasp of an individual run type.
The “Run Tree” presents a node-like feature with key parameters for evaluation, such as the chains used, time taken to run, and the number of tokens used. Make sure to check on-to the “Metadata” tabs to observe a concise “Run Stats”.
This information is invaluable for developers to experiment with and brainstorm better possibilities for enhancing performance and reducing the cost of our web applications. With these insights at our disposal, we can make informed decisions to optimize the overall performance of our web apps powered by LangSmith. Moreover, LangSmith facilitates seamless collaboration among co-workers by enabling the sharing of selected run traces through a public link, readily available at the top-right corner of the platform.
Conclusion
In this blog post, we demonstrated the integration of LangSmith into our previous web apps built using LangChain AI and Databutton. Despite being in its early stages, LangSmith has already shown its potential in developing cost-effective and robust language model-powered web apps, empowering developers to optimize performance and enhance efficiency. We are excited to witness the future advancements and possibilities that LangSmith will bring to us!
Hi there ! I’m always on the lookout for sponsorship, affiliate links and writing/coding gigs to keep broadening my online contents. Any support, feedback and suggestions is very much appreciated ! Interested ? Drop an email here : [email protected]