feed tasks to AI
This commit is contained in:
parent
94ac62d585
commit
b700e16dec
Binary file not shown.
@ -58,6 +58,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<div class="loader-overlay" id="loader-overlay" style="display: none;">
|
||||||
|
<div class="loader"></div>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -78,6 +81,15 @@
|
|||||||
|
|
||||||
const chatTextarea = document.getElementById('chat-textarea');
|
const chatTextarea = document.getElementById('chat-textarea');
|
||||||
const chatForm = document.getElementById('chat-form');
|
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) {
|
if (chatTextarea && chatForm) {
|
||||||
chatTextarea.addEventListener('keydown', function(e) {
|
chatTextarea.addEventListener('keydown', function(e) {
|
||||||
|
|||||||
@ -80,9 +80,26 @@ def chat_view(request, conversation_id=None):
|
|||||||
history.append({"role": role, "content": msg.content})
|
history.append({"role": role, "content": msg.content})
|
||||||
|
|
||||||
try:
|
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({
|
response = LocalAIApi.create_response({
|
||||||
"input": [
|
"input": [
|
||||||
{"role": "system", "content": "You are a helpful assistant."},
|
system_message,
|
||||||
|
tasks_context,
|
||||||
*history
|
*history
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|||||||
@ -79,6 +79,7 @@ body {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
|
position: relative; /* Needed for loader overlay */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Chat Header */
|
/* Chat Header */
|
||||||
@ -170,3 +171,31 @@ body {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
color: #6c757d;
|
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); }
|
||||||
|
}
|
||||||
@ -79,6 +79,7 @@ body {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
|
position: relative; /* Needed for loader overlay */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Chat Header */
|
/* Chat Header */
|
||||||
@ -170,3 +171,31 @@ body {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
color: #6c757d;
|
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); }
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user