Skip to content

Commit

Permalink
Merge pull request #59 from jamakase/feature/backend-api
Browse files Browse the repository at this point in the history
refactor
  • Loading branch information
anntish authored Sep 13, 2024
2 parents 777073d + f24d668 commit 4e0a0ab
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
56 changes: 28 additions & 28 deletions services/backend/services/message_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,31 +120,31 @@ def get_message(conversation_id):
return result, 200


@staticmethod
def get_message_for_ml(conversation_id):
"""
Получает только сообщения и роли отправителей для заданного идентификатора беседы.
:param conversation_id: Идентификатор беседы.
:return: Словарь с сообщениями, и ролями отправителей.
"""

messages = MessageModel.query.filter(MessageModel.conversation_id.in_([conversation_id])).all()

if not messages:
return [
{
"text": None,
"role": None
}
]

formatted_messages = [
{
"text": message.text,
"role": message.role,
}
for message in messages
]

return formatted_messages
# @staticmethod
# def get_message_for_ml(conversation_id):
# """
# Получает только сообщения и роли отправителей для заданного идентификатора беседы.
#
# :param conversation_id: Идентификатор беседы.
# :return: Словарь с сообщениями, и ролями отправителей.
# """
#
# messages = MessageModel.query.filter(MessageModel.conversation_id.in_([conversation_id])).all()
#
# if not messages:
# return [
# {
# "text": None,
# "role": None
# }
# ]
#
# formatted_messages = [
# {
# "text": message.text,
# "role": message.role,
# }
# for message in messages
# ]
#
# return formatted_messages
2 changes: 1 addition & 1 deletion services/backend/services/rag_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def run_question_task(conversation_id, question: str):
}
}

all_messages = MessageService.get_message_for_ml(conversation_id)
all_messages = MessageService.get_message(conversation_id)

query = {
"data": data,
Expand Down

0 comments on commit 4e0a0ab

Please sign in to comment.