🐛 fix(store.py): pass component object instead of dict to store_service.upload() to fix data type mismatch
🐛 fix(service.py): convert parent UUID to string before sending to store in upload() method to fix data type mismatch
This commit is contained in:
parent
0ce19818ec
commit
e6ae03105f
2 changed files with 10 additions and 4 deletions
|
|
@ -41,7 +41,7 @@ def create_component(
|
|||
):
|
||||
try:
|
||||
decrypted = auth_utils.decrypt_api_key(store_api_Key, settings_service)
|
||||
return store_service.upload(decrypted, component.dict())
|
||||
return store_service.upload(decrypted, component)
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc))
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from langflow.services.base import Service
|
|||
from typing import TYPE_CHECKING, List, Dict, Any, Optional
|
||||
import httpx
|
||||
from httpx import HTTPError
|
||||
from langflow.services.store.schema import ComponentResponse
|
||||
from langflow.services.store.schema import ComponentResponse, StoreComponentCreate
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langflow.services.settings.service import SettingsService
|
||||
|
|
@ -109,11 +109,17 @@ class StoreService(Service):
|
|||
component = self._get(url, api_key, params)
|
||||
return ComponentResponse(**component)
|
||||
|
||||
def upload(self, api_key: str, component_data: Dict[str, Any]) -> ComponentResponse:
|
||||
def upload(
|
||||
self, api_key: str, component_data: StoreComponentCreate
|
||||
) -> ComponentResponse:
|
||||
headers = {"Authorization": f"Bearer {api_key}"}
|
||||
component_dict = component_data.dict(exclude_unset=True)
|
||||
# Parent is a UUID, but the store expects a string
|
||||
if component_dict.get("parent"):
|
||||
component_dict["parent"] = str(component_dict["parent"])
|
||||
try:
|
||||
response = httpx.post(
|
||||
self.components_url, headers=headers, json=component_data
|
||||
self.components_url, headers=headers, json=component_dict
|
||||
)
|
||||
response.raise_for_status()
|
||||
component = response.json()["data"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue