Node Details
- Name:
postApiChain
- Type:
POSTApiChain
- Category: [[API Chain|Chains]]
- Version: 1.0
- Icon: post.svg
- Description: Chain to run queries against POST API
Parameters
-
Language Model (Required)
- Type: BaseLanguageModel
- Description: The language model used to generate API requests and process responses.
-
API Documentation (Required)
- Type: string
- Description: Description of how the API works. Should include details about endpoints, request body structure, and response formats.
- Rows: 4
-
Headers (Optional)
- Type: json
- Description: Headers to be included in the API request.
- Additional Params: true
-
URL Prompt (Optional)
- Type: string
- Description: Prompt used to tell LLMs how to construct the URL and request body. Must contain and placeholders.
- Default: A predefined prompt template for URL and request body construction.
- Rows: 4
- Additional Params: true
-
Answer Prompt (Optional)
- Type: string
- Description: Prompt used to tell LLMs how to process the API response. Must contain , , and placeholders.
- Default: A predefined prompt template for answer generation.
- Rows: 4
- Additional Params: true
Input
- A string containing the user’s question or query about the API.
Output
- A string containing the answer to the user’s question, based on the API response.
How It Works
- The chain receives a user question about the API.
- It uses the language model and the URL prompt to generate an appropriate API URL and request body based on the API documentation and the question.
- The chain makes a POST request to the constructed URL, including any specified headers and the generated request body.
- Upon receiving the API response, it uses the language model and the answer prompt to generate a human-readable answer to the original question.
- The final answer is returned as output.
Use Cases
- Querying external POST APIs to answer user questions
- Automating complex API interactions in chatbots or virtual assistants
- Simplifying interactions with APIs that require structured request bodies
- Creating natural language interfaces for data submission or retrieval from POST APIs
- Integrating multiple POST API sources to answer complex queries or perform multi-step operations
Special Features
- Dynamic Request Generation: Constructs both API URLs and request bodies based on natural language questions.
- Flexible API Documentation: Can work with various POST APIs by providing appropriate documentation.
- Customizable Prompts: Allows fine-tuning of URL/request body construction and answer generation processes.
- Header Support: Enables authentication and other custom headers for API requests.
- Language Model Integration: Leverages advanced language models for intelligent API interaction.
Notes
- The quality of results depends significantly on the completeness and accuracy of the provided API documentation.
- Custom URL and answer prompts can be used to optimize the chain for specific APIs or use cases.
- The chain is designed specifically for POST requests and may not be suitable for APIs requiring other HTTP methods.
- Proper error handling should be implemented when using this chain in production environments.
- The effectiveness of the chain can vary depending on the complexity of the API and the nature of the user queries.
- Care should be taken when constructing request bodies to ensure they meet the API’s requirements.