From c53d8e9bce3f9dbce4c574dcb3f5bb8cf5fc3bd6 Mon Sep 17 00:00:00 2001 From: Yannic Kilcher Date: Thu, 9 Feb 2023 08:52:45 +0100 Subject: [PATCH] changed return type of GET chat --- inference/server/main.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/inference/server/main.py b/inference/server/main.py index 1f9f16af..28e8df22 100644 --- a/inference/server/main.py +++ b/inference/server/main.py @@ -67,6 +67,11 @@ class ChatListEntry(pydantic.BaseModel): id: str +class ChatEntry(pydantic.BaseModel): + id: str + conversation: protocol.Conversation + + class ListChatsResponse(pydantic.BaseModel): chats: list[ChatListEntry] @@ -80,6 +85,9 @@ class DbChatEntry(pydantic.BaseModel): def to_list_entry(self) -> ChatListEntry: return ChatListEntry(id=self.id) + def to_entry(self) -> ChatEntry: + return ChatEntry(id=self.id, conversation=self.conversation) + # TODO: make real database CHATS: dict[str, DbChatEntry] = {} @@ -103,9 +111,9 @@ async def create_chat(request: CreateChatRequest) -> ChatListEntry: @app.get("/chat/{id}") -async def get_chat(id: str) -> protocol.Conversation: +async def get_chat(id: str) -> ChatEntry: """Allows a client to get the current state of a chat.""" - return CHATS[id].conversation + return CHATS[id].to_entry() @app.post("/chat/{id}/message")