feed tasks to AI
This commit is contained in:
parent
94ac62d585
commit
b700e16dec
Binary file not shown.
@ -58,6 +58,9 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="loader-overlay" id="loader-overlay" style="display: none;">
|
||||
<div class="loader"></div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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
|
||||
]
|
||||
})
|
||||
|
||||
@ -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); }
|
||||
}
|
||||
@ -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); }
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user