latest changes
This commit is contained in:
@@ -2,7 +2,17 @@ import './styles/app.scss';
|
||||
import htmx from 'htmx.org';
|
||||
|
||||
window.htmx = htmx;
|
||||
document.body.addEventListener('htmx:beforeRequest', function () {
|
||||
document.getElementById('request-failed').hidden = true;
|
||||
});
|
||||
|
||||
document.body.addEventListener('htmx:responseError', function () {
|
||||
document.getElementById('request-failed').hidden = false;
|
||||
});
|
||||
|
||||
document.body.addEventListener('htmx:sendError', function () {
|
||||
document.getElementById('request-failed').hidden = false;
|
||||
});
|
||||
document.addEventListener('click', (event) => {
|
||||
const button = event.target.closest('[data-weather-location]');
|
||||
if (!button) return;
|
||||
|
||||
+30
-1
@@ -353,8 +353,37 @@ header {
|
||||
opacity: .65;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
.tasks-result {
|
||||
.task-result {
|
||||
background-color: #fff;
|
||||
color: #000;
|
||||
padding: 25px;
|
||||
}
|
||||
.htmx-indicator {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.htmx-request.htmx-indicator {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.request-failed {
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
}
|
||||
|
||||
.request-failed:not([hidden]) {
|
||||
display: inline-flex;
|
||||
}
|
||||
@@ -36,7 +36,7 @@ final class BraindumpController extends AbstractController
|
||||
|
||||
// Get the user's brain dump.
|
||||
$brainDump = $request->getPayload()->getString('brain_dump');
|
||||
// dd('THIS IS THE NEW CONTROLLER', $brainDump);
|
||||
// dd('THIS IS THE NEW CONTROLLER', $brainDump);
|
||||
// Tell Ollama exactly what structure we want back.
|
||||
$schema = [
|
||||
'type' => 'object',
|
||||
@@ -96,7 +96,7 @@ final class BraindumpController extends AbstractController
|
||||
|
||||
'json' => [
|
||||
'model' => 'qwen3:4b',
|
||||
|
||||
'think' => false,
|
||||
'prompt' => <<<PROMPT
|
||||
You are a task extraction assistant.
|
||||
|
||||
@@ -133,7 +133,7 @@ PROMPT,
|
||||
);
|
||||
|
||||
$data = $response->toArray();
|
||||
// dd($data);
|
||||
// dd($data);
|
||||
// dd($data['response']);
|
||||
file_put_contents(
|
||||
'/tmp/ollama-response.txt',
|
||||
@@ -141,7 +141,7 @@ PROMPT,
|
||||
);
|
||||
|
||||
//$json = $data['response'] ?? '{"tasks":[]}';
|
||||
$json = $data['thinking'] ?? '{"tasks":[]}';
|
||||
$json = $data['response'] ?? '{"tasks":[]}';
|
||||
$tasks = json_decode($json, true);
|
||||
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
hx-post="{{ path('app_braindump_dump') }}"
|
||||
hx-target="#tasks-result"
|
||||
hx-swap="innerHTML"
|
||||
>
|
||||
hx-indicator="#thinking"
|
||||
hx-disabled-elt="this"
|
||||
>
|
||||
|
||||
<input
|
||||
type="hidden"
|
||||
@@ -34,12 +36,28 @@
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit">
|
||||
✨ Suggest tasks
|
||||
</button>
|
||||
<button type="submit">
|
||||
<span class="material-symbols-outlined">robot_2</span>
|
||||
Suggest tasks
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
<span
|
||||
id="thinking"
|
||||
class="htmx-indicator"
|
||||
aria-live="polite"
|
||||
>
|
||||
<span class="material-symbols-outlined spinner">progress_activity</span>
|
||||
Thinking…
|
||||
</span> <span
|
||||
id="request-failed"
|
||||
class="request-failed"
|
||||
aria-live="assertive"
|
||||
hidden
|
||||
>
|
||||
<span class="material-symbols-outlined">error</span>
|
||||
Something went wrong
|
||||
</span>
|
||||
<div id="tasks-result" class="task-result">
|
||||
{# HTMX will put the proposed tasks here #}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user