From b700e16dec9711cb1d0e5ec787fd250c407a9b60 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Wed, 19 Nov 2025 23:38:56 +0000 Subject: [PATCH] feed tasks to AI --- core/__pycache__/views.cpython-311.pyc | Bin 6597 -> 7578 bytes core/templates/core/chat.html | 12 ++++++++++ core/views.py | 19 +++++++++++++++- static/css/custom.css | 29 +++++++++++++++++++++++++ staticfiles/css/custom.css | 29 +++++++++++++++++++++++++ 5 files changed, 88 insertions(+), 1 deletion(-) diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 63db3ad8895c1873b2e6980a2a357c4723428ca7..47221354aa2e21b7041fc54c4c2bee3d7a4671c0 100644 GIT binary patch delta 1491 zcmaJ>TTdHD6rS0&F&J21Fvh?_hKo~7xukKVsv)Iql$JmtiWEdk+REB^H?WTFwRXlK zxa+tNeQ6a%gi+P1AreArqF$s@^`%nPw>IfRr2?`9vf7lNVASwXo;t(g5c<&3&e^ly zeCInebB^|x=;uSygZg?mVB?dE?Yb2BPFj}WWBRQm!(IBD^vHF`f(y{RO&?2L^e4|* z_|BrY*r|F{uPQAG`5MyBW9^Y}RJ>&`-GL4CPr*Zj{w8|O>#54SRo}9Y!_`3be+Vr1 zIr^o)t&p!}VhvX9U2sp>m#ibvYJ+s!H{lB%mC1YQu>ZyW!DkWywb}AoPV&MbMxuv) zqM1r!xUpqPw3RC>mq4VI{^4J#slxM^XsKM0-fn0upsR+76qGTIgcc_#rKFV^Ev2Oi zQZkvO9#@ENqzBNnku^~!Yi10rAsr)PAO&L`6O_f8iP4-+W)YdybQ2K;U&BaAt6cQD zt}=d_B}wfoA?1pZC7fyN7b*!RD~JsoY=r5UM2{ymTTo$n`&9!aS>k~`=#D?FDm!Hj zo4f=5zQW9>ULh+y(kn&Zr1o(mzfgT3|&?lb&QaU+!(&b7s76%xCyYjXo{uIs#J+Vy7TiDyldHwNDcGOpT%KJ6|!^>ijn=vNIN!4`Td@Ro=F zBFt81N{)n~r|HLmbI?bB544QMIp~^Y0){zX5>t4_e49g(-IKADhB50ullOM1o_A7= zXJdD1+MhTUH_}AAK^7Z(s(p-w*r0ul?QYCIUSSjeMJF4-fW36D@n%8xy}XTj$^z)l ziDjpFoL|=Q;KGGnH)snN<-Se%#D;ugT|QZqPj1RX8}iT($d$(jJ8((U`+Y{^J&haaYUs&xuR`c5ga5Pp<^30M*pAi! delta 626 zcmbPbebkt5IWI340}z<{%4Kd6*vPklk5OatdOjJ(S(DH39cMSIVVuBNWIXvEpYr6r z{7#GvlLW5Rm&k*3KtPrNjFrNlB9J1O!Z(L0ow0^(5o0FfGDZf5)j$jZwVWvW1YzPe zoM`H}YPgD-QiN)`@-&qhN>pI#7#LI-iezfJQ;da6)DeO;+^E`TGt6bG<%(oTVW{P< z@j1*8i(oRr44M*?CkZbSV9m@cC@s0g zR$N(JlA2p3Guc)|no)1^da+JM@yV9r;gc7LJInAEfr7Xw5JUukh+q&A1R`Q4{}&gZ z>?xtn!VBb1u8@%9$^bI#fw(w!@&bvajFOYxBJRm26E zNFe&a%&a8!Kvv}gE0F%c%xW$6k%3h~{0oSf;PI7bbDb0`qqGFjxFdolu51iP*|=PF zn2!nwxvDcCRcCe8nLJ;5H)F=+Xc;N40-!2T{1)?0u9x|usL#m$fdL0mqy$t40CD4i A_5c6? diff --git a/core/templates/core/chat.html b/core/templates/core/chat.html index 48f2b91..e75bdf1 100644 --- a/core/templates/core/chat.html +++ b/core/templates/core/chat.html @@ -58,6 +58,9 @@ {% endif %} + @@ -78,6 +81,15 @@ const chatTextarea = document.getElementById('chat-textarea'); const chatForm = document.getElementById('chat-form'); + const loaderOverlay = document.getElementById('loader-overlay'); + + if (chatForm) { + chatForm.addEventListener('submit', function() { + if (loaderOverlay) { + loaderOverlay.style.display = 'flex'; + } + }); + } if (chatTextarea && chatForm) { chatTextarea.addEventListener('keydown', function(e) { diff --git a/core/views.py b/core/views.py index 7567fc5..667fdc5 100644 --- a/core/views.py +++ b/core/views.py @@ -80,9 +80,26 @@ def chat_view(request, conversation_id=None): history.append({"role": role, "content": msg.content}) try: + system_message = { + "role": "system", + "content": "You are a helpful assistant for a project management application. Your purpose is to assist users with their tasks and provide information about the application. The application manages articles and a to-do list." + } + + tasks = TodoItem.objects.all().order_by('created_at') + task_list_str = "\n".join([ + f"- {task.title} (Status: {task.get_status_display()}, Tags: {task.tags or 'None'})" + for task in tasks + ]) + + tasks_context = { + "role": "system", + "content": f"Here is the current list of tasks:\n{task_list_str}" + } + response = LocalAIApi.create_response({ "input": [ - {"role": "system", "content": "You are a helpful assistant."}, + system_message, + tasks_context, *history ] }) diff --git a/static/css/custom.css b/static/css/custom.css index 3cccea4..742ef2f 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -79,6 +79,7 @@ body { display: flex; flex-direction: column; background-color: #ffffff; + position: relative; /* Needed for loader overlay */ } /* Chat Header */ @@ -170,3 +171,31 @@ body { height: 100%; color: #6c757d; } + +/* Loader Styles */ +.loader-overlay { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(255, 255, 255, 0.8); + display: flex; + justify-content: center; + align-items: center; + z-index: 10; +} + +.loader { + border: 5px solid #f3f3f3; /* Light grey */ + border-top: 5px solid #0d6efd; /* Blue */ + border-radius: 50%; + width: 50px; + height: 50px; + animation: spin 1s linear infinite; +} + +@keyframes spin { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } +} \ No newline at end of file diff --git a/staticfiles/css/custom.css b/staticfiles/css/custom.css index 3cccea4..742ef2f 100644 --- a/staticfiles/css/custom.css +++ b/staticfiles/css/custom.css @@ -79,6 +79,7 @@ body { display: flex; flex-direction: column; background-color: #ffffff; + position: relative; /* Needed for loader overlay */ } /* Chat Header */ @@ -170,3 +171,31 @@ body { height: 100%; color: #6c757d; } + +/* Loader Styles */ +.loader-overlay { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(255, 255, 255, 0.8); + display: flex; + justify-content: center; + align-items: center; + z-index: 10; +} + +.loader { + border: 5px solid #f3f3f3; /* Light grey */ + border-top: 5px solid #0d6efd; /* Blue */ + border-radius: 50%; + width: 50px; + height: 50px; + animation: spin 1s linear infinite; +} + +@keyframes spin { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } +} \ No newline at end of file