mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-09-09 11:15:08 +08:00
changed return type of GET chat
This commit is contained in:
@@ -67,6 +67,11 @@ class ChatListEntry(pydantic.BaseModel):
|
|||||||
id: str
|
id: str
|
||||||
|
|
||||||
|
|
||||||
|
class ChatEntry(pydantic.BaseModel):
|
||||||
|
id: str
|
||||||
|
conversation: protocol.Conversation
|
||||||
|
|
||||||
|
|
||||||
class ListChatsResponse(pydantic.BaseModel):
|
class ListChatsResponse(pydantic.BaseModel):
|
||||||
chats: list[ChatListEntry]
|
chats: list[ChatListEntry]
|
||||||
|
|
||||||
@@ -80,6 +85,9 @@ class DbChatEntry(pydantic.BaseModel):
|
|||||||
def to_list_entry(self) -> ChatListEntry:
|
def to_list_entry(self) -> ChatListEntry:
|
||||||
return ChatListEntry(id=self.id)
|
return ChatListEntry(id=self.id)
|
||||||
|
|
||||||
|
def to_entry(self) -> ChatEntry:
|
||||||
|
return ChatEntry(id=self.id, conversation=self.conversation)
|
||||||
|
|
||||||
|
|
||||||
# TODO: make real database
|
# TODO: make real database
|
||||||
CHATS: dict[str, DbChatEntry] = {}
|
CHATS: dict[str, DbChatEntry] = {}
|
||||||
@@ -103,9 +111,9 @@ async def create_chat(request: CreateChatRequest) -> ChatListEntry:
|
|||||||
|
|
||||||
|
|
||||||
@app.get("/chat/{id}")
|
@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."""
|
"""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")
|
@app.post("/chat/{id}/message")
|
||||||
|
|||||||
Reference in New Issue
Block a user