Skip to content

Commit

Permalink
Feat/0.3.1.4 (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
zgqgit committed Jun 17, 2024
2 parents 4ade957 + 1888564 commit 8600631
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/backend/bisheng/api/v1/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ def get_chatlist_list(*,
status_code=200)
def get_online_chat(*,
keyword: Optional[str] = None,
page: Optional[int] = 1,
limit: Optional[int] = 10,
page: Optional[int] = 0,
limit: Optional[int] = 0,
Authorize: AuthJWT = Depends()):
Authorize.jwt_required()
payload = json.loads(Authorize.get_jwt_subject())
Expand Down Expand Up @@ -200,7 +200,9 @@ def get_online_chat(*,
update_time=one.update_time,
flow_type='flow'))
res.sort(key=lambda x: x.update_time, reverse=True)
return resp_200(data=res[(page - 1) * limit:page * limit])
if page and limit:
res = res[(page - 1) * limit:page * limit]
return resp_200(data=res)


@router.websocket('/chat/{flow_id}')
Expand Down
2 changes: 1 addition & 1 deletion src/backend/bisheng/database/models/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def delete_by_message_id(cls, user_id: int, message_id: str):
logger.info('delete_param_error user_id={} chat_id={}', user_id, message_id)
return False

statement = delete(ChatMessage).where(ChatMessage.chat_id == message_id,
statement = delete(ChatMessage).where(ChatMessage.id == message_id,
ChatMessage.user_id == user_id)

with session_getter() as session:
Expand Down
10 changes: 7 additions & 3 deletions src/frontend/src/controllers/API/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export async function postValidatePrompt(
*/
export const getChatsApi = (page) => {
return (axios.get(`/api/v1/chat/list?page=${page}&limit=40`) as Promise<any[]>).then(res =>
res?.filter((el,i) => el.chat_id) || []
res?.filter((el, i) => el.chat_id) || []
)
};

Expand Down Expand Up @@ -417,13 +417,17 @@ export async function GPUlistByFinetuneApi(): Promise<any> {
*/
// 分词
export async function splitWordApi(word: string, messageId: string): Promise<string[]> {
return await axios.get(`/api/v1/qa/keyword?answer=${encodeURIComponent(word)}&message_id=${messageId}`)
return await axios.get(`/api/v1/qa/keyword?message_id=${messageId}`)
}

// 获取 chunks
export async function getSourceChunksApi(chatId: string, messageId: number, keys: string) {
try {
let chunks: any[] = await axios.get(`/api/v1/qa/chunk?chat_id=${chatId}&message_id=${messageId}&keys=${keys}`)
let chunks: any[] = await axios.post(`/api/v1/qa/chunk`, {
chat_id: chatId,
message_id: messageId,
keys,
})

const fileMap = {}
chunks.forEach(chunk => {
Expand Down

0 comments on commit 8600631

Please sign in to comment.