Skip to content

Commit

Permalink
minor endpoints changes
Browse files Browse the repository at this point in the history
  • Loading branch information
josancamon19 committed Sep 24, 2024
1 parent 5b3df59 commit d2a601c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/lib/backend/http/api/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Future<List<ServerMessage>> getMessagesServer() async {
}

Future<List<ServerMessage>> clearChatServer() async {
var response = await makeApiCall(url: '${Env.apiBaseUrl}v1/clear-chat', headers: {}, method: 'DELETE', body: '');
var response = await makeApiCall(url: '${Env.apiBaseUrl}v1/messages', headers: {}, method: 'DELETE', body: '');
if (response == null) throw Exception('Failed to delete chat');
if (response.statusCode == 200) {
return [ServerMessage.fromJson(jsonDecode(response.body))];
Expand Down
4 changes: 2 additions & 2 deletions backend/database/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def get_messages(uid: str, limit: int = 20, offset: int = 0, include_memories: b
]

return messages


def batch_delete_messages(parent_doc_ref, batch_size=450):
messages_ref = parent_doc_ref.collection('messages')
Expand Down Expand Up @@ -127,4 +127,4 @@ def clear_chat(uid: str):
batch_delete_messages(user_ref)
return None
except Exception as e:
return {"message": str(e)}
return {"message": str(e)}
7 changes: 3 additions & 4 deletions backend/routers/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import database.chat as chat_db
from models.chat import Message, SendMessageRequest, MessageSender
from utils.chat.chat import clear_user_chat_message
from utils.llm import qa_rag, initial_chat_message
from utils.other import endpoints as auth
from utils.plugins import get_plugin_by_id
Expand Down Expand Up @@ -58,9 +57,9 @@ def send_message(
return ai_message


@router.delete('/v1/clear-chat', tags=['chat'], response_model=Message)
def clear_chat(uid: str = Depends(auth.get_current_user_uid)):
err = clear_user_chat_message(uid)
@router.delete('/v1/messages', tags=['chat'], response_model=Message)
def clear_chat_messages(uid: str = Depends(auth.get_current_user_uid)):
err = chat_db.clear_chat(uid)
if err:
raise HTTPException(status_code=500, detail='Failed to clear chat')
return initial_message_util(uid)
Expand Down
6 changes: 0 additions & 6 deletions backend/utils/chat/chat.py

This file was deleted.

0 comments on commit d2a601c

Please sign in to comment.