🐛 fix(service.py): import and use process_tags_for_post function to correctly process tags for post request

 feat(utils.py): add process_tags_for_post function to handle processing of tags for post request
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-10-31 10:44:57 -03:00
commit d7e2d43409
2 changed files with 8 additions and 0 deletions

View file

@ -12,6 +12,7 @@ from langflow.services.store.schema import (
ListComponentResponse,
StoreComponentCreate,
)
from langflow.services.store.utils import process_tags_for_post
if TYPE_CHECKING:
from langflow.services.settings.service import SettingsService
@ -209,6 +210,8 @@ class StoreService(Service):
response = None
if component_dict.get("parent"):
component_dict["parent"] = str(component_dict["parent"])
component_dict = process_tags_for_post(component_dict)
try:
response = httpx.post(
self.components_url, headers=headers, json=component_dict

View file

@ -0,0 +1,5 @@
def process_tags_for_post(component_dict):
tags = component_dict.pop("tags", None)
if tags and all(isinstance(tag, str) for tag in tags):
component_dict["tags"] = [{"tags_id": tag} for tag in tags]
return component_dict