RestGPT is an autonomous agent based on large language models (LLMs), designed to control real-world applications through RESTful APIs. This project is the official code implementation of the paper "RestGPT: Connecting Large Language Models with Real-World RESTful APIs," maintained by Yifan-Song793 on GitHub.
Purpose: RestGPT aims to build an LLM agent capable of autonomously operating real applications, such as querying a movie database (TMDB) or managing a music player (Spotify). By connecting LLMs with RESTful APIs, it addresses practical challenges such as planning, API calls, and response parsing.
Main capabilities: RestGPT adopts an iterative coarse-to-fine online planning framework and includes the following core components:
- Planner: generates a natural language subtask for the current step.
- API selector: maps coarse-grained high-level subtasks into finer-grained API call plans.
- Executor: executes the API call plan. Among these, the caller organizes API parameters according to the API plan and API documentation; the parser generates Python code according to the response schema to parse the API response.
Usage:
- Create a logs folder.
- Obtain an OpenAI key from OpenAI, and obtain a https://developer.themoviedb.org/docs/getting-started to obtain a TMDB key, and obtain a https://developer.spotify.com/documentation/web-api to obtain a Spotify key.
- Fill in your own keys in config.yaml.
- (Optional) Initialize the Spotify environment. Note: this operation will delete all data in Spotify.
- Run the code using the provided commands, then enter the scenario (TMDB/Spotify) and instruction. The project also provides two scripts for running RestGPT on RestBench: run_tmdb.py will sequentially execute all instructions in RestBench-TMDB; for RestBench-Spotify, you need to manually modify query_idx before executing the instructions.
Applicable scenarios: RestGPT is suitable for scenarios that require LLMs to autonomously control real applications, such as querying movie information through natural language instructions (e.g., "Who is the director of today's most popular movie?") or creating music playlists (e.g., "Create a playlist for me containing three Mariah Carey songs, named 'Love Mariah'"). The project also proposes the RestBench benchmark, which includes two scenarios, TMDB and Spotify, for evaluating agent performance.
Limitations: The demo is currently still under construction. Initializing the Spotify environment will delete all data, so caution is required. Running requires users to obtain and configure the API keys for OpenAI, TMDB, and Spotify themselves. More details regarding charges, pricing, platform support, etc., are not yet provided in the materials.