Published on

RestGPT: Connecting Large Language Models with Real-World RESTful APIs

Authors
  • avatar
    Twitter

RestGPT: Connecting Large Language Models with Real-World RESTful APIs

RestGPT is a groundbreaking project that aims to connect large language models (LLMs) with real-world applications using RESTful APIs. The goal is to create an autonomous agent capable of controlling applications such as movie databases and music players. This project tackles the challenges of planning, API calling, and response parsing to enable LLMs to interact with real-world systems effectively.

How Does RestGPT Work?

RestGPT adopts an iterative coarse-to-fine online planning framework and uses an executor to call RESTful APIs. The system consists of three main modules:

  1. Planner: This module generates natural language sub-tasks for each step of the process.
  2. API selector: It maps the high-level sub-tasks to specific API calling plans.
  3. Executor: This module executes the API calling plan, which includes organizing API parameters and generating Python code to parse the API response.

To demonstrate the capabilities of RestGPT, the team behind the project created an example using the TMDB movie database. In this example, RestGPT is able to search for the number of movies directed by Sofia Coppola using the TMDB API. The system generates the necessary API calls and parses the response to provide the desired information.

example

RestBench: Evaluating RestGPT's Performance

To evaluate the performance of RestGPT, the team introduced RestBench, a high-quality test set consisting of two real-world scenarios: TMDB movie database and Spotify music player. RestBench includes realistic user instructions with human-annotated gold solution paths. These paths represent the correct sequence of API calls to achieve the desired outcome.

Here are examples of instructions from RestBench:

TMDB example:

  • Instruction: "Who is the director of today's most trending movie?"
  • Gold solution path:
    • GET /trending/{media_type}/{time_window}
    • GET /movie/{movie_id}/credits

Spotify example:

  • Instruction: "Make me a playlist containing three songs of Mariah Carey and name it 'Love Mariah'."
  • Gold solution path:
    • GET /search
    • GET /me
    • POST /users/{user_id}/playlists
    • POST /playlists/{playlist_id}/tracks

RestBench provides a comprehensive evaluation of RestGPT's performance, with statistics on the number of instructions and the length of solution paths for each scenario.

Benefits and Use Cases

RestGPT opens up exciting possibilities for integrating large language models with real-world applications. Some potential benefits and use cases of this technology include:

  1. Automation of repetitive tasks: RestGPT can automate tasks that involve interacting with RESTful APIs, reducing the need for manual intervention.
  2. Natural language interaction with applications: Users can communicate with applications using natural language instructions, making the interaction more intuitive and user-friendly.
  3. Integration with various systems: RestGPT can be integrated with a wide range of systems that expose RESTful APIs, enabling the control of diverse applications.

Future Directions

The RestGPT project is still under active development, and there are several future directions that the team plans to explore:

  1. Improving planning capabilities: The team aims to enhance the planning module to generate more accurate and context-aware sub-tasks.
  2. Expanding API coverage: RestGPT currently supports a limited number of APIs. The team plans to expand the coverage to include more popular APIs and services.
  3. Enhancing response parsing: The parsing module can be further improved to handle complex API responses and extract relevant information more effectively.

Conclusion

RestGPT is an innovative project that connects large language models with real-world applications through RESTful APIs. By enabling LLMs to interact with real-world systems, RestGPT opens up new possibilities for automation and natural language interaction. The introduction of RestBench provides a comprehensive evaluation of RestGPT's performance, showcasing its potential in various scenarios. With ongoing development and future directions, RestGPT is poised to revolutionize the way we interact with applications and systems.

To learn more about RestGPT and access the code, visit the RestGPT GitHub repository.


This blog post is based on the paper RestGPT: Connecting Large Language Models with Real-World RESTful APIs by Yifan Song, Weimin Xiong, Dawei Zhu, Wenhao Wu, Han Qian, Mingbo Song, Hailiang Huang, Cheng Li, Ke Wang, Rong Yao, Sujian Li.