Merge branch 'feature/store' of github.com:logspace-ai/langflow into feature/store
This commit is contained in:
commit
3cb0231f2e
3 changed files with 13 additions and 5 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
|
||||
|
|
@ -106,14 +106,20 @@ class StoreService(Service):
|
|||
def download(self, api_key: str, id: str) -> ComponentResponse:
|
||||
url = f"{self.components_url}/{id}"
|
||||
params = {"fields": ",".join(["id", "name", "description", "data"])}
|
||||
component = self._get(url, api_key, params)[0]
|
||||
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"]
|
||||
|
|
|
|||
|
|
@ -553,6 +553,7 @@ export async function saveFlowStore(newFlow: {
|
|||
description?: string;
|
||||
style?: FlowStyleType;
|
||||
is_component?: boolean;
|
||||
parent?: string;
|
||||
}): Promise<FlowType> {
|
||||
try {
|
||||
const response = await api.post(`${BASE_URL_API}store/components/`, {
|
||||
|
|
@ -560,6 +561,7 @@ export async function saveFlowStore(newFlow: {
|
|||
data: newFlow.data,
|
||||
description: newFlow.description,
|
||||
is_component: newFlow.is_component,
|
||||
parent: newFlow.parent,
|
||||
});
|
||||
|
||||
if (response.status !== 201) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue