Building a Agent API with LangServe: Integrating Currency Exchange and Trip Planning

Open in ColabOpen in GitHub

Overview

This tutorial guides you through creating a Agent API using LangServe, enabling you to build intelligent and dynamic applications. You'll learn how to leverage LangChain agents and deploy them as production-ready APIs with ease. Discover how to define tools, orchestrate agent workflows, and expose them via a simple and scalable REST interface.

Table of Contents

References


Environment Setup

Set up the environment. You may refer to Environment Setup for more details.

[Note]

  • langchain-opentutorial is a package that provides a set of easy-to-use environment setup, useful functions and utilities for tutorials.

  • You can checkout the langchain-opentutorial for more details.

You can alternatively set API keys in .env file and load it.

[Note] This is not necessary if you've already set API keys in previous steps.

LangServe

LangServe is a tool that allows you to easily deploy LangChain runnables and chains as REST APIs. It integrates with FastAPI and uses Pydantic for data validation.

Implementing a Travel Planning Agent

This section demonstrates how to implement a travel planning agent. This agent suggests customized travel plans based on the user's travel requirements.

Implementing a Currency exchange agent

This section shows how to implement a currency exchange agent. This agent performs currency conversions using real-time exchange rate information.

Testing in the LangServe Playground

LangServe provides a playground for easily testing the implemented agents. This allows you to directly verify and debug the API's behavior.

Last updated