10 Software frameworks

 

This chapter covers

  • Building applications with LangChain
  • Solving complex tasks with agents
  • Querying data with LlamaIndex

Up to now, we’ve mostly been using OpenAI’s Python library to interact with language models. This library offers basic functionality for sending prompts and retrieving answers from GPT and other OpenAI models (as well as options for tuning and fine-tuning). The libraries from other providers, such as Anthropic and Cohere, offer similar functionality. As long as your data-analysis tasks are simple, this is probably all you need. However, what if your data analysis requires a complex multistep pipeline, possibly integrating many different data formats?

At that point, you may want to switch to a more powerful software framework. Several higher-level frameworks for building complex applications on top of language models are currently emerging. In this chapter, we’ll discuss two of the most popular contenders: LangChain and LlamaIndex. The former is a general framework for building applications using large language models. What’s more, it comes with various useful built-in components that implement popular use cases for language models. LlamaIndex, on the other hand, specifically supports use cases where language models need to interact with large data sets.

10.1 LangChain

10.2 Classifying reviews with LangChain

10.2.1 Overview

10.2.2 Creating a classification chain

10.2.3 Putting it together

10.2.4 Trying it out

10.3 Agents: Putting the large language model into the driver’s seat

10.4 Building an agent for data analysis

10.4.1 Overview

10.4.2 Creating an agent with LangChain

10.4.3 Complete code for data-analysis agent

10.4.4 Trying it out

10.5 Adding custom tools

10.5.1 The currency converter

10.5.2 Trying it out

10.6 Indexing multimodal data with LlamaIndex