I'll help you create a to-do list app that uses local LLM integration to break down simple instructions into detailed steps. Here's a complete implementation:
HTML Structure (index.html)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Smart To-Do List</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<header>
<h1>🤖 Smart To-Do List</h1>
<p>Enter a simple task and let AI break it down into detailed steps</p>
</header>
<div class="input-section">
<div class="input-group">
<input type="text" id="taskInput" placeholder="e.g., Plan a birthday party for my friend">
<button id="generateBtn">Generate Steps</button>
</div>
<div id="loadingSpinner" class="loading hidden">
<div class="spinner"></div>
<span>Breaking down your task...</span>
</div>
</div>
<div class="tasks-container">
<div id="tasksContainer"></div>
</div>
<div class="settings">
<details>
<summary>⚙️ LLM Settings</summary>
<div class="settings-content">
<label for="llmEndpoint">LLM Endpoint:</label>
<input type="text" id="llmEndpoint" value="http://localhost:11434/api/generate">
<label for="llmModel">Model:</label>
<input type="text" id="llmModel" value="llama2">
<button id="testConnection">Test Connection</button>
<div id="connectionStatus"></div>
</div>
</details>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
CSS Styling (style.css)
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
border-radius: 16px;
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
overflow: hidden;
}
header {
background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
color: white;
padding: 2rem;
text-align: center;
}
header h1 {
font-size: 2.5rem;
margin-bottom: 0.5rem;
}
header p {
opacity: 0.9;
font-size: 1.1rem;
}
.input-section {
padding: 2rem;
border-bottom: 1px solid #e5e7eb;
}
.input-group {
display: flex;
gap: 1rem;
margin-bottom: 1rem;
}
#taskInput {
flex: 1;
padding: 1rem;
border: 2px solid #e5e7eb;
border-radius: 8px;
font-size: 1rem;
transition: border-color 0.3s;
}
#taskInput:focus {
outline: none;
border-color: #4f46e5;
}
#generateBtn {
padding: 1rem 2rem;
background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
font-weight: 600;
transition: transform 0.2s;
}
#generateBtn:hover {
transform: translateY(-2px);
}
#generateBtn:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
.loading {
display: flex;
align-items: center;
gap: 1rem;
color: #6b7280;
}
.loading.hidden {
display: none;
}
.spinner {
width: 20px;
height: 20px;
border: 2px solid #e5e7eb;
border-top: 2px solid #4f46e5;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.tasks-container {
padding: 2rem;
}
.task-group {
margin-bottom: 2rem;
background: #f9fafb;
border-radius: 12px;
padding: 1.5rem;
border-left: 4px solid #4f46e5;
}
.task-title {
font-size: 1.25rem;
font-weight: 600;
color: #1f2937;
margin-bottom: 1rem;
display: flex;
justify-content: between;
align-items: center;
}
.delete-task {
background: #ef4444;
color: white;
border: none;
border-radius: 6px;
padding: 0.25rem 0.75rem;
cursor: pointer;
font-size: 0.875rem;
}
.steps-list {
list-style: none;
}
.step-item {
display: flex;
align-items: flex-start;
gap: 0.75rem;
padding: 0.75rem 0;
border-bottom: 1px solid #e5e7eb;
}
.step-item:last-child {
border-bottom: none;
}
.step-checkbox {
margin-top: 0.25rem;
width: 18px;
height: 18px;
cursor: pointer;
}
.step-text {
flex: 1;
line-height: 1.5;
transition: all 0.3s;
}
.step-item.completed .step-text {
text-decoration: line-through;
opacity: 0.6;
}
.settings {
border-top: 1px solid #e5e7eb;
padding: 1rem 2rem;
}
.settings details summary {
cursor: pointer;
font-weight: 600;
padding: 0.5rem 0;
}
.settings-content {
margin-top: 1rem;
display: grid;
gap: 1rem;
}
.settings-content label {
font-weight: 500;
margin-bottom: 0.25rem;
}
.settings-content input {
padding: 0.5rem;
border: 1px solid #d1d5db;
border-radius: 4px;
}
#testConnection {
padding: 0.5rem 1rem;
background: #10b981;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
#connectionStatus {
padding: 0.5rem;
border-radius: 4px;
font-weight: 500;
}
.status-success {
background: #d1fae5;
color: #065f46;
}
.status-error {
background: #fee2e2;
color: #991b1b;
}
.empty-state {
text-align: center;
padding: 3rem;
color: #6b7280;
}
.empty-state h3 {
font-size: 1.25rem;
margin-bottom: 0.5rem;
}
JavaScript Logic (script.js)
class SmartTodoApp {
constructor() {
this.tasks = JSON.parse(localStorage.getItem('smartTodoTasks')) || [];
this.initializeElements();
this.bindEvents();
this.renderTasks();
}
initializeElements() {
this.taskInput = document.getElementById('taskInput');
this.generateBtn = document.getElementById('generateBtn');
this.loadingSpinner = document.getElementById('loadingSpinner');
this.tasksContainer = document.getElementById('tasksContainer');
this.llmEndpoint = document.getElementById('llmEndpoint');
this.llmModel = document.getElementById('llmModel');
this.testConnectionBtn = document.getElementById('testConnection');
this.connectionStatus = document.getElementById('connectionStatus');
}
bindEvents() {
this.generateBtn.addEventListener('click', () => this.generateTask());
this.taskInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') this.generateTask();
});
this.testConnectionBtn.addEventListener('click', () => this.testConnection());
}
async generateTask() {
const taskDescription = this.taskInput.value.trim();
if (!taskDescription) return;
this.setLoading(true);
try {
const steps = await this.breakDownTask(taskDescription);
const newTask = {
id: Date.now(),
title: taskDescription,
steps: steps.map((step, index) => ({
id: `${Date.now()}-${index}`,
text: step,
completed: false
})),
createdAt: new Date().toISOString()
};
this.tasks.unshift(newTask);
this.saveTasks();
this.renderTasks();
this.taskInput.value = '';
} catch (error) {
console.error('Error generating task:', error);
alert('Failed to generate task steps. Please check your LLM connection.');
} finally {
this.setLoading(false);
}
}
async breakDownTask(taskDescription) {
const prompt = `Break down this task into 3-8 specific, actionable steps. Return only the steps as a numbered list, nothing else:
Task: ${taskDescription}
Steps:`;
const response = await fetch(this.llmEndpoint.value, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: this.llmModel.value,
prompt: prompt,
stream: false,
options: {
temperature: 0.7,
max_tokens: 500
}
})
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
const stepsText = data.response || data.text || '';
// Parse the numbered list into individual steps
const steps = stepsText
.split('\n')
.map(line => line.trim())
.filter(line => line && /^\d+\./.test(line))
.map(line => line.replace(/^\d+\.\s*/, '').trim())
.filter(step => step.length > 0);
return steps.length > 0 ? steps : [taskDescription];
}
async testConnection() {
this.connectionStatus.textContent = 'Testing connection...';
this.connectionStatus.className = '';
try {
const response = await fetch(this.llmEndpoint.value, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: this.llmModel.value,
prompt: 'Hello',
stream: false
})
});
if (response.ok) {
this.connectionStatus.textContent = '✅ Connection successful!';
this.connectionStatus.className = 'status-success';
} else {
throw new Error(`HTTP ${response.status}`);
}
} catch (error) {
this.connectionStatus.textContent = `❌ Connection failed: ${error.message}`;
this.connectionStatus.className = 'status-error';
}
}
toggleStep(taskId, stepId) {
const task = this.tasks.find(t => t.id === taskId);
if (task) {
const step = task.steps.find(s => s.id === stepId);
if (step) {
step.completed = !step.completed;
this.saveTasks();
this.renderTasks();
}
}
}
deleteTask(taskId) {
if (confirm('Are you sure you want to delete this task?')) {
this.tasks = this.tasks.filter(t => t.id !== taskId);
this.saveTasks();
this.renderTasks();
}
}
renderTasks() {
if (this.tasks.length === 0) {
this.tasksContainer.innerHTML = `
<div class="empty-state">
<h3>No tasks yet</h3>
<p>Enter a task above to get started!</p>
</div>
`;
return;
}
this.tasksContainer.innerHTML = this.tasks.map(task => `
<div class="task-group">
<div class="task-title">
<span>${task.title}</span>
<button class="delete-task" onclick="app.deleteTask(${task.id})">Delete</button>
</div>
<ul class="steps-list">
${task.steps.map(step => `
<li class="step-item ${step.completed ? 'completed' : ''}">
<input
type="checkbox"
class="step-checkbox"
${step.completed ? 'checked' : ''}
onchange="app.toggleStep(${task.id}, '${step.id}')"
>
<span class="step-text">${step.text}</span>
</li>
`).join('')}
</ul>
</div>
`).join('');
}
setLoading(isLoading) {
this.generateBtn.disabled = isLoading;
this.loadingSpinner.classList.toggle('hidden', !isLoading);
}
saveTasks() {
localStorage.setItem('smartTodoTasks', JSON.stringify(this.tasks));
}
}
// Initialize the app
const app = new SmartTodoApp();
Setup Instructions
1. Local LLM Setup (Ollama)
First, install and set up Ollama:
# Install Ollama (macOS/Linux)
curl -fsSL https://ollama.ai/install.sh | sh
# Or on Windows, download from https://ollama.ai
# Pull a model (e.g., Llama 2)
ollama pull llama2
# Start the Ollama server
ollama serve
2. Alternative LLM Options
The app can work with other local LLMs by modifying the endpoint:
- LM Studio:
http://localhost:1234/v1/chat/completions
- Text Generation WebUI:
http://localhost:7860/api/v1/generate
- LocalAI:
http://localhost:8080/v1/completions
3. Usage
- Open
index.html in your browser
- Ensure your local LLM is running
- Test the connection in settings
- Enter a simple task like "Plan a birthday party"
- Click "Generate Steps" to see detailed breakdown
4. Features
- Smart Task Breakdown: Converts simple instructions into detailed steps
- Local Privacy: All processing happens on your local LLM
- Progress Tracking: Check off completed steps
- Persistent Storage: Tasks saved in browser localStorage
- Configurable: Easy to switch between different LLM providers
- Responsive Design: Works on desktop and mobile
The app will automatically break down tasks like "Learn Python" into specific steps like "Install Python", "Set up development environment", "Complete basic syntax tutorial", etc.