latest changes
This commit is contained in:
@@ -2,7 +2,17 @@ import './styles/app.scss';
|
|||||||
import htmx from 'htmx.org';
|
import htmx from 'htmx.org';
|
||||||
|
|
||||||
window.htmx = htmx;
|
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) => {
|
document.addEventListener('click', (event) => {
|
||||||
const button = event.target.closest('[data-weather-location]');
|
const button = event.target.closest('[data-weather-location]');
|
||||||
if (!button) return;
|
if (!button) return;
|
||||||
|
|||||||
+30
-1
@@ -353,8 +353,37 @@ header {
|
|||||||
opacity: .65;
|
opacity: .65;
|
||||||
text-decoration: line-through;
|
text-decoration: line-through;
|
||||||
}
|
}
|
||||||
.tasks-result {
|
.task-result {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
color: #000;
|
color: #000;
|
||||||
padding: 25px;
|
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.
|
// Get the user's brain dump.
|
||||||
$brainDump = $request->getPayload()->getString('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.
|
// Tell Ollama exactly what structure we want back.
|
||||||
$schema = [
|
$schema = [
|
||||||
'type' => 'object',
|
'type' => 'object',
|
||||||
@@ -96,7 +96,7 @@ final class BraindumpController extends AbstractController
|
|||||||
|
|
||||||
'json' => [
|
'json' => [
|
||||||
'model' => 'qwen3:4b',
|
'model' => 'qwen3:4b',
|
||||||
|
'think' => false,
|
||||||
'prompt' => <<<PROMPT
|
'prompt' => <<<PROMPT
|
||||||
You are a task extraction assistant.
|
You are a task extraction assistant.
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ PROMPT,
|
|||||||
);
|
);
|
||||||
|
|
||||||
$data = $response->toArray();
|
$data = $response->toArray();
|
||||||
// dd($data);
|
// dd($data);
|
||||||
// dd($data['response']);
|
// dd($data['response']);
|
||||||
file_put_contents(
|
file_put_contents(
|
||||||
'/tmp/ollama-response.txt',
|
'/tmp/ollama-response.txt',
|
||||||
@@ -141,7 +141,7 @@ PROMPT,
|
|||||||
);
|
);
|
||||||
|
|
||||||
//$json = $data['response'] ?? '{"tasks":[]}';
|
//$json = $data['response'] ?? '{"tasks":[]}';
|
||||||
$json = $data['thinking'] ?? '{"tasks":[]}';
|
$json = $data['response'] ?? '{"tasks":[]}';
|
||||||
$tasks = json_decode($json, true);
|
$tasks = json_decode($json, true);
|
||||||
|
|
||||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
|||||||
@@ -12,7 +12,9 @@
|
|||||||
hx-post="{{ path('app_braindump_dump') }}"
|
hx-post="{{ path('app_braindump_dump') }}"
|
||||||
hx-target="#tasks-result"
|
hx-target="#tasks-result"
|
||||||
hx-swap="innerHTML"
|
hx-swap="innerHTML"
|
||||||
>
|
hx-indicator="#thinking"
|
||||||
|
hx-disabled-elt="this"
|
||||||
|
>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
type="hidden"
|
type="hidden"
|
||||||
@@ -34,12 +36,28 @@
|
|||||||
></textarea>
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit">
|
<button type="submit">
|
||||||
✨ Suggest tasks
|
<span class="material-symbols-outlined">robot_2</span>
|
||||||
</button>
|
Suggest tasks
|
||||||
|
</button>
|
||||||
|
|
||||||
</form>
|
</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">
|
<div id="tasks-result" class="task-result">
|
||||||
{# HTMX will put the proposed tasks here #}
|
{# HTMX will put the proposed tasks here #}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user