Skip to content

Commit

Permalink
fix: using input instead of endpoint request
Browse files Browse the repository at this point in the history
  • Loading branch information
paopa committed Oct 4, 2024
1 parent 1faa186 commit a8e80ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
14 changes: 2 additions & 12 deletions wren-ai-service/src/web/v1/routers/semantics_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -99,19 +90,18 @@ 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,
mdl=request.mdl,
)

background_tasks.add_task(
service.generate, request, service_metadata=asdict(service_metadata)
service.generate, input, service_metadata=asdict(service_metadata)
)
return PostResponse(id=id)

Expand Down
4 changes: 2 additions & 2 deletions wren-ai-service/src/web/v1/services/semantics_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

0 comments on commit a8e80ed

Please sign in to comment.