Refactor store service to update components with
user data
This commit is contained in:
parent
e3b0941df9
commit
340a0b4431
1 changed files with 13 additions and 11 deletions
|
|
@ -4,8 +4,6 @@ from uuid import UUID
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
from httpx import HTTPError, HTTPStatusError
|
from httpx import HTTPError, HTTPStatusError
|
||||||
from loguru import logger
|
|
||||||
|
|
||||||
from langflow.services.base import Service
|
from langflow.services.base import Service
|
||||||
from langflow.services.store.schema import (
|
from langflow.services.store.schema import (
|
||||||
CreateComponentResponse,
|
CreateComponentResponse,
|
||||||
|
|
@ -15,6 +13,7 @@ from langflow.services.store.schema import (
|
||||||
StoreComponentCreate,
|
StoreComponentCreate,
|
||||||
)
|
)
|
||||||
from langflow.services.store.utils import process_tags_for_post, update_components_with_user_data
|
from langflow.services.store.utils import process_tags_for_post, update_components_with_user_data
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from langflow.services.settings.service import SettingsService
|
from langflow.services.settings.service import SettingsService
|
||||||
|
|
@ -460,16 +459,19 @@ class StoreService(Service):
|
||||||
elif exc.response.status_code == 401:
|
elif exc.response.status_code == 401:
|
||||||
raise ValueError("You are not authorized to access this resource. Please check your API key.")
|
raise ValueError("You are not authorized to access this resource. Please check your API key.")
|
||||||
|
|
||||||
if store_api_Key and result:
|
if store_api_Key:
|
||||||
# Now, from the result, we need to get the components
|
# Now, from the result, we need to get the components
|
||||||
# the user likes and set the liked_by_user to True
|
# the user likes and set the liked_by_user to True
|
||||||
try:
|
if result:
|
||||||
updated_result = await update_components_with_user_data(result, self, store_api_Key, liked=liked)
|
try:
|
||||||
|
updated_result = await update_components_with_user_data(
|
||||||
|
result, self, store_api_Key, liked=liked
|
||||||
|
)
|
||||||
|
authorized = True
|
||||||
|
result = updated_result
|
||||||
|
except Exception:
|
||||||
|
# If we get an error here, it means the user is not authorized
|
||||||
|
authorized = False
|
||||||
|
else:
|
||||||
authorized = True
|
authorized = True
|
||||||
result = updated_result
|
|
||||||
except Exception:
|
|
||||||
# If we get an error here, it means the user is not authorized
|
|
||||||
authorized = False
|
|
||||||
elif store_api_Key and not result:
|
|
||||||
authorized = True
|
|
||||||
return ListComponentResponseModel(results=result, authorized=authorized, count=comp_count)
|
return ListComponentResponseModel(results=result, authorized=authorized, count=comp_count)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue