Add interactive Chat with LLM interface to Web UI

Features:
- Real-time streaming chat interface (ChatGPT-like experience)
- Model selection: Text model (fast) or Vision model (image analysis)
- System prompt toggle: Chat with Miku's personality or raw LLM
- Mood selector: Choose from 14 different emotional states
- Full context integration: Uses complete miku_lore.txt, miku_prompt.txt, and miku_lyrics.txt
- Conversation memory: Maintains chat history throughout session
- Image upload support for vision model
- Horizontal scrolling tabs for responsive design
- Clear chat history functionality
- SSE (Server-Sent Events) for streaming responses
- Keyboard shortcuts (Ctrl+Enter to send)

Technical changes:
- Added POST /chat/stream endpoint in api.py with streaming support
- Updated ChatMessage model with mood, conversation_history, and image_data
- Integrated context_manager for proper Miku personality context
- Added Chat with LLM tab to index.html
- Implemented JavaScript streaming client with EventSource-like handling
- Added CSS for chat messages, typing indicators, and animations
- Made tab navigation horizontally scrollable for narrow viewports
This commit is contained in:
2025-12-13 00:23:03 +02:00
parent 65e6c3e7ea
commit bb82b7f146
23 changed files with 2926 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 KiB

View File

@@ -0,0 +1,158 @@
{
"filename": "image.jpg",
"timestamp": "20251212_183716_009649",
"detections": [
{
"bbox": [
119.55944061279297,
180.97171020507812,
297.92144775390625,
436.08282470703125
],
"confidence": 0.9996753931045532,
"keypoints": [
[
132.7552032470703,
332.19482421875,
1.0409083366394043
],
[
167.63368225097656,
377.03857421875,
0.49831530451774597
],
[
222.4427032470703,
421.88232421875,
0.9701149463653564
],
[
307.1475524902344,
284.8597412109375,
0.6079238653182983
],
[
282.234375,
210.1201629638672,
0.5996946096420288
],
[
115.31597137451172,
314.7555847167969,
0.7496854066848755
],
[
115.31597137451172,
312.2642517089844,
0.5584710836410522
],
[
120.2986068725586,
297.31634521484375,
0.3189491033554077
],
[
132.7552032470703,
249.9812774658203,
0.8169550895690918
],
[
165.14236450195312,
217.59413146972656,
0.7688059210777283
],
[
207.49478149414062,
177.73301696777344,
0.7945058345794678
],
[
132.7552032470703,
324.7208557128906,
0.6811453104019165
],
[
137.7378387451172,
319.73822021484375,
0.7827794551849365
],
[
147.703125,
312.2642517089844,
0.9601166844367981
],
[
140.22915649414062,
337.1774597167969,
0.8893141746520996
],
[
145.21180725097656,
334.6861267089844,
0.9148634672164917
],
[
152.68576049804688,
327.2121887207031,
0.7076182961463928
],
[
165.14236450195312,
282.3684387207031,
0.873072624206543
],
[
177.5989532470703,
254.9639129638672,
0.8900364637374878
],
[
205.0034637451172,
237.52467346191406,
0.9707838296890259
],
[
177.5989532470703,
287.35107421875,
0.954558253288269
],
[
195.03819274902344,
274.89447021484375,
0.9857109785079956
],
[
209.98611450195312,
259.9465637207031,
0.8659088015556335
],
[
145.21180725097656,
349.6340637207031,
0.6900861263275146
],
[
195.03819274902344,
372.0559387207031,
0.9787168502807617
],
[
200.0208282470703,
364.58197021484375,
0.7773717045783997
],
[
224.93402099609375,
357.1080017089844,
0.7449542284011841
],
[
209.98611450195312,
374.5472412109375,
0.8536796569824219
]
]
}
],
"count": 1
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 825 KiB

View File

@@ -0,0 +1,158 @@
{
"filename": "image.jpg",
"timestamp": "20251212_183914_242385",
"detections": [
{
"bbox": [
511.1620178222656,
313.3533630371094,
1083.8155517578125,
839.5020751953125
],
"confidence": 0.9995828866958618,
"keypoints": [
[
548.6305541992188,
551.2622680664062,
0.81919926404953
],
[
615.7383422851562,
696.66259765625,
0.8121110200881958
],
[
817.0618896484375,
808.509033203125,
0.7185730934143066
],
[
1001.6084594726562,
685.4779663085938,
0.6966434121131897
],
[
1063.1240234375,
551.2622680664062,
0.7870713472366333
],
[
559.815185546875,
467.37750244140625,
0.973198652267456
],
[
621.3306884765625,
439.4158935546875,
0.9450849294662476
],
[
688.4385375976562,
428.23126220703125,
0.9495770931243896
],
[
861.8004760742188,
422.6389465332031,
0.9442600607872009
],
[
940.0929565429688,
422.6389465332031,
0.9088742136955261
],
[
1007.2007446289062,
445.0082092285156,
0.7901953458786011
],
[
576.5921020507812,
528.8930053710938,
0.92279052734375
],
[
632.5153198242188,
506.52374267578125,
0.9073525667190552
],
[
699.6231689453125,
528.8930053710938,
0.8589534759521484
],
[
615.7383422851562,
573.631591796875,
0.894051194190979
],
[
649.2922973632812,
579.223876953125,
0.993202805519104
],
[
694.0308227539062,
573.631591796875,
0.8784698843955994
],
[
867.3927612304688,
517.7083740234375,
0.9179519414901733
],
[
945.6852416992188,
500.9314270019531,
0.9570797681808472
],
[
1001.6084594726562,
540.07763671875,
0.9408495426177979
],
[
889.7620239257812,
556.8546142578125,
0.8830338716506958
],
[
934.5006103515625,
573.631591796875,
0.963606059551239
],
[
979.2391967773438,
568.0392456054688,
0.9247269630432129
],
[
777.9156494140625,
623.9624633789062,
0.9716311693191528
],
[
733.1770629882812,
691.0703125,
0.8924270868301392
],
[
789.1002807617188,
679.8856811523438,
0.9534333944320679
],
[
861.8004760742188,
691.0703125,
0.9393677711486816
],
[
805.8772583007812,
763.7704467773438,
0.9732789397239685
]
]
}
],
"count": 1
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

@@ -0,0 +1,158 @@
{
"filename": "image.jpg",
"timestamp": "20251212_184651_299996",
"detections": [
{
"bbox": [
679.526123046875,
314.5827331542969,
1048.38037109375,
686.7960205078125
],
"confidence": 0.9886683225631714,
"keypoints": [
[
760.3587036132812,
600.6489868164062,
0.8326239585876465
],
[
847.59619140625,
658.8073120117188,
0.8956679105758667
],
[
974.8175659179688,
658.8073120117188,
0.7903480529785156
],
[
1040.2457275390625,
487.9672546386719,
0.8313735127449036
],
[
989.3571166992188,
360.74591064453125,
0.9052637815475464
],
[
694.9306030273438,
542.4906616210938,
0.9268804788589478
],
[
709.47021484375,
513.4114990234375,
0.9603891968727112
],
[
731.279541015625,
487.9672546386719,
0.9192783236503601
],
[
807.6123657226562,
389.8250732421875,
0.972201943397522
],
[
840.326416015625,
357.11102294921875,
0.940582275390625
],
[
880.310302734375,
324.39697265625,
0.869667649269104
],
[
756.7238159179688,
582.4745483398438,
0.8402314186096191
],
[
756.7238159179688,
549.760498046875,
0.9118363857269287
],
[
789.4378662109375,
531.5859985351562,
0.9668882489204407
],
[
793.0728149414062,
593.3792114257812,
0.9368247985839844
],
[
807.6123657226562,
575.2047729492188,
0.8808077573776245
],
[
818.5170288085938,
560.6651611328125,
0.9203211069107056
],
[
851.2311401367188,
444.3485107421875,
0.9373521208763123
],
[
876.6753540039062,
400.7297668457031,
0.9984884262084961
],
[
927.5639038085938,
382.5552978515625,
0.9292656183242798
],
[
883.9451904296875,
466.15789794921875,
0.9265365600585938
],
[
916.6592407226562,
447.9833984375,
0.9233924150466919
],
[
934.8336791992188,
426.1740417480469,
0.7806099653244019
],
[
829.4217529296875,
575.2047729492188,
0.9482753276824951
],
[
894.849853515625,
604.283935546875,
0.9339636564254761
],
[
902.11962890625,
597.0140991210938,
0.9017537832260132
],
[
923.9290161132812,
571.56982421875,
0.8778568506240845
],
[
905.7545166015625,
597.0140991210938,
0.9572181701660156
]
]
}
],
"count": 1
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 858 KiB

View File

@@ -0,0 +1,158 @@
{
"filename": "image.jpg",
"timestamp": "20251212_184922_481791",
"detections": [
{
"bbox": [
726.7632446289062,
329.3017578125,
1039.0159912109375,
644.193115234375
],
"confidence": 0.9996580481529236,
"keypoints": [
[
724.5214233398438,
491.360107421875,
0.9068583250045776
],
[
773.7232055664062,
571.31298828125,
0.8334410786628723
],
[
912.1032104492188,
623.58984375,
1.0417006015777588
],
[
988.98095703125,
552.8623046875,
0.8980095386505127
],
[
1007.431640625,
463.6841125488281,
0.9310619831085205
],
[
746.0472412109375,
380.6560974121094,
0.9479750394821167
],
[
795.2489624023438,
352.9801025390625,
0.9780125617980957
],
[
850.6010131835938,
346.82989501953125,
0.9504765272140503
],
[
949.0045166015625,
343.7547912597656,
0.9409129023551941
],
[
979.755615234375,
346.82989501953125,
0.9877245426177979
],
[
1004.3565063476562,
352.9801025390625,
0.8175486922264099
],
[
761.4227905273438,
469.8343200683594,
0.8901976346969604
],
[
798.3240966796875,
439.0832214355469,
0.898412823677063
],
[
847.52587890625,
442.1583251953125,
0.9480761289596558
],
[
786.023681640625,
503.6605529785156,
0.800086498260498
],
[
816.7747802734375,
503.6605529785156,
0.9084622859954834
],
[
841.3756713867188,
485.2098693847656,
0.8428341746330261
],
[
939.7791748046875,
442.1583251953125,
0.9022107124328613
],
[
976.6805419921875,
423.7076721191406,
0.9188122749328613
],
[
998.206298828125,
448.3085632324219,
0.8803592920303345
],
[
942.8543090820312,
485.2098693847656,
0.9008185267448425
],
[
961.3049926757812,
488.2850036621094,
0.9842251539230347
],
[
979.755615234375,
485.2098693847656,
0.8688068389892578
],
[
918.25341796875,
497.51031494140625,
0.9747406840324402
],
[
865.9765625,
540.5618896484375,
0.9243482947349548
],
[
902.8778686523438,
528.2614135742188,
0.9051891565322876
],
[
933.6289672851562,
537.4867553710938,
0.8917962908744812
],
[
899.802734375,
589.763671875,
0.9897644519805908
]
]
}
],
"count": 1
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

View File

@@ -0,0 +1,158 @@
{
"filename": "image.jpg",
"timestamp": "20251212_185051_284641",
"detections": [
{
"bbox": [
464.01947021484375,
298.8453674316406,
694.5145874023438,
535.1456909179688
],
"confidence": 0.9993460774421692,
"keypoints": [
[
462.7322082519531,
420.45697021484375,
0.9005646705627441
],
[
488.11602783203125,
464.3017578125,
0.8725886940956116
],
[
596.5741577148438,
515.0693969726562,
0.8660060167312622
],
[
654.2647094726562,
452.763671875,
0.6613621711730957
],
[
679.6484985351562,
381.2274169921875,
0.6446322202682495
],
[
469.6550598144531,
376.6121826171875,
0.8074662685394287
],
[
513.4998779296875,
351.2283630371094,
0.9991122484207153
],
[
561.9598999023438,
341.9978942871094,
0.9606946706771851
],
[
635.8037109375,
335.07501220703125,
0.9511255025863647
],
[
658.8799438476562,
330.45977783203125,
0.9962062239646912
],
[
681.9561157226562,
332.76739501953125,
0.9747639894485474
],
[
499.65411376953125,
411.22650146484375,
0.9199956655502319
],
[
527.3455810546875,
383.5350646972656,
0.9078559875488281
],
[
561.9598999023438,
383.5350646972656,
0.9202607870101929
],
[
527.3455810546875,
441.2255554199219,
0.8042559623718262
],
[
548.1141357421875,
441.2255554199219,
0.9188339114189148
],
[
564.2675170898438,
429.6874694824219,
0.8672323226928711
],
[
633.49609375,
381.2274169921875,
0.9129951000213623
],
[
656.5723266601562,
362.7664794921875,
0.9563388824462891
],
[
670.4180297851562,
371.9969482421875,
0.7818325757980347
],
[
638.111328125,
422.76458740234375,
0.8392997980117798
],
[
647.341796875,
425.07220458984375,
0.7628639936447144
],
[
656.5723266601562,
413.53411865234375,
0.661534309387207
],
[
628.880859375,
438.9179382324219,
0.8268178701400757
],
[
610.419921875,
464.3017578125,
0.5365467667579651
],
[
612.7275390625,
464.3017578125,
0.5780096650123596
],
[
617.3427734375,
461.994140625,
0.7304803133010864
],
[
612.7275390625,
466.609375,
0.5040683746337891
]
]
}
],
"count": 1
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 KiB

View File

@@ -0,0 +1,309 @@
{
"filename": "image.jpg",
"timestamp": "20251212_191027_072297",
"detections": [
{
"bbox": [
512.831298828125,
222.49111938476562,
712.5111083984375,
411.5509948730469
],
"confidence": 0.9998140335083008,
"keypoints": [
[
516.1463012695312,
288.74609375,
0.7828178405761719
],
[
527.8463134765625,
341.3960266113281,
0.5173957943916321
],
[
594.146240234375,
397.94598388671875,
0.8529050350189209
],
[
672.1461181640625,
366.7460021972656,
0.7297168970108032
],
[
703.3461303710938,
294.5960693359375,
0.7670934200286865
],
[
539.5462646484375,
261.44610595703125,
0.7913055419921875
],
[
553.1962890625,
269.24609375,
0.8353862762451172
],
[
574.646240234375,
278.99609375,
0.4457876682281494
],
[
660.4461669921875,
234.14613342285156,
0.10699062049388885
],
[
664.3461303710938,
238.04612731933594,
0.14179950952529907
],
[
666.296142578125,
230.2461395263672,
0.12028367072343826
],
[
529.7962646484375,
288.74609375,
0.7327077388763428
],
[
551.2462768554688,
280.94610595703125,
0.9288605451583862
],
[
578.5462646484375,
294.5960693359375,
0.8427419662475586
],
[
535.6463012695312,
316.0460510253906,
0.8363535404205322
],
[
551.2462768554688,
319.946044921875,
0.8699395656585693
],
[
568.7962646484375,
321.89605712890625,
0.9123891592025757
],
[
635.09619140625,
294.5960693359375,
0.8234646916389465
],
[
660.4461669921875,
280.94610595703125,
0.8122385740280151
],
[
691.6461181640625,
292.6460876464844,
0.7891280651092529
],
[
646.796142578125,
321.89605712890625,
0.9696841239929199
],
[
662.3961791992188,
321.89605712890625,
0.9332332015037537
],
[
677.9961547851562,
317.9960632324219,
0.8933278918266296
],
[
605.84619140625,
339.446044921875,
1.0230207443237305
],
[
592.1962280273438,
370.64599609375,
0.8191301822662354
],
[
603.896240234375,
358.9460144042969,
0.7493577003479004
],
[
623.3961791992188,
366.7460021972656,
0.7101249694824219
],
[
601.9462280273438,
382.34600830078125,
0.5985337495803833
]
]
},
{
"bbox": [
421.40216064453125,
1508.900146484375,
667.2318725585938,
1703.595947265625
],
"confidence": 0.8141310811042786,
"keypoints": [
[
663.1506958007812,
1626.65380859375,
0.8262687921524048
],
[
617.5377807617188,
1552.2327880859375,
0.6535483598709106
],
[
509.50714111328125,
1518.6231689453125,
0.602016806602478
],
[
449.4901123046875,
1573.8388671875,
0.4771423935890198
],
[
420.68194580078125,
1655.4620361328125,
0.7748799324035645
],
[
634.342529296875,
1684.2701416015625,
0.8334325551986694
],
[
610.3357543945312,
1669.8660888671875,
0.7198474407196045
],
[
576.7261962890625,
1665.064697265625,
0.4280695915222168
],
[
519.10986328125,
1669.8660888671875,
0.502719521522522
],
[
487.9010314941406,
1686.6708984375,
0.8003339767456055
],
[
466.2948913574219,
1696.2735595703125,
0.6699382662773132
],
[
646.345947265625,
1638.6572265625,
0.8834235668182373
],
[
615.1370849609375,
1655.4620361328125,
0.8206165432929993
],
[
576.7261962890625,
1641.057861328125,
0.8421959280967712
],
[
624.7398071289062,
1609.84912109375,
0.7180304527282715
],
[
605.5343627929688,
1605.0477294921875,
0.7486437559127808
],
[
581.527587890625,
1612.249755859375,
0.8593735694885254
],
[
507.1064758300781,
1648.260009765625,
0.8547894954681396
],
[
473.4969482421875,
1667.4654541015625,
0.7392223477363586
],
[
432.68536376953125,
1660.2633056640625,
0.834228515625
],
[
490.30169677734375,
1624.253173828125,
0.9149014353752136
],
[
468.6955871582031,
1621.8524169921875,
0.8226698637008667
],
[
447.0894470214844,
1626.65380859375,
0.7505560517311096
],
[
540.7160034179688,
1593.0443115234375,
0.8701224327087402
],
[
547.9180297851562,
1549.83203125,
0.752951443195343
],
[
533.5139770507812,
1559.434814453125,
0.9301882386207581
],
[
511.9078369140625,
1545.0306396484375,
0.7194414138793945
],
[
531.11328125,
1535.427978515625,
1.0092731714248657
]
]
}
],
"count": 2
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 KiB

View File

@@ -0,0 +1,309 @@
{
"filename": "image.jpg",
"timestamp": "20251212_191444_937803",
"detections": [
{
"bbox": [
512.831298828125,
222.49111938476562,
712.5111083984375,
411.5509948730469
],
"confidence": 0.9998140335083008,
"keypoints": [
[
516.1463012695312,
288.74609375,
0.7828178405761719
],
[
527.8463134765625,
341.3960266113281,
0.5173957943916321
],
[
594.146240234375,
397.94598388671875,
0.8529050350189209
],
[
672.1461181640625,
366.7460021972656,
0.7297168970108032
],
[
703.3461303710938,
294.5960693359375,
0.7670934200286865
],
[
539.5462646484375,
261.44610595703125,
0.7913055419921875
],
[
553.1962890625,
269.24609375,
0.8353862762451172
],
[
574.646240234375,
278.99609375,
0.4457876682281494
],
[
660.4461669921875,
234.14613342285156,
0.10699062049388885
],
[
664.3461303710938,
238.04612731933594,
0.14179950952529907
],
[
666.296142578125,
230.2461395263672,
0.12028367072343826
],
[
529.7962646484375,
288.74609375,
0.7327077388763428
],
[
551.2462768554688,
280.94610595703125,
0.9288605451583862
],
[
578.5462646484375,
294.5960693359375,
0.8427419662475586
],
[
535.6463012695312,
316.0460510253906,
0.8363535404205322
],
[
551.2462768554688,
319.946044921875,
0.8699395656585693
],
[
568.7962646484375,
321.89605712890625,
0.9123891592025757
],
[
635.09619140625,
294.5960693359375,
0.8234646916389465
],
[
660.4461669921875,
280.94610595703125,
0.8122385740280151
],
[
691.6461181640625,
292.6460876464844,
0.7891280651092529
],
[
646.796142578125,
321.89605712890625,
0.9696841239929199
],
[
662.3961791992188,
321.89605712890625,
0.9332332015037537
],
[
677.9961547851562,
317.9960632324219,
0.8933278918266296
],
[
605.84619140625,
339.446044921875,
1.0230207443237305
],
[
592.1962280273438,
370.64599609375,
0.8191301822662354
],
[
603.896240234375,
358.9460144042969,
0.7493577003479004
],
[
623.3961791992188,
366.7460021972656,
0.7101249694824219
],
[
601.9462280273438,
382.34600830078125,
0.5985337495803833
]
]
},
{
"bbox": [
421.40216064453125,
1508.900146484375,
667.2318725585938,
1703.595947265625
],
"confidence": 0.8141310811042786,
"keypoints": [
[
663.1506958007812,
1626.65380859375,
0.8262687921524048
],
[
617.5377807617188,
1552.2327880859375,
0.6535483598709106
],
[
509.50714111328125,
1518.6231689453125,
0.602016806602478
],
[
449.4901123046875,
1573.8388671875,
0.4771423935890198
],
[
420.68194580078125,
1655.4620361328125,
0.7748799324035645
],
[
634.342529296875,
1684.2701416015625,
0.8334325551986694
],
[
610.3357543945312,
1669.8660888671875,
0.7198474407196045
],
[
576.7261962890625,
1665.064697265625,
0.4280695915222168
],
[
519.10986328125,
1669.8660888671875,
0.502719521522522
],
[
487.9010314941406,
1686.6708984375,
0.8003339767456055
],
[
466.2948913574219,
1696.2735595703125,
0.6699382662773132
],
[
646.345947265625,
1638.6572265625,
0.8834235668182373
],
[
615.1370849609375,
1655.4620361328125,
0.8206165432929993
],
[
576.7261962890625,
1641.057861328125,
0.8421959280967712
],
[
624.7398071289062,
1609.84912109375,
0.7180304527282715
],
[
605.5343627929688,
1605.0477294921875,
0.7486437559127808
],
[
581.527587890625,
1612.249755859375,
0.8593735694885254
],
[
507.1064758300781,
1648.260009765625,
0.8547894954681396
],
[
473.4969482421875,
1667.4654541015625,
0.7392223477363586
],
[
432.68536376953125,
1660.2633056640625,
0.834228515625
],
[
490.30169677734375,
1624.253173828125,
0.9149014353752136
],
[
468.6955871582031,
1621.8524169921875,
0.8226698637008667
],
[
447.0894470214844,
1626.65380859375,
0.7505560517311096
],
[
540.7160034179688,
1593.0443115234375,
0.8701224327087402
],
[
547.9180297851562,
1549.83203125,
0.752951443195343
],
[
533.5139770507812,
1559.434814453125,
0.9301882386207581
],
[
511.9078369140625,
1545.0306396484375,
0.7194414138793945
],
[
531.11328125,
1535.427978515625,
1.0092731714248657
]
]
}
],
"count": 2
}