code format
This commit is contained in:
parent
faea687871
commit
0f33313dae
3 changed files with 23 additions and 18 deletions
|
|
@ -66,7 +66,6 @@ async def check_if_store_has_api_key(
|
|||
return {"has_api_key": api_key is not None, "is_valid": is_valid}
|
||||
|
||||
|
||||
|
||||
@router.post("/components/", response_model=CreateComponentResponse, status_code=201)
|
||||
async def share_component(
|
||||
component: StoreComponentCreate,
|
||||
|
|
@ -100,6 +99,7 @@ async def share_component(
|
|||
except Exception as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc))
|
||||
|
||||
|
||||
@router.patch("/components/{component_id}", response_model=CreateComponentResponse, status_code=201)
|
||||
async def update_component(
|
||||
component_id: UUID,
|
||||
|
|
@ -134,6 +134,7 @@ async def update_component(
|
|||
except Exception as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc))
|
||||
|
||||
|
||||
@router.get("/components/", response_model=ListComponentResponseModel)
|
||||
async def get_components(
|
||||
component_id: Annotated[Optional[str], Query()] = None,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
import inspect
|
||||
from typing import Any
|
||||
|
||||
from langchain import (document_loaders, embeddings, llms, memory, requests,
|
||||
text_splitter)
|
||||
from langchain import document_loaders, embeddings, llms, memory, requests, text_splitter
|
||||
from langchain.agents import agent_toolkits
|
||||
from langchain.chat_models import (AzureChatOpenAI, ChatAnthropic, ChatOpenAI,
|
||||
ChatVertexAI)
|
||||
from langchain.chat_models import AzureChatOpenAI, ChatAnthropic, ChatOpenAI, ChatVertexAI
|
||||
from langflow.interface.agents.custom import CUSTOM_AGENTS
|
||||
from langflow.interface.chains.custom import CUSTOM_CHAINS
|
||||
from langflow.interface.importing.utils import import_class
|
||||
|
|
|
|||
|
|
@ -7,16 +7,19 @@ from httpx import HTTPError, HTTPStatusError
|
|||
from loguru import logger
|
||||
|
||||
from langflow.services.base import Service
|
||||
from langflow.services.store.exceptions import (APIKeyError, FilterError,
|
||||
ForbiddenError)
|
||||
from langflow.services.store.schema import (CreateComponentResponse,
|
||||
DownloadComponentResponse,
|
||||
ListComponentResponse,
|
||||
ListComponentResponseModel,
|
||||
StoreComponentCreate)
|
||||
from langflow.services.store.utils import (process_component_data,
|
||||
process_tags_for_post,
|
||||
update_components_with_user_data)
|
||||
from langflow.services.store.exceptions import APIKeyError, FilterError, ForbiddenError
|
||||
from langflow.services.store.schema import (
|
||||
CreateComponentResponse,
|
||||
DownloadComponentResponse,
|
||||
ListComponentResponse,
|
||||
ListComponentResponseModel,
|
||||
StoreComponentCreate,
|
||||
)
|
||||
from langflow.services.store.utils import (
|
||||
process_component_data,
|
||||
process_tags_for_post,
|
||||
update_components_with_user_data,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langflow.services.settings.service import SettingsService
|
||||
|
|
@ -350,7 +353,9 @@ class StoreService(Service):
|
|||
pass
|
||||
raise ValueError(f"Upload failed: {exc}")
|
||||
|
||||
async def update(self, api_key: str, component_id: UUID, component_data: StoreComponentCreate) -> CreateComponentResponse:
|
||||
async def update(
|
||||
self, api_key: str, component_id: UUID, component_data: StoreComponentCreate
|
||||
) -> CreateComponentResponse:
|
||||
# Patch is the same as post, but we need to add the id to the url
|
||||
headers = {"Authorization": f"Bearer {api_key}"}
|
||||
component_dict = component_data.model_dump(exclude_unset=True)
|
||||
|
|
@ -364,8 +369,9 @@ class StoreService(Service):
|
|||
# response = httpx.post(self.components_url, headers=headers, json=component_dict)
|
||||
# response.raise_for_status()
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.patch(self.components_url + f"/{component_id}",
|
||||
headers=headers, json=component_dict)
|
||||
response = await client.patch(
|
||||
self.components_url + f"/{component_id}", headers=headers, json=component_dict
|
||||
)
|
||||
response.raise_for_status()
|
||||
component = response.json()["data"]
|
||||
return CreateComponentResponse(**component)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue