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