Fix chat history construction when generating chatml msgs with context

This commit is contained in:
Debanjum Singh Solanky 2024-10-23 03:40:01 -07:00
parent 7d9a06c8ab
commit 3b978b9b67
2 changed files with 2 additions and 2 deletions

View file

@ -203,7 +203,7 @@ def generate_chatml_messages_with_context(
chatml_messages.insert(0, reconstructed_context_message) chatml_messages.insert(0, reconstructed_context_message)
role = "user" if chat["by"] == "you" else "assistant" role = "user" if chat["by"] == "you" else "assistant"
message_content = construct_structured_message(message_content, chat.get("images"), model_type, vision_enabled) message_content = construct_structured_message(chat["message"], chat.get("images"), model_type, vision_enabled)
reconstructed_message = ChatMessage(content=message_content, role=role) reconstructed_message = ChatMessage(content=message_content, role=role)
chatml_messages.insert(0, reconstructed_message) chatml_messages.insert(0, reconstructed_message)

View file

@ -112,7 +112,7 @@ def add_files_filter(request: Request, filter: FilesFilterRequest):
file_filters = ConversationAdapters.add_files_to_filter(request.user.object, conversation_id, files_filter) file_filters = ConversationAdapters.add_files_to_filter(request.user.object, conversation_id, files_filter)
return Response(content=json.dumps(file_filters), media_type="application/json", status_code=200) return Response(content=json.dumps(file_filters), media_type="application/json", status_code=200)
except Exception as e: except Exception as e:
logger.error(f"Error adding file filter {filter.filename}: {e}", exc_info=True) logger.error(f"Error adding file filter {filter.filenames}: {e}", exc_info=True)
raise HTTPException(status_code=422, detail=str(e)) raise HTTPException(status_code=422, detail=str(e))