Fix store_api_Key typo in get_components function
This commit is contained in:
parent
c6dfb90bcf
commit
f956c2a77e
2 changed files with 10 additions and 9 deletions
|
|
@ -3,6 +3,7 @@ from typing import Annotated, List, Optional, Union
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||||
|
|
||||||
from langflow.services.auth import utils as auth_utils
|
from langflow.services.auth import utils as auth_utils
|
||||||
from langflow.services.database.models.user.user import User
|
from langflow.services.database.models.user.user import User
|
||||||
from langflow.services.deps import get_settings_service, get_store_service
|
from langflow.services.deps import get_settings_service, get_store_service
|
||||||
|
|
@ -125,7 +126,7 @@ async def get_components(
|
||||||
filter_by_user=filter_by_user,
|
filter_by_user=filter_by_user,
|
||||||
page=page,
|
page=page,
|
||||||
limit=limit,
|
limit=limit,
|
||||||
store_api_Key=store_api_Key,
|
store_api_key=store_api_Key,
|
||||||
)
|
)
|
||||||
except CustomException as exc:
|
except CustomException as exc:
|
||||||
raise HTTPException(status_code=exc.status_code, detail=str(exc)) from exc
|
raise HTTPException(status_code=exc.status_code, detail=str(exc)) from exc
|
||||||
|
|
|
||||||
|
|
@ -416,12 +416,12 @@ class StoreService(Service):
|
||||||
is_component: Optional[bool] = None,
|
is_component: Optional[bool] = None,
|
||||||
filter_by_user: bool = False,
|
filter_by_user: bool = False,
|
||||||
liked: bool = False,
|
liked: bool = False,
|
||||||
store_api_Key: Optional[str] = None,
|
store_api_key: Optional[str] = None,
|
||||||
sort: Optional[List[str]] = None,
|
sort: Optional[List[str]] = None,
|
||||||
page: int = 1,
|
page: int = 1,
|
||||||
limit: int = 15,
|
limit: int = 15,
|
||||||
):
|
):
|
||||||
async with user_data_context(api_key=store_api_Key, store_service=self):
|
async with user_data_context(api_key=store_api_key, store_service=self):
|
||||||
filter_conditions: List[Dict[str, Any]] = self.build_filter_conditions(
|
filter_conditions: List[Dict[str, Any]] = self.build_filter_conditions(
|
||||||
search=search,
|
search=search,
|
||||||
private=private,
|
private=private,
|
||||||
|
|
@ -429,14 +429,14 @@ class StoreService(Service):
|
||||||
is_component=is_component,
|
is_component=is_component,
|
||||||
filter_by_user=filter_by_user,
|
filter_by_user=filter_by_user,
|
||||||
liked=liked,
|
liked=liked,
|
||||||
store_api_Key=store_api_Key,
|
store_api_Key=store_api_key,
|
||||||
)
|
)
|
||||||
|
|
||||||
result: List[ListComponentResponse] = []
|
result: List[ListComponentResponse] = []
|
||||||
authorized = False
|
authorized = False
|
||||||
try:
|
try:
|
||||||
result, metadata = await self.query_components(
|
result, metadata = await self.query_components(
|
||||||
api_key=store_api_Key,
|
api_key=store_api_key,
|
||||||
page=page,
|
page=page,
|
||||||
limit=limit,
|
limit=limit,
|
||||||
sort=sort,
|
sort=sort,
|
||||||
|
|
@ -454,7 +454,7 @@ class StoreService(Service):
|
||||||
if result and not metadata:
|
if result and not metadata:
|
||||||
if len(result) >= limit:
|
if len(result) >= limit:
|
||||||
comp_count = await self.count_components(
|
comp_count = await self.count_components(
|
||||||
api_key=store_api_Key,
|
api_key=store_api_key,
|
||||||
filter_conditions=filter_conditions,
|
filter_conditions=filter_conditions,
|
||||||
use_api_key=liked or filter_by_user,
|
use_api_key=liked or filter_by_user,
|
||||||
)
|
)
|
||||||
|
|
@ -468,13 +468,13 @@ class StoreService(Service):
|
||||||
elif exc.response.status_code == 401:
|
elif exc.response.status_code == 401:
|
||||||
raise APIKeyError("You are not authorized to access this resource. Please check your API key.")
|
raise APIKeyError("You are not authorized to access this resource. Please check your API key.")
|
||||||
|
|
||||||
if store_api_Key:
|
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
|
||||||
if result:
|
if result:
|
||||||
try:
|
try:
|
||||||
updated_result = await update_components_with_user_data(
|
updated_result = await update_components_with_user_data(
|
||||||
result, self, store_api_Key, liked=liked
|
result, self, store_api_key, liked=liked
|
||||||
)
|
)
|
||||||
authorized = True
|
authorized = True
|
||||||
result = updated_result
|
result = updated_result
|
||||||
|
|
@ -482,5 +482,5 @@ class StoreService(Service):
|
||||||
# If we get an error here, it means the user is not authorized
|
# If we get an error here, it means the user is not authorized
|
||||||
authorized = False
|
authorized = False
|
||||||
else:
|
else:
|
||||||
authorized = await self.check_api_key(store_api_Key)
|
authorized = await self.check_api_key(store_api_key)
|
||||||
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