Skip to content

Commit

Permalink
align response types
Browse files Browse the repository at this point in the history
Signed-off-by: xtzhang1122 <[email protected]>
  • Loading branch information
xtzhang1122 committed Aug 26, 2024
1 parent 6e5c402 commit 2b1edaf
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/core/routes/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,20 @@ async def conversation_stream(offset: int = 0, limit: int = 30, order: str = "up
@router.post("/conversations")
def get_conversations(
offset: int = 0, limit: int = 30, order: str = "updated"
) -> ResponseConversation:
return StreamingResponse(conversation_stream(offset, limit), media_type="application/json")
) -> List[ResponseConversation]:
normalized_responses = {normalize_question(k): v for k, v in responses.items()}
items = list(normalized_responses.items())[offset:offset + limit]
conversations = [
ResponseConversation(
id=str(uuid.uuid4()),
message=ResponseMessage(
content=answer,
type=1,
id=str(uuid.uuid4()),
)
) for _, answer in items
]
return conversations


async def single_conversation_stream(question: str) -> AsyncGenerator[ResponseConversation, None]:
Expand Down

0 comments on commit 2b1edaf

Please sign in to comment.