From a7dddbcb1d75167436bcb2f165bd0b953a58857e Mon Sep 17 00:00:00 2001 From: Rodrigo Nader Date: Wed, 6 Mar 2024 01:23:49 -0300 Subject: [PATCH] Add APIRequest component for making HTTP requests --- .../langflow/components/{helpers => data}/APIRequest.py | 4 ++++ 1 file changed, 4 insertions(+) rename src/backend/langflow/components/{helpers => data}/APIRequest.py (96%) diff --git a/src/backend/langflow/components/helpers/APIRequest.py b/src/backend/langflow/components/data/APIRequest.py similarity index 96% rename from src/backend/langflow/components/helpers/APIRequest.py rename to src/backend/langflow/components/data/APIRequest.py index 75abe4e94..86674c781 100644 --- a/src/backend/langflow/components/helpers/APIRequest.py +++ b/src/backend/langflow/components/data/APIRequest.py @@ -2,6 +2,7 @@ import asyncio from typing import List, Optional import httpx +import json from langflow import CustomComponent from langflow.schema import Record @@ -26,10 +27,12 @@ class APIRequest(CustomComponent): "headers": { "display_name": "Headers", "info": "The headers to send with the request.", + "input_types": ["dict"] }, "body": { "display_name": "Body", "info": "The body to send with the request (for POST, PATCH, PUT).", + "input_types": ["dict"] }, "timeout": { "display_name": "Timeout", @@ -53,6 +56,7 @@ class APIRequest(CustomComponent): raise ValueError(f"Unsupported method: {method}") data = body if body else None + data = json.dumps(data) try: response = await client.request( method, url, headers=headers, content=data, timeout=timeout