From a8e80ed2c601ea8e440a0340cc949f84ddb653ea Mon Sep 17 00:00:00 2001 From: Pao-Sheng Wang Date: Fri, 4 Oct 2024 17:23:06 +0800 Subject: [PATCH] fix: using input instead of endpoint request --- .../src/web/v1/routers/semantics_description.py | 14 ++------------ .../src/web/v1/services/semantics_description.py | 4 ++-- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/wren-ai-service/src/web/v1/routers/semantics_description.py b/wren-ai-service/src/web/v1/routers/semantics_description.py index 1b0165e4c..53adec9dd 100644 --- a/wren-ai-service/src/web/v1/routers/semantics_description.py +++ b/wren-ai-service/src/web/v1/routers/semantics_description.py @@ -70,19 +70,10 @@ class PostRequest(BaseModel): - _id: str | None = None selected_models: list[str] user_prompt: str mdl: str - @property - def id(self) -> str: - return self._id - - @id.setter - def id(self, id: str): - self._id = id - class PostResponse(BaseModel): id: str @@ -99,11 +90,10 @@ async def generate( service_metadata: ServiceMetadata = Depends(get_service_metadata), ) -> PostResponse: id = str(uuid.uuid4()) - request.id = id service = service_container.semantics_description service[id] = SemanticsDescription.Resource(id=id) - SemanticsDescription.Input( + input = SemanticsDescription.Input( id=id, selected_models=request.selected_models, user_prompt=request.user_prompt, @@ -111,7 +101,7 @@ async def generate( ) background_tasks.add_task( - service.generate, request, service_metadata=asdict(service_metadata) + service.generate, input, service_metadata=asdict(service_metadata) ) return PostResponse(id=id) diff --git a/wren-ai-service/src/web/v1/services/semantics_description.py b/wren-ai-service/src/web/v1/services/semantics_description.py index 172c81228..abc8311b6 100644 --- a/wren-ai-service/src/web/v1/services/semantics_description.py +++ b/wren-ai-service/src/web/v1/services/semantics_description.py @@ -77,7 +77,7 @@ async def generate(self, request: Input, **kwargs) -> Resource: return self[request.id] - def __getitem__(self, id: int) -> Resource: + def __getitem__(self, id: str) -> Resource: response = self._cache.get(id) if response is None: @@ -91,5 +91,5 @@ def __getitem__(self, id: int) -> Resource: return response - def __setitem__(self, id: int, value: Resource): + def __setitem__(self, id: str, value: Resource): self._cache[id] = value