feat:新增对话历史列表
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
"""会话创建与历史查询接口"""
|
||||
|
||||
from fastapi import APIRouter, Depends, Request
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Depends, Query, Request
|
||||
|
||||
from app.common.response import ApiResponse, success_response
|
||||
from app.core.auth import get_current_user
|
||||
from app.core.exceptions import BizException
|
||||
from app.schemas.conversation import ConversationCreated, ConversationDetail
|
||||
from app.schemas.conversation import (
|
||||
ConversationCreated,
|
||||
ConversationDetail,
|
||||
ConversationList,
|
||||
)
|
||||
from app.schemas.user import CurrentUser
|
||||
|
||||
router = APIRouter(prefix="/conversations", tags=["Conversation"])
|
||||
@@ -21,6 +27,19 @@ async def create_conversation(
|
||||
)
|
||||
|
||||
|
||||
@router.get("")
|
||||
async def list_conversations(
|
||||
request: Request,
|
||||
user: Annotated[CurrentUser, Depends(get_current_user)],
|
||||
limit: Annotated[int, Query(ge=1, le=100)] = 20,
|
||||
offset: Annotated[int, Query(ge=0)] = 0,
|
||||
) -> ApiResponse[ConversationList]:
|
||||
store = request.app.state.conversation_store
|
||||
return success_response(
|
||||
ConversationList(conversations=await store.list_by_user(user.id, limit, offset))
|
||||
)
|
||||
|
||||
|
||||
@router.get("/{conversation_id}")
|
||||
async def get_conversation(
|
||||
conversation_id: str,
|
||||
|
||||
Reference in New Issue
Block a user