Compare commits

..

351 Commits

Author SHA1 Message Date
root 78cd7bbddf Added ctrl+w shortcut to delete current chat. 2024-10-16 20:25:11 -03:00
jeffser 218c10f4ad Rewrote system for getting youtube transcripts 2024-10-16 14:47:56 -06:00
Simon 134a907eff Update uk.po (#352) 2024-10-16 10:01:23 -06:00
aritra saha 97ee2e7a24 update hipo bnpo (#351)
* Update bn.po

* Update hi.po
2024-10-16 10:01:02 -06:00
jeffser ed62aed6a4 Updated spanish 2024-10-15 21:48:17 -06:00
jeffser b6ab989ac8 Updated translations 2024-10-15 21:46:53 -06:00
jeffser cefd758846 Preparing for 2.7.0 2024-10-15 21:46:27 -06:00
jeffser c114ae67ba Made messages more compact 2024-10-15 20:06:05 -06:00
jeffser 0a7f7e5ac2 User messages are now smaller 2024-10-15 11:24:44 -06:00
jeffser 22db4a43d9 Made messages more compact 2024-10-15 10:57:49 -06:00
jeffser 70e4d8f407 Fixed 'window size not adapting to large text' 2024-10-15 10:31:00 -06:00
jeffser 3da5207f53 Finally finished label 2024-10-14 16:43:46 -06:00
jeffser f00122d789 Label thingy 2024-10-14 16:41:04 -06:00
jeffser 6a19ca266e Added dots 2024-10-14 16:38:31 -06:00
jeffser 4f9aebf7a3 Updated label 2024-10-14 16:36:07 -06:00
jeffser 61f9e187bd Added link to AMD Support label 2024-10-14 16:28:13 -06:00
jeffser 27126736a4 Fixed reconnection dialog not selecting 'use local instance' 2024-10-14 15:59:15 -06:00
aritra saha c9cf2bfefc update hipo and small bn.po (#348)
* Update bn.po

* Update bn.po

* Update hi.po
2024-10-14 15:46:41 -06:00
aritra saha e03ea42be3 Update bn.po (#347) 2024-10-13 17:26:40 -06:00
jeffser 3253e67680 Update to snap 2024-10-13 17:08:42 -06:00
jeffser e189769f3f Updated spanish 2024-10-13 17:07:33 -06:00
jeffser f6637493db Update languages 2024-10-13 17:03:00 -06:00
jeffser 063da38597 Preparing for 2.6.5 2024-10-13 16:24:20 -06:00
jeffser 7587b03828 Added Exception as e so it can catch everything 2024-10-13 15:21:39 -06:00
jeffser 8fffb64f79 the 2024-10-13 15:07:20 -06:00
aritra saha 735eae0d0e Update bn.po (#346)
* Update bn.po

* Update bn.po
2024-10-13 14:39:45 -06:00
jeffser 8c98be6ef6 Integrated instance indicator on preferences 2024-10-13 10:27:18 -06:00
jeffser 115e22e52c Added warning if model is too large for system 2024-10-13 10:00:43 -06:00
jeffser 792a81ad03 Restore Ollama logging 2024-10-13 09:57:52 -06:00
jeffser 2ea0ff6870 Removed webiste button in creation page 2024-10-12 18:47:20 -06:00
jeffser 6242087152 Replace model selector with button if there aren't any models download 2024-10-12 17:25:34 -06:00
aritra saha 1da6e31de1 Update hi.po (#345) 2024-10-12 17:07:09 -06:00
aritra saha cb4979ab7c Update bn.po (#344)
* Update bn.po

* Update bn.po
2024-10-12 17:06:55 -06:00
jeffser da653c754d Added create button to details and fixed some css 2024-10-12 17:01:54 -06:00
jeffser c4907b81fd Fixed datetime bug 2024-10-12 13:29:54 -06:00
jeffser 4c104560d5 Chaged styling 2024-10-11 22:51:51 -06:00
jeffser 2253e378ac Updated spanish 2024-10-11 22:45:20 -06:00
jeffser ba66ac40a3 Updated translations 2024-10-11 22:44:53 -06:00
jeffser 40d0d92498 Forgot one translation 2024-10-11 22:44:22 -06:00
jeffser 4ed6cf8e18 Updated spanish 2024-10-11 22:42:49 -06:00
jeffser 3fc1c74f51 Updated translations 2024-10-11 22:41:17 -06:00
jeffser 150e8779c7 New 'model details' page 2024-10-11 22:40:31 -06:00
Jeffry Samuel 5462248565 Update README.md 2024-10-11 19:08:35 -06:00
jeffser 0bc9f79f99 Added rounded corners on images 2024-10-11 16:40:23 -06:00
jeffser 8bfa0830c1 Updated spanish 2024-10-11 16:32:43 -06:00
jeffser ffefe2b141 Updated languages with new files 2024-10-11 16:30:00 -06:00
jeffser c8679d6fa5 New screenie 2024-10-11 16:25:58 -06:00
jeffser 8fd8d920e6 Fixed error: text following another block doesn't render 2024-10-11 16:13:13 -06:00
jeffser 202da99fa7 Preparing for 2.6.0 2024-10-11 16:06:24 -06:00
jeffser f084d6e447 That was a bad idea anyways 2024-10-11 15:59:03 -06:00
jeffser 9ab0084e18 oops 2024-10-11 15:54:19 -06:00
jeffser e42eec3e31 Switched back to using main thread for switcher 2024-10-11 15:53:51 -06:00
jeffser e553215bf1 This one should still be part of the other thread 2024-10-11 15:47:46 -06:00
jeffser 50eedc5326 Made launch and instance switcher thread safe 2024-10-11 15:41:17 -06:00
jeffser f6975f1b6d Forgot to import a library 2024-10-11 15:29:38 -06:00
Jeffry Samuel 35dac564b0 Update README.md 2024-10-11 15:24:09 -06:00
jeffser 7e1a3713b5 Fixed: Create model from existing 2024-10-11 15:11:09 -06:00
jeffser a99d1f11c2 Better handling of switching instances 2024-10-11 15:01:13 -06:00
jeffser 19523ba37a Fixed bug of model duplication when switching instances 2024-10-11 14:50:22 -06:00
jeffser 9bec816965 Added spam prevention 2024-10-11 14:46:05 -06:00
jeffser cbb7605851 Rewrote remote / local instance switcher and stuff 2024-10-11 14:40:49 -06:00
jeffser c856b49268 Removed reference to instance manager 2024-10-11 13:45:19 -06:00
jeffser fb04e4cb4f Restarting rewrite of instance manager 2024-10-11 13:44:36 -06:00
jeffser 00527a6271 Not going to use that library because of bearer tokens 2024-10-11 13:39:20 -06:00
jeffser 462657b7bb Started instance manager 2024-10-11 13:28:39 -06:00
jeffser 12fb88f3fd Removed references to old dialog system 2024-10-11 13:28:02 -06:00
jeffser 22af279548 Added Ollama-python dependency (I'll integrate it tomorrow) 2024-10-10 22:45:38 -06:00
jeffser 00fc442348 Cuted some lines down 2024-10-10 22:34:14 -06:00
jeffser 32df119c60 Reconnect dialog added 2024-10-10 22:30:52 -06:00
jeffser ef8ec59977 Made functions more readeable 2024-10-10 22:23:53 -06:00
jeffser 3156c70260 Rewrote a whole new dialog system cause I was bored 2024-10-10 22:14:08 -06:00
jeffser 7f042a906d Much better markup rendering 2024-10-09 21:31:08 -06:00
jeffser ff5e663185 Update spanish 2024-10-09 21:07:20 -06:00
jeffser 9d0daea052 Languages updated 2024-10-09 21:05:44 -06:00
jeffser 31a10ee7d6 Added note 2024-10-09 21:05:23 -06:00
jeffser 38abd208ff Much better message block rendering 2024-10-09 20:48:04 -06:00
jeffser c34713eff5 Preparing for 2.5.1 2024-10-09 20:02:18 -06:00
jeffser d55aaf19a2 Nah, I'll leave then sudo thing 2024-10-09 12:51:02 -06:00
jeffser 9f4b6faf28 Remove sudo 2024-10-09 12:49:02 -06:00
jeffser 57184f0a5c Remove digests when canceling the download of a model 2024-10-09 10:46:16 -06:00
jeffser df568c7217 Verify image recognition only at launch 2024-10-09 10:13:00 -06:00
jeffser ed440d8935 New icon 2024-10-08 19:27:01 -06:00
jeffser 70c183c71d Rewritten edit system (cancel and save buttons) 2024-10-08 19:26:51 -06:00
jeffser b44d457bc5 Removed unused variable 2024-10-08 19:01:38 -06:00
aritra saha 15e4bbb62f Update hi.po (#342) 2024-10-08 15:46:45 -06:00
aritra saha 5d95ba1c15 Update bn.po (#341) 2024-10-08 15:46:29 -06:00
jeffser 7e81200f80 Forgot to remove this permission 2024-10-07 13:04:45 -06:00
jeffser b952fa07b5 Replaced sudo with pkexec in custom scripts 2024-10-07 13:01:12 -06:00
jeffser 15bd4335e8 Use system for terminal if it is allowed to 2024-10-07 12:33:35 -06:00
jeffser d79a1236a0 Updated spanish 2024-10-07 10:40:02 -06:00
jeffser ce11a308bf Update languages 2024-10-07 10:38:39 -06:00
jeffser aa1fbcebe7 Copy shortcut 2024-10-07 10:37:14 -06:00
jeffser efbfb1e82a Change warning so that it only appears with bash scripts 2024-10-07 10:16:31 -06:00
jeffser f497f1c5dc Styling 2024-10-07 10:10:20 -06:00
jeffser 9ecf231307 Use venv for running python scripts 2024-10-07 10:02:39 -06:00
jeffser 66a9627b29 Better styling for terminal 2024-10-07 02:17:34 -06:00
jeffser f03c01b6a6 Better dimensions for terminal 2024-10-07 02:07:17 -06:00
jeffser 29a5251d63 Virtual terminal! 2024-10-07 02:02:27 -06:00
jeffser fcb956ff23 Removed flatpak permission 2024-10-07 01:11:08 -06:00
jeffser 363fb882f3 Updated Spanish 2024-10-06 23:37:48 -06:00
jeffser e24cbb65b1 Updated languages 2024-10-06 23:26:47 -06:00
jeffser cf4d37a1c0 Preparing for 2.5.0 2024-10-06 23:26:22 -06:00
jeffser 6394569b3b New models! 2024-10-06 23:26:08 -06:00
jeffser e6c855fcf9 Updated Ollama to 0.3.12 2024-10-06 23:04:43 -06:00
jeffser c00061f46b Proper python support 2024-10-06 22:41:05 -06:00
jeffser 67d572bd64 Even better code block detection 2024-10-06 22:23:37 -06:00
jeffser 06769aba90 Fixed codeblock detection when it doesn't have a language 2024-10-06 22:21:42 -06:00
jeffser f5845e95e6 Added compatibility with python scripts 2024-10-06 22:16:06 -06:00
jeffser 4d529619d6 Better recognition for code blocks 2024-10-06 22:03:33 -06:00
jeffser 95561f205c Faster and well organized launch 2024-10-06 21:42:08 -06:00
jeffser e855466280 Modified script running 2024-10-06 21:16:32 -06:00
jeffser c1c30c993c Run Bash scripts on a terminal straight from chat :D 2024-10-06 21:13:00 -06:00
jeffser 7da70097f2 Fixed bug with text messages being loaded at launch 2024-10-06 19:24:32 -06:00
jeffser 01b6ae6bee added italian template 2024-10-06 16:07:07 -06:00
jeffser 9c1e0ea263 Added GSK_RENDERER=ngl 2024-10-03 15:53:19 -06:00
jeffser 22116b0d1e Preparing for 2.0.6 2024-09-29 16:10:36 -06:00
jeffser 03d92de88b Merge branch 'main' of github.com-jeffser:Jeffser/Alpaca 2024-09-29 16:07:19 -06:00
jeffser 0be0942da3 Fix: Text rendering causing crash because of notification being in a different thread 2024-09-29 16:07:12 -06:00
Jeffry Samuel b488b64473 Added instructions for Snap 2024-09-25 14:20:57 -06:00
jeffser 56eac5ccd6 Removed unnecesary line from release notes 2024-09-25 13:50:54 -06:00
jeffser ad5d6dfa41 Preparing for 2.0.5 2024-09-25 13:50:32 -06:00
Jeffry Samuel c4fb424514 Removed tag from Snap 2024-09-25 13:23:40 -06:00
সৌম্যদীপ ঘোষ 28e09d5c2e snap: improve the snap (#318)
1. cleaned up the manifest
2. added arm64 support
2024-09-25 12:21:01 -06:00
jeffser 633507fecd Quick fix to message generation 2024-09-25 09:34:12 -06:00
jeffser 5f3c01d231 Preparing for 2.0.4 2024-09-22 15:08:40 -06:00
jeffser 4851b7858b Merge branch 'main' of github.com-jeffser:Jeffser/Alpaca 2024-09-22 15:03:30 -06:00
jeffser d4f359bba7 Update Ollama to v0.3.11 2024-09-22 15:02:47 -06:00
jeffser 40afce9fb0 New models added to list 2024-09-22 14:55:38 -06:00
ProjectMoon 61d2e7c7a0 Use show API to detect vision. (#316)
* Use show API to detect vision.

* Update so it actually works.

* Removed Cache

---------

Co-authored-by: Jeffry Samuel <jeffrysamuer@gmail.com>
2024-09-21 16:39:22 -06:00
jeffser 0cb1891d9e Added Telugu officialy 2024-09-21 16:29:38 -06:00
jeffser 5bd55843db Merge branch 'main' of github.com-jeffser:Jeffser/Alpaca 2024-09-21 15:50:44 -06:00
jeffser 5150fd769a Message search (yeah finally) 2024-09-21 15:50:38 -06:00
Aryan Karamtoth d5eea3397c Added te.po - Telugu Translation (#320)
* Added te.po - Telugu Translation

* Update te.po
2024-09-21 15:01:23 -06:00
Louis Chauvet-Villaret 11b0b6a8d7 hop, fr updated (#319) 2024-09-21 15:00:53 -06:00
aritra saha ecc93cda78 Update bn.po hi.po (#309)
* Update bn.po

* Update hi.po
2024-09-19 20:00:08 -06:00
jeffser 3653af7b81 Fixed model manager with accessibility large text on (wip) 2024-09-18 18:10:47 -06:00
jeffser bed097c760 Merge branch 'main' of github.com-jeffser:Jeffser/Alpaca 2024-09-18 17:47:13 -06:00
jeffser f8d18afd13 Fixed right click on messages sometimes crashes app 2024-09-18 17:45:21 -06:00
jeffser 991c01cba0 Update release notes 2024-09-18 10:42:55 -06:00
jeffser 3e6a2b040f Update spanish 2024-09-18 10:39:35 -06:00
jeffser 22138933f7 Updated languages 2024-09-18 10:32:26 -06:00
jeffser 3d1a3a9ece New release notes 2024-09-18 10:31:43 -06:00
jeffser 0d5350b24d Updated runtime to Gnome.Platform 47 2024-09-18 10:28:22 -06:00
jeffser 4fb83ed441 Made sidebar resize a little 2024-09-17 22:36:51 -06:00
jeffser e8cfc9a9ee Update welcome dialog 2024-09-17 21:27:19 -06:00
jeffser 13a076bd9f Instant launch 2024-09-17 21:14:58 -06:00
jeffser 63296219cf Merge branch 'main' of github.com-jeffser:Jeffser/Alpaca 2024-09-17 19:46:34 -06:00
jeffser 1ee36b113a Fixed stop button 2024-09-17 19:46:28 -06:00
Jeffry Samuel dce91739e7 Update com.jeffser.Alpaca.metainfo.xml.in 2024-09-17 19:04:55 -06:00
jeffser dd29077499 Preparing for 2.0.3 2024-09-17 19:03:48 -06:00
jeffser e398d55211 Merge branch 'main' of github.com-jeffser:Jeffser/Alpaca 2024-09-17 18:59:31 -06:00
jeffser cbdfe43896 Fixed image verifier 2024-09-17 18:59:21 -06:00
Jeffry Samuel 25eb1526d3 Update README.md 2024-09-16 22:10:28 -06:00
jeffser 318f15925f Fixed spinner 2024-09-16 18:30:48 -06:00
jeffser 95912e0211 Merge branch 'main' of github.com-jeffser:Jeffser/Alpaca 2024-09-16 10:38:04 -06:00
jeffser f96b652605 Changed appearance of delete / stop buttons 2024-09-16 10:37:58 -06:00
Jeffry Samuel 24b1ff2e1b Update README.md 2024-09-16 10:34:52 -06:00
jeffser 7e79f715b1 Added hebrew to updater 2024-09-16 10:34:26 -06:00
jeffser a061feeb71 Changed order 2024-09-16 10:33:39 -06:00
jeffser 12790b5ae1 Stop existing instance before starting new one fallback 2024-09-16 10:31:28 -06:00
Yosef Or Boczko 2e2626fa99 Added Hebrew Translation (#307) 2024-09-16 10:24:00 -06:00
hideo aoyama 3962315a6e first working version (#305) 2024-09-16 10:20:50 -06:00
jeffser 08c0074ae5 Experimental Snap package 2024-09-12 11:40:23 -06:00
jeffser 295429acdf Changed version 2024-09-11 23:46:59 -06:00
jeffser a842258e9e Preparing for 2.0.2 2024-09-11 23:28:08 -06:00
jeffser 053efabfc8 Removed pkgbuild 2024-09-11 23:16:28 -06:00
Jeffry Samuel a12083bfe9 Update README.md 2024-09-11 23:16:00 -06:00
jeffser 672b8098bd package name should be lowercase 2024-09-11 23:11:39 -06:00
jeffser db03cce49f Made it use the stable version instead of git 2024-09-11 22:56:02 -06:00
jeffser e8b0733c32 Changed package name to com.jeffser.Alpaca 2024-09-11 22:49:25 -06:00
jeffser 68d970716f Fixes for system installation 2024-09-11 22:44:07 -06:00
jeffser a0338bcccb Fixed launch error when displaying welcome dialog 2024-09-11 22:33:11 -06:00
jeffser eb92126e4b Merge branch 'main' of github.com-jeffser:Jeffser/Alpaca 2024-09-11 22:31:25 -06:00
jeffser d26caea5f0 Changed behavior of Welcome dialog (again yeah) 2024-09-11 22:31:18 -06:00
Jeffry Samuel 6d339aad5e Added system installation instructions 2024-09-11 22:09:56 -06:00
jeffser e7b6da4f62 Merge branch 'main' of github.com-jeffser:Jeffser/Alpaca 2024-09-11 22:04:39 -06:00
jeffser 37e36add45 Added makepkg 2024-09-11 22:04:30 -06:00
Jeffry Samuel ed2501adf4 Update README.md 2024-09-11 17:36:20 -06:00
jeffser 83db9fd9d4 Preparing version 2.0.1 2024-09-11 16:34:07 -06:00
jeffser 6cb49cfc98 Removed version from extensions 2024-09-11 15:35:18 -06:00
jeffser a928d2c074 Added device=all because of AMD GPUs 2024-09-11 15:10:01 -06:00
jeffser 4d35cea229 Added libnuma to dependencies 2024-09-11 13:06:30 -06:00
jeffser 51d2326dee Fixed clear chat 2024-09-11 10:51:04 -06:00
jeffser 80dcae194b Fixed Ollama instance sometimes failing to give version 2024-09-11 10:36:07 -06:00
jeffser 50759adb8e Merge branch 'main' of github.com-jeffser:Jeffser/Alpaca 2024-09-11 10:24:22 -06:00
jeffser f46d16d257 Changed launch / welcome dialog behavior 2024-09-11 10:24:12 -06:00
Jeffry Samuel 5a9eeefaa7 Update README.md 2024-09-10 20:18:57 -06:00
Jeffry Samuel f4f91d9aa1 Update README.md 2024-09-10 00:12:30 -06:00
YusaBecerikli ad5f73e985 Update tr.po (#290)
* Update tr.po

* Update tr.po

I deleted line 5 and revised line 10.

---------

Co-authored-by: Jeffry Samuel <jeffrysamuer@gmail.com>
2024-09-10 00:10:04 -06:00
aritra saha d06ac2c2eb Update bn.po (#286)
* Update bn.po

* Update bn.po
2024-09-05 15:13:08 -06:00
aritra saha 343411cd8c Update hi.po (#287) 2024-09-05 10:45:23 -06:00
Simon e14750db44 Update uk.po (#288) 2024-09-05 10:44:49 -06:00
Marcel Margenberg 3be3b21f93 Additional German Translation (#285)
* Updated de.po for v2.0.0

Translated for the new update

* Update de.po

Fixed typo

* Update de.po
2024-09-04 19:15:35 -06:00
jeffser 5c28245ff3 Spanish update 2024-09-04 15:45:39 -06:00
jeffser b433091e90 Updated translations 2024-09-04 15:44:29 -06:00
jeffser fe22f34a3d Updated copyright info 2024-09-04 15:32:01 -06:00
jeffser ef395a27a3 Added Polish template 2024-09-04 15:31:45 -06:00
jeffser 362e62ee36 Fixed welcome dialog not baing able to close after initial load 2024-09-04 15:18:37 -06:00
jeffser 80aabcb805 Fixed error on config save 2024-09-04 15:16:46 -06:00
jeffser c283f3f1d2 Fixed translation updater with new Simplified Chinese locale 2024-09-04 15:09:06 -06:00
mags0ft 603fdb8150 Add an option to hide the power save warning at startup (#282)
* add an option to hide the power save warning at startup

* Fixed stuff and made it positive

* Changed description and name of switch

* Fixed tab

* Fixed name of element (my bad)

* Check power saver mode state when switching

* Warning set to true by default

---------

Co-authored-by: Jeffry Samuel <jeffrysamuer@gmail.com>
2024-09-04 15:05:16 -06:00
mags0ft 6e0ae393a4 made font family of code blocks monospace (#284) 2024-09-04 14:23:32 -06:00
Yuehao Sui abbdbf1abe Update Simplified Chinese Translation (#279) 2024-09-04 09:26:20 -06:00
Louis Chauvet-Villaret a68973ece6 French update (#278) 2024-09-04 09:20:54 -06:00
jeffser 50aad8cb6d even better checker 2024-09-03 22:06:23 -06:00
jeffser 79a7840f24 Better checker for Ollama instance missing 2024-09-03 21:56:37 -06:00
jeffser 19a8aade60 Fixed remote connection and added checker for Ollama missing 2024-09-03 21:52:14 -06:00
jeffser a591270d58 Removed prints 2024-09-02 18:40:23 -06:00
jeffser 1087d3e336 Fixed run on background 2024-09-02 18:18:49 -06:00
jeffser fb7393fe5c Fixed crash at close 2024-09-02 17:57:48 -06:00
jeffser d3159ae6ea Fixed regeneration 2024-09-02 17:22:54 -06:00
jeffser c2c047d8b7 Save at send message and fixed copy button on code blocks 2024-09-02 17:00:35 -06:00
jeffser e897d6c931 Removed unnecesary line 2024-09-02 16:33:13 -06:00
jeffser 3ceb25ccc6 Fixed YouTube integration 2024-09-02 16:31:27 -06:00
jeffser 9d740a7db9 Modified logging 2024-09-02 16:18:23 -06:00
jeffser 4e77898487 Fixed export chat 2024-09-02 16:16:27 -06:00
jeffser c913a25679 Fixed app not launching when there are too many messages 2024-09-02 16:12:49 -06:00
jeffser 758e055f1c Added save on rename, duplicate and import of chats 2024-09-02 16:10:53 -06:00
jeffser a08be7351c Fixed model pull by name 2024-09-02 16:04:17 -06:00
jeffser 08c0c54b98 Fixed extension 2024-09-02 14:51:53 -06:00
jeffser 687b99f9ab Update welcome screen when a model is pulled / created / deleted 2024-09-02 13:36:17 -06:00
jeffser 5801d43af9 Fixed delete model 2024-09-02 13:15:44 -06:00
jeffser 5a28a16119 Fixed pull model 2024-09-02 12:52:15 -06:00
jeffser 47e58d2ccd Welcome dialog now waits for the app to be fully loaded 2024-09-02 12:50:19 -06:00
jeffser d33e9c53d8 Removed unnecesary code 2024-09-02 12:43:41 -06:00
aritra saha 8869296aed Update hi.po and bn.po (#274)
* Update hi.po

* Update bn.po

* Update es.po

* Update fr.po

* Update de.po
2024-09-02 12:16:58 -06:00
Marcel Margenberg da4dd3341a Updated de.po for v2.0.0 (#275)
* Updated de.po for v2.0.0

Translated for the new update

* Update de.po

Fixed typo
2024-09-02 12:16:42 -06:00
Simon 15aa7fb844 Updating the Ukrainian translation to the latest version (#276) 2024-09-02 12:16:07 -06:00
Jeffry Samuel d74f535968 Changed extension name 2024-09-02 04:24:00 -06:00
jeffser 521a95fc6b Fixed rare crash at launch 2024-09-02 03:17:23 -06:00
jeffser 9548e2ec40 Updated spanish translation 2024-09-02 03:13:50 -06:00
jeffser f1a3c7136f Updated languages 2024-09-02 03:00:45 -06:00
jeffser 4542f26bb7 Updated release notes 2024-09-02 03:00:06 -06:00
jeffser 4926cb157e Removed unnecesary timer start and added *60 to make it minutes 2024-09-02 02:56:57 -06:00
jeffser 0d3b544a73 Finished timer implementation 2024-09-02 02:55:02 -06:00
jeffser daf56c2de4 Added inactive timer 2024-09-02 02:38:03 -06:00
jeffser 46e3921585 Added version notes (the update is still not ready) 2024-09-02 01:35:52 -06:00
jeffser 707984e20d New model list 2024-09-02 01:08:15 -06:00
jeffser cfb79a70be Moved description extractor to internal tooling 2024-09-02 01:06:44 -06:00
jeffser c32d0acfd4 Added back chat notifications 2024-09-02 00:43:49 -06:00
jeffser 38de4ac18e Fixed extension 2024-09-01 23:36:25 -06:00
jeffser 923c0e52e2 Added AMD extension 2024-09-01 19:10:27 -06:00
jeffser e753591b45 Properly written module 2024-09-01 18:21:24 -06:00
jeffser 12e754e4bc Updated Ollama to v0.3.9 2024-09-01 18:12:01 -06:00
jeffser eb3919ad63 Adding /sys/module/amdgpu to filesystem 2024-09-01 17:46:50 -06:00
jeffser 1b94864422 Added new message indicator 2024-09-01 16:56:18 -06:00
jeffser 51a90e0b79 Merge branch 'main' of github.com-jeffser:Jeffser/Alpaca 2024-09-01 16:56:00 -06:00
jeffser 7264902199 Added Ollama debug 2024-09-01 16:55:53 -06:00
Allie f08b03308e Add keywords to .desktop file (#271)
* add keywords to .desktop file

This allows for easier searching for the app

* Update com.jeffser.Alpaca.desktop.in

---------

Co-authored-by: Jeffry Samuel <jeffrysamuer@gmail.com>
2024-09-01 14:28:20 -06:00
jeffser f831466d87 Better handling of focus with messages 2024-08-31 22:00:57 -06:00
jeffser a54ec6fa9d Added spinner for chats receiving messages 2024-08-31 22:00:42 -06:00
jeffser ed3136cffd Reverting that 2024-08-31 20:42:34 -06:00
jeffser e37c5acbf9 Save selected chat when chat is changed 2024-08-31 20:41:50 -06:00
jeffser 9d2ad2eb3a Scroll to bottom when chat is changed 2024-08-31 20:37:35 -06:00
jeffser d1a0d6375b Fixed reconnect dialog and made it so that the launch dialog doesn't appear with remote connections 2024-08-31 20:03:19 -06:00
jeffser ebf3af38c8 Fixed name 2024-08-31 19:29:08 -06:00
jeffser 80b433e7a4 Code cleaning 2024-08-31 19:23:50 -06:00
jeffser 5da5c2c702 Code cleaning 2024-08-31 19:09:46 -06:00
jeffser fe8626f650 Changed string 2024-08-31 18:26:59 -06:00
jeffser ee998d978f Instant launch! 2024-08-31 18:24:53 -06:00
jeffser cee360d5a2 Better remote instance switcher 2024-08-31 17:35:25 -06:00
jeffser 5098babfd2 Clean code 2024-08-31 17:27:04 -06:00
jeffser 7026655116 New instance manager 'ollama_instance' 2024-08-31 17:14:39 -06:00
jeffser 01ba38a23b Added new files to translation list 2024-08-31 16:51:16 -06:00
jeffser ef2c2650b0 Added drag and drop to text entry 2024-08-30 21:48:50 -06:00
jeffser a7d955a5bf Check for power saver at start 2024-08-30 20:41:29 -06:00
jeffser 129677d27c Warning banner is now hidden by default 2024-08-30 20:40:00 -06:00
jeffser 9ae011a31b fixed tabbing 2024-08-30 20:36:01 -06:00
jeffser abf1253980 Remove unused variables 2024-08-30 20:34:05 -06:00
jeffser e0c7e9c771 Remove unnecesary code 2024-08-30 20:30:37 -06:00
jeffser 6a4c98ef18 Added warning for power saver 2024-08-30 20:29:23 -06:00
jeffser 809e23fb9c Added autoscrolling 2024-08-30 20:10:31 -06:00
jeffser 69eaa56240 Fixed attachments 2024-08-30 14:12:01 -06:00
jeffser df2a9d7b26 Tweaked model selector appearance 2024-08-30 13:42:52 -06:00
jeffser da97a7c6ee Fixed YouTube integration 2024-08-30 13:39:10 -06:00
jeffser bb7a8b659a Removed unnecesary method 2024-08-30 13:38:56 -06:00
jeffser 0999a64356 Restored image recognition 2024-08-30 12:42:48 -06:00
jeffser 4647e1ba47 Merge branch 'main' of github.com-jeffser:Jeffser/Alpaca 2024-08-30 12:42:30 -06:00
jeffser ea0caf03d6 Fixed copy code block button 2024-08-30 12:42:24 -06:00
Marcel Margenberg 1c9ce2a117 Update main.py (#269)
Added Ukrainian & German Contributors
2024-08-28 14:29:35 -06:00
jeffser 01b38fa37a Added back support for creating models 2024-08-28 11:51:12 -06:00
Jeffry Samuel 80d1149932 Update README.md 2024-08-28 10:34:35 -06:00
Marcel Margenberg cc1500f007 Fixed formatting conflicts (#267)
* Update de.po

Fixed string errors

* Update de.po

Fixed all string errors

* Update de.po

fixed
2024-08-28 10:24:17 -06:00
jeffser d0735de129 New model manager (create model doesn't work yet) 2024-08-27 23:25:58 -06:00
jeffser bbf678cb75 Added German to translations update script 2024-08-27 15:10:16 -06:00
jeffser a44a7b5044 Added Ukrainian and German to the list of available languages 2024-08-27 15:09:25 -06:00
Jeffry Samuel 427ecd4499 Update README.md 2024-08-27 15:07:20 -06:00
Marcel Margenberg 0a5bb0b97f Full German Translation (#265) 2024-08-27 15:05:55 -06:00
jeffser 252b76e7eb Merge branch 'main' of github.com-jeffser:Jeffser/Alpaca 2024-08-26 23:16:57 -06:00
jeffser 5cf2be2b7d Actually stop the thread when the message generation stops 2024-08-26 23:16:49 -06:00
aritra saha 7f9a5eb516 Update hi.po (#263) 2024-08-26 17:49:44 -06:00
aritra saha 9ecfbe8c3f Update bn.po (#262) 2024-08-26 17:49:27 -06:00
jeffser 377adc8699 Updated translation files 2024-08-26 15:10:03 -06:00
jeffser 8598f73be7 Changed text and tooltip for button 2024-08-26 14:28:13 -06:00
jeffser 6f9b3b7c02 Changed message footer format 2024-08-26 14:26:13 -06:00
jeffser db198e10c0 Added back regenerate button 2024-08-26 14:05:42 -06:00
jeffser d2271a7ade Changed master to 46 2024-08-26 13:17:54 -06:00
jeffser 8d3d650ecf Merge branch 'main' of github.com-jeffser:Jeffser/Alpaca 2024-08-26 13:17:03 -06:00
jeffser 4545f5a1b2 Rewrite of Chat / Message / Model selector systems 2024-08-26 13:16:55 -06:00
Jeffry Samuel 62c1354f8b Update README.md 2024-08-26 12:54:23 -06:00
Simon 2bd99860f2 Added translation into Ukrainian language. (#256)
* Added Ukrainian translation

* Clearing the translation

* standardisation
2024-08-26 12:52:58 -06:00
jeffser 8026550f7a Added Ukrainian file 2024-08-25 11:57:48 -06:00
jeffser 68c03176d4 Made directory for custom widgets 2024-08-23 13:52:43 -06:00
jeffser ed54b2846a Added exception catch to Ollama's output in case it can't decode message 2024-08-19 23:06:58 -06:00
jeffser ff927d6c77 Merge branch 'main' of github.com-jeffser:Jeffser/Alpaca 2024-08-19 23:01:49 -06:00
jeffser bd006da0c1 Added check for title generation 2024-08-19 23:01:40 -06:00
YusaBecerikli a409800279 Lines 389 and 390 have been changed (#250) 2024-08-15 23:39:05 -06:00
Jeffser 5d89ccc729 Added Turkish credits 2024-08-15 23:38:27 -06:00
Jeffser fef3926ce3 Added Turkish officially 2024-08-15 23:37:02 -06:00
Jeffry Samuel c95be9611d added turkish credits 2024-08-15 23:36:04 -06:00
YusaBecerikli 1c4fc4341e Update tr.po (#249) 2024-08-15 23:29:55 -06:00
Jeffser 3ddc172437 Changed .accent for .suggested-action 2024-08-15 00:19:55 -06:00
Jeffser 0d65cf1cbc Added turkish template 2024-08-15 00:02:35 -06:00
aritra saha cddcf496b2 update (#241)
* Update bn.po

* Update hi.po
2024-08-13 16:22:45 -06:00
Louis Chauvet-Villaret 9333b31444 French update (#244) 2024-08-13 16:22:27 -06:00
Jeffry Samuel cbd3e90073 Update bug_report.md 2024-08-12 23:59:10 -06:00
Jeffry Samuel a7b6e6bbce Update flatpak-builder.yml 2024-08-12 23:15:53 -06:00
aritra saha 801c10fb77 Update hi.po (#240) 2024-08-12 22:58:04 -06:00
aritra saha 50520b8474 Update bn.po (#239) 2024-08-12 22:53:43 -06:00
jeffser b66e2102d3 Spanish update 2024-08-12 22:21:32 -06:00
jeffser 8c0f1fd4d5 Updated languages 2024-08-12 22:17:35 -06:00
jeffser 8b851d1b56 Preparing for 1.1.1 2024-08-12 22:16:47 -06:00
jeffser f36d6e1b29 Removed bugged imported chats 2024-08-12 22:12:09 -06:00
jeffser eecac162ef Update translations 2024-08-12 22:03:47 -06:00
jeffser 82e7a3a9e1 Better caption names on dropdown 2024-08-12 18:57:17 -06:00
jeffser f0505a0242 Only enable youtube caption search when there's more than 10 captions 2024-08-12 18:55:06 -06:00
jeffser 11dd13b430 Added ollama debbugging messages to about dialog 2024-08-11 22:30:56 -06:00
jeffser b8fe222052 Added duplicate chat option 2024-08-11 22:11:17 -06:00
jeffser 47d19a58aa Give message focus when editing it 2024-08-11 21:50:50 -06:00
jeffser fd67afbf33 Fixed message editor 2024-08-11 21:48:31 -06:00
jeffser d06e08a64e Fix message regeneration 2024-08-11 21:36:31 -06:00
jeffser 77b08d9e52 Added loading spinner to regenerating message 2024-08-11 21:15:26 -06:00
jeffser 9451bf88d0 Removed french language set 2024-08-11 16:02:30 -06:00
jeffser 82bb50d663 Merge branch 'main' of github.com-jeffser:Jeffser/Alpaca 2024-08-11 16:01:14 -06:00
jeffser edc3053774 Focus message entry when creating a new chat 2024-08-11 15:59:39 -06:00
Louis Chauvet-Villaret 1320ddb7d4 Hola Jeffry, traduje la aplicacion, buen dia (#236) 2024-08-11 15:37:51 -06:00
jeffser d95f06a230 Make buttons visible when stopping message 2024-08-11 15:08:26 -06:00
jeffser 938ace91c1 Fixed import chat 2024-08-11 14:55:18 -06:00
jeffser 175cfad81c Welcome screen appears when clearing chat 2024-08-11 14:49:12 -06:00
jeffser 2f399dbb64 Removed bold from manage button label 2024-08-11 14:44:19 -06:00
jeffser 27558b85af Added top margin to model selector 2024-08-11 14:23:30 -06:00
jeffser bcc1f3fa65 Changed 'Open Model Manager' to pill button on welcome screen 2024-08-11 14:19:00 -06:00
jeffser fd92a86c5e CTRL+W and CTRL+Q stops local instance before closing the app 2024-08-11 13:23:34 -06:00
jeffser 3b95d369b8 Added Azerbaijani template 2024-08-11 01:45:57 -06:00
Jeffry Samuel a12920d801 Update SECURITY.md 2024-08-11 00:47:58 -06:00
Jeffry Samuel 2dd63df533 Create SECURITY.md 2024-08-11 00:44:49 -06:00
Jeffry Samuel cea1aa5028 Update CODE_OF_CONDUCT.md 2024-08-11 00:40:27 -06:00
Jeffry Samuel 54b96d4e3a Update CODE_OF_CONDUCT.md 2024-08-11 00:40:04 -06:00
Jeffry Samuel a470136476 Create CODE_OF_CONDUCT.md 2024-08-11 00:37:44 -06:00
Jeffry Samuel 7d35cb08dd Create CONTRIBUTING.md 2024-08-11 00:32:55 -06:00
aritra saha 1f03f1032e Update bn.po and hipo (#223)
* Update bn.po

* Update hi.po
2024-08-11 00:14:48 -06:00
54 changed files with 61146 additions and 28747 deletions
+4 -2
View File
@@ -16,5 +16,7 @@ A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Additional context**
Add any other context about the problem here.
**Debugging information**
```
Please paste here the debugging information available at 'About Alpaca' > 'Troubleshooting' > 'Debugging Information'
```
+1 -1
View File
@@ -13,6 +13,6 @@ jobs:
- uses: actions/checkout@v4
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6
with:
bundle: Alpaca.flatpak
bundle: com.jeffser.Alpaca.flatpak
manifest-path: com.jeffser.Alpaca.json
cache-key: flatpak-builder-${{ github.sha }}
+4
View File
@@ -0,0 +1,4 @@
Alpaca follows [GNOME's code of conduct](https://conduct.gnome.org/), please make sure to read it before interacting in any way with this repository.
To report any misconduct please reach out via private message on
- X (formally Twitter): [@jeffrysamuer](https://x.com/jeffrysamuer)
- Mastodon: [@jeffser@floss.social](https://floss.social/@jeffser)
+30
View File
@@ -0,0 +1,30 @@
# Contributing Rules
## Translations
If you want to translate or contribute on existing translations please read [this discussion](https://github.com/Jeffser/Alpaca/discussions/153).
## Code
1) Before contributing code make sure there's an open [issue](https://github.com/Jeffser/Alpaca/issues) for that particular problem or feature.
2) Ask to contribute on the responses to the issue.
3) Wait for [my](https://github.com/Jeffser) approval, I might have already started working on that issue.
4) Test your code before submitting a pull request.
## Q&A
### Do I need to comment my code?
There's no need to add comments if the code is easy to read by itself.
### What if I need help or I don't understand the existing code?
You can reach out on the issue, I'll try to answer as soon as possible.
### What IDE should I use?
I use Gnome Builder but you can use whatever you want.
### Can I be credited?
You might be credited on the GitHub repository in the [thanks](https://github.com/Jeffser/Alpaca/blob/main/README.md#thanks) section of the README.
+47 -1
View File
@@ -33,7 +33,33 @@ Alpaca is an [Ollama](https://github.com/ollama/ollama) client where you can man
Normal conversation | Image recognition | Code highlighting | YouTube transcription | Model management
:------------------:|:-----------------:|:-----------------:|:---------------------:|:----------------:
![screenie1](https://jeffser.com/images/alpaca/screenie1.png) | ![screenie2](https://jeffser.com/images/alpaca/screenie2.png) | ![screenie3](https://jeffser.com/images/alpaca/screenie3.png) | ![screenie4](https://jeffser.com/images/alpaca/screenie4.png) | ![screenie5](https://jeffser.com/images/alpaca/screenie5.png)
![screenie1](https://jeffser.com/images/alpaca/screenie1.png) | ![screenie2](https://jeffser.com/images/alpaca/screenie2.png) | ![screenie3](https://jeffser.com/images/alpaca/screenie3.png) | ![screenie4](https://jeffser.com/images/alpaca/screenie5.png) | ![screenie5](https://jeffser.com/images/alpaca/screenie6.png)
## Installation
### Flathub
You can find the latest stable version of the app on [Flathub](https://flathub.org/apps/com.jeffser.Alpaca)
### Flatpak Package
Everytime a new version is published they become available on the [releases page](https://github.com/Jeffser/Alpaca/releases) of the repository
### Snap Package
You can also find the Snap package on the [releases page](https://github.com/Jeffser/Alpaca/releases), to install it run this command:
```BASH
sudo snap install ./{package name} --dangerous
```
The `--dangerous` comes from the package being installed without any involvement of the SnapStore, I'm working on getting the app there, but for now you can test the app this way.
### Building Git Version
Note: This is not recommended since the prerelease versions of the app often present errors and general instability.
1. Clone the project
2. Open with Gnome Builder
3. Press the run button (or export if you want to build a Flatpak package)
## Translators
@@ -47,6 +73,13 @@ Language | Contributors
🇮🇳 Bengali | [Aritra Saha](https://github.com/olumolu)
🇨🇳 Simplified Chinese | [Yuehao Sui](https://github.com/8ar10der) , [Aleksana](https://github.com/Aleksanaa)
🇮🇳 Hindi | [Aritra Saha](https://github.com/olumolu)
🇹🇷 Turkish | [YusaBecerikli](https://github.com/YusaBecerikli)
🇺🇦 Ukrainian | [Simon](https://github.com/OriginalSimon)
🇩🇪 German | [Marcel Margenberg](https://github.com/MehrzweckMandala)
🇮🇱 Hebrew | [Yosef Or Boczko](https://github.com/yoseforb)
🇮🇳 Telugu | [Aryan Karamtoth](https://github.com/SpaciousCoder78)
Want to add a language? Visit [this discussion](https://github.com/Jeffser/Alpaca/discussions/153) to get started!
---
@@ -58,5 +91,18 @@ Language | Contributors
- [Nokse](https://github.com/Nokse22) for their contributions to the UI and table rendering
- [Louis Chauvet-Villaret](https://github.com/loulou64490) for their suggestions
- [Aleksana](https://github.com/Aleksanaa) for her help with better handling of directories
- [Gnome Builder Team](https://gitlab.gnome.org/GNOME/gnome-builder) for the awesome IDE I use to develop Alpaca
- Sponsors for giving me enough money to be able to take a ride to my campus every time I need to <3
- Everyone that has shared kind words of encouragement!
---
## Dependencies
- [Requests](https://github.com/psf/requests)
- [Pillow](https://github.com/python-pillow/Pillow)
- [Pypdf](https://github.com/py-pdf/pypdf)
- [Pytube](https://github.com/pytube/pytube)
- [Html2Text](https://github.com/aaronsw/html2text)
- [Ollama](https://github.com/ollama/ollama)
- [Numactl](https://github.com/numactl/numactl)
+12
View File
@@ -0,0 +1,12 @@
# Security Policy
## Supported Packaging
Alpaca only supports [Flatpak](https://flatpak.org/) packaging officially, any other packaging methods might not behave as expected.
## Official Versions
The only ways Alpaca is being distributed officially are:
- [Alpaca's GitHub Repository Releases Page](https://github.com/Jeffser/Alpaca/releases)
- [Flathub](https://flathub.org/apps/com.jeffser.Alpaca)
+90 -10
View File
@@ -1,16 +1,28 @@
{
"id" : "com.jeffser.Alpaca",
"runtime" : "org.gnome.Platform",
"runtime-version" : "46",
"runtime-version" : "47",
"sdk" : "org.gnome.Sdk",
"command" : "alpaca",
"finish-args" : [
"--share=network",
"--share=ipc",
"--socket=fallback-x11",
"--device=dri",
"--socket=wayland"
"--device=all",
"--socket=wayland",
"--filesystem=/sys/module/amdgpu:ro",
"--env=LD_LIBRARY_PATH=/app/lib:/usr/lib/x86_64-linux-gnu/GL/default/lib:/usr/lib/x86_64-linux-gnu/openh264/extra:/usr/lib/x86_64-linux-gnu/openh264/extra:/usr/lib/sdk/llvm15/lib:/usr/lib/x86_64-linux-gnu/GL/default/lib:/usr/lib/ollama:/app/plugins/AMD/lib/ollama",
"--env=GSK_RENDERER=ngl"
],
"add-extensions": {
"com.jeffser.Alpaca.Plugins": {
"add-ld-path": "/app/plugins/AMD/lib/ollama",
"directory": "plugins",
"no-autodownload": true,
"autodelete": true,
"subdirectories": true
}
},
"cleanup" : [
"/include",
"/lib/pkgconfig",
@@ -99,6 +111,45 @@
}
]
},
{
"name": "python3-youtube-transcript-api",
"buildsystem": "simple",
"build-commands": [
"pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"youtube-transcript-api\" --no-build-isolation"
],
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/12/90/3c9ff0512038035f59d279fddeb79f5f1eccd8859f06d6163c58798b9487/certifi-2024.8.30-py3-none-any.whl",
"sha256": "922820b53db7a7257ffbda3f597266d435245903d80737e34f8a45ff3e3230d8"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/f2/4f/e1808dc01273379acc506d18f1504eb2d299bd4131743b9fc54d7be4df1e/charset_normalizer-3.4.0.tar.gz",
"sha256": "223217c3d4f82c3ac5e29032b3f1c2eb0fb591b72161f86d93f5719079dae93e"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/76/c6/c88e154df9c4e1a2a66ccf0005a88dfb2650c1dffb6f5ce603dfbd452ce3/idna-3.10-py3-none-any.whl",
"sha256": "946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/f9/9b/335f9764261e915ed497fcdeb11df5dfd6f7bf257d4a6a2a686d80da4d54/requests-2.32.3-py3-none-any.whl",
"sha256": "70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/ce/d9/5f4c13cecde62396b0d3fe530a50ccea91e7dfc1ccf0e09c228841bb5ba8/urllib3-2.2.3-py3-none-any.whl",
"sha256": "ca899ca043dcb1bafa3e262d73aa25c465bfb49e0bd9dd5d59f1d0acba2f8fac"
},
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/52/42/5f57d37d56bdb09722f226ed81cc1bec63942da745aa27266b16b0e16a5d/youtube_transcript_api-0.6.2-py3-none-any.whl",
"sha256": "019dbf265c6a68a0591c513fff25ed5a116ce6525832aefdfb34d4df5567121c"
}
]
},
{
"name": "python3-html2text",
"buildsystem": "simple",
@@ -117,27 +168,56 @@
"name": "ollama",
"buildsystem": "simple",
"build-commands": [
"install -Dm0755 ollama* ${FLATPAK_DEST}/bin/ollama"
"cp -r --remove-destination * ${FLATPAK_DEST}/",
"mkdir ${FLATPAK_DEST}/plugins"
],
"sources": [
{
"type": "file",
"url": "https://github.com/ollama/ollama/releases/download/v0.3.3/ollama-linux-amd64",
"sha256": "2b2a4ee4c86fa5b09503e95616bd1b3ee95238b1b3bf12488b9c27c66b84061a",
"type": "archive",
"url": "https://github.com/ollama/ollama/releases/download/v0.3.12/ollama-linux-amd64.tgz",
"sha256": "f0efa42f7ad77cd156bd48c40cd22109473801e5113173b0ad04f094a4ef522b",
"only-arches": [
"x86_64"
]
},
{
"type": "file",
"url": "https://github.com/ollama/ollama/releases/download/v0.3.3/ollama-linux-arm64",
"sha256": "28fddbea0c161bc539fd08a3dc78d51413cfe8da97386cb39420f4f30667e22c",
"type": "archive",
"url": "https://github.com/ollama/ollama/releases/download/v0.3.12/ollama-linux-arm64.tgz",
"sha256": "da631cbe4dd2c168dae58d6868b1ff60e881e050f2d07578f2f736e689fec04c",
"only-arches": [
"aarch64"
]
}
]
},
{
"name": "libnuma",
"buildsystem": "autotools",
"build-commands": [
"autoreconf -i",
"make",
"make install"
],
"sources": [
{
"type": "archive",
"url": "https://github.com/numactl/numactl/releases/download/v2.0.18/numactl-2.0.18.tar.gz",
"sha256": "b4fc0956317680579992d7815bc43d0538960dc73aa1dd8ca7e3806e30bc1274"
}
]
},
{
"name": "vte",
"buildsystem": "meson",
"config-opts": ["-Dvapi=false"],
"sources": [
{
"type": "archive",
"url": "https://gitlab.gnome.org/GNOME/vte/-/archive/0.78.0/vte-0.78.0.tar.gz",
"sha256": "82e19d11780fed4b66400f000829ce5ca113efbbfb7975815f26ed93e4c05f2d"
}
]
},
{
"name" : "alpaca",
"builddir" : true,
+1
View File
@@ -5,5 +5,6 @@ Icon=com.jeffser.Alpaca
Terminal=false
Type=Application
Categories=Utility;Development;Chat;
Keywords=ai;ollama;llm
StartupNotify=true
X-Purism-FormFactor=Workstation;Mobile;
+201 -1
View File
@@ -63,10 +63,14 @@
</screenshot>
<screenshot>
<image>https://jeffser.com/images/alpaca/screenie4.png</image>
<caption>A conversation involving a YouTube video transcript</caption>
<caption>A Python script running inside integrated terminal</caption>
</screenshot>
<screenshot>
<image>https://jeffser.com/images/alpaca/screenie5.png</image>
<caption>A conversation involving a YouTube video transcript</caption>
</screenshot>
<screenshot>
<image>https://jeffser.com/images/alpaca/screenie6.png</image>
<caption>Multiple models being downloaded</caption>
</screenshot>
</screenshots>
@@ -78,6 +82,202 @@
<url type="contribute">https://github.com/Jeffser/Alpaca/discussions/154</url>
<url type="vcs-browser">https://github.com/Jeffser/Alpaca</url>
<releases>
<release version="2.7.0" date="2024-10-15">
<url type="details">https://github.com/Jeffser/Alpaca/releases/tag/2.7.0</url>
<description>
<p>New</p>
<ul>
<li>User messages are now compacted into bubbles</li>
</ul>
<p>Fixes</p>
<ul>
<li>Fixed re connection dialog not working when 'use local instance' is selected</li>
<li>Fixed model manager not adapting to large system fonts</li>
</ul>
</description>
</release>
<release version="2.6.5" date="2024-10-13">
<url type="details">https://github.com/Jeffser/Alpaca/releases/tag/2.6.5</url>
<description>
<p>New</p>
<ul>
<li>Details page for models</li>
<li>Model selector gets replaced with 'manage models' button when there are no models downloaded</li>
<li>Added warning when model is too big for the device</li>
<li>Added AMD GPU indicator in preferences</li>
</ul>
</description>
</release>
<release version="2.6.0" date="2024-10-11">
<url type="details">https://github.com/Jeffser/Alpaca/releases/tag/2.6.0</url>
<description>
<p>New</p>
<ul>
<li>Better system for handling dialogs</li>
<li>Better system for handling instance switching</li>
<li>Remote connection dialog</li>
</ul>
<p>Fixes</p>
<ul>
<li>Fixed: Models get duplicated when switching remote and local instance</li>
<li>Better internal instance manager</li>
</ul>
</description>
</release>
<release version="2.5.1" date="2024-10-09">
<url type="details">https://github.com/Jeffser/Alpaca/releases/tag/2.5.1</url>
<description>
<p>New</p>
<ul>
<li>Added 'Cancel' and 'Save' buttons when editing a message</li>
</ul>
<p>Fixes</p>
<ul>
<li>Better handling of image recognition</li>
<li>Remove unused files when canceling a model download</li>
<li>Better message blocks rendering</li>
</ul>
</description>
</release>
<release version="2.5.0" date="2024-10-06">
<url type="details">https://github.com/Jeffser/Alpaca/releases/tag/2.5.0</url>
<description>
<p>New</p>
<ul>
<li>Run bash and python scripts straight from chat</li>
<li>Updated Ollama to 0.3.12</li>
<li>New models!</li>
</ul>
<p>Fixes</p>
<ul>
<li>Fixed and made faster the launch sequence</li>
<li>Better detection of code blocks in messages</li>
<li>Fixed app not loading in certain setups with Nvidia GPUs</li>
</ul>
</description>
</release>
<release version="2.0.6" date="2024-09-29">
<url type="details">https://github.com/Jeffser/Alpaca/releases/tag/2.0.6</url>
<description>
<p>Fixes</p>
<ul>
<li>Fixed message notification sometimes crashing text rendering because of them running on different threads</li>
</ul>
</description>
</release>
<release version="2.0.5" date="2024-09-25">
<url type="details">https://github.com/Jeffser/Alpaca/releases/tag/2.0.5</url>
<description>
<p>Fixes</p>
<ul>
<li>Fixed message generation sometimes failing</li>
</ul>
</description>
</release>
<release version="2.0.4" date="2024-09-22">
<url type="details">https://github.com/Jeffser/Alpaca/releases/tag/2.0.4</url>
<description>
<p>New</p>
<ul>
<li>Sidebar resizes with the window</li>
<li>New welcome dialog</li>
<li>Message search</li>
<li>Updated Ollama to v0.3.11</li>
<li>A lot of new models provided by Ollama repository</li>
</ul>
<p>Fixes</p>
<ul>
<li>Fixed text inside model manager when the accessibility option 'large text' is on</li>
<li>Fixed image recognition on unsupported models</li>
</ul>
</description>
</release>
<release version="2.0.3" date="2024-09-18">
<url type="details">https://github.com/Jeffser/Alpaca/releases/tag/2.0.3</url>
<description>
<p>Fixes</p>
<ul>
<li>Fixed spinner not hiding if the back end fails</li>
<li>Fixed image recognition with local images</li>
<li>Changed appearance of delete / stop model buttons</li>
<li>Fixed stop button crashing the app</li>
</ul>
<p>New</p>
<ul>
<li>Made sidebar resize a little when the window is smaller</li>
<li>Instant launch</li>
</ul>
</description>
</release>
<release version="2.0.2" date="2024-09-11">
<url type="details">https://github.com/Jeffser/Alpaca/releases/tag/2.0.2</url>
<description>
<p>Fixes</p>
<ul>
<li>Fixed error on first run (welcome dialog)</li>
<li>Fixed checker for Ollama instance (used on system packages)</li>
</ul>
</description>
</release>
<release version="2.0.1" date="2024-09-11">
<url type="details">https://github.com/Jeffser/Alpaca/releases/tag/2.0.1</url>
<description>
<p>Fixes</p>
<ul>
<li>Fixed 'clear chat' option</li>
<li>Fixed welcome dialog causing the local instance to not launch</li>
<li>Fixed support for AMD GPUs</li>
</ul>
</description>
</release>
<release version="2.0.0" date="2024-09-01">
<url type="details">https://github.com/Jeffser/Alpaca/releases/tag/2.0.0</url>
<description>
<p>New</p>
<ul>
<li>Model, message and chat systems have been rewritten</li>
<li>New models are available</li>
<li>Ollama updated to v0.3.9</li>
<li>Added support for multiple chat generations simultaneously</li>
<li>Added experimental AMD GPU support</li>
<li>Added message loading spinner and new message indicator to chat tab</li>
<li>Added animations</li>
<li>Changed model manager / model selector appearance</li>
<li>Changed message appearance</li>
<li>Added markdown and code blocks to user messages</li>
<li>Added loading dialog at launch so the app opens faster</li>
<li>Added warning when device is on 'battery saver' mode</li>
<li>Added inactivity timer to integrated instance</li>
</ul>
<ul>
<li>The chat is now scrolled to the bottom when it's changed</li>
<li>Better handling of focus on messages</li>
<li>Better general performance on the app</li>
</ul>
</description>
</release>
<release version="1.1.1" date="2024-08-12">
<url type="details">https://github.com/Jeffser/Alpaca/releases/tag/1.1.1</url>
<description>
<p>New</p>
<ul>
<li>New duplicate chat option</li>
<li>Changed model selector appearance</li>
<li>Message entry is focused on launch and chat change</li>
<li>Message is focused when it's being edited</li>
<li>Added loading spinner when regenerating a message</li>
<li>Added Ollama debugging to 'About Alpaca' dialog</li>
<li>Changed YouTube transcription dialog appearance and behavior</li>
</ul>
<p>Fixes</p>
<ul>
<li>CTRL+W and CTRL+Q stops local instance before closing the app</li>
<li>Changed appearance of 'Open Model Manager' button on welcome screen</li>
<li>Fixed message generation not working consistently</li>
<li>Fixed message edition not working consistently</li>
</ul>
</description>
</release>
<release version="1.1.0" date="2024-08-10">
<url type="details">https://github.com/Jeffser/Alpaca/releases/tag/1.1.0</url>
<description>
+1 -1
View File
@@ -1,5 +1,5 @@
project('Alpaca', 'c',
version: '1.1.0',
version: '2.7.0',
meson_version: '>= 0.62.0',
default_options: [ 'warning_level=2', 'werror=false', ],
)
+6 -1
View File
@@ -4,5 +4,10 @@ pt_BR
fr
nb_NO
bn
zh_CN
zh_Hans
hi
tr
uk
de
he
te
+7 -1
View File
@@ -5,5 +5,11 @@ src/main.py
src/window.py
src/available_models_descriptions.py
src/connection_handler.py
src/dialogs.py
src/window.ui
src/generic_actions.py
src/custom_widgets/chat_widget.py
src/custom_widgets/message_widget.py
src/custom_widgets/model_widget.py
src/custom_widgets/table_widget.py
src/custom_widgets/dialog_widget.py
src/custom_widgets/terminal_widget.py
+1545 -985
View File
File diff suppressed because it is too large Load Diff
+211 -353
View File
File diff suppressed because it is too large Load Diff
+1742 -1069
View File
File diff suppressed because it is too large Load Diff
+2533 -954
View File
File diff suppressed because it is too large Load Diff
+1767 -1063
View File
File diff suppressed because it is too large Load Diff
+1763 -1091
View File
File diff suppressed because it is too large Load Diff
+3070
View File
File diff suppressed because it is too large Load Diff
+1734 -1065
View File
File diff suppressed because it is too large Load Diff
+2554
View File
File diff suppressed because it is too large Load Diff
+1604 -1026
View File
File diff suppressed because it is too large Load Diff
+2527
View File
File diff suppressed because it is too large Load Diff
+1578 -1009
View File
File diff suppressed because it is too large Load Diff
+1649 -1056
View File
File diff suppressed because it is too large Load Diff
+3056
View File
File diff suppressed because it is too large Load Diff
+3217
View File
File diff suppressed because it is too large Load Diff
+3210
View File
File diff suppressed because it is too large Load Diff
+3083
View File
File diff suppressed because it is too large Load Diff
+93
View File
@@ -0,0 +1,93 @@
name: jeffser-alpaca
base: core24
adopt-info: alpaca
platforms:
amd64:
arm64:
confinement: strict
grade: stable
compression: lzo
slots:
dbus-alpaca:
interface: dbus
bus: session
name: com.jeffser.Alpaca
apps:
alpaca:
command: usr/bin/alpaca
common-id: com.jeffser.Alpaca
extensions:
- gnome
plugs:
- network
- network-bind
- home
- removable-media
ollama:
command: bin/ollama
plugs:
- home
- removable-media
- network
- network-bind
ollama-daemon:
command: bin/ollama serve
daemon: simple
install-mode: enable
restart-condition: on-failure
plugs:
- home
- removable-media
- network
- network-bind
parts:
# Python dependencies
python-deps:
plugin: python
source: .
python-packages:
- requests==2.31.0
- pillow==10.3.0
- pypdf==4.2.0
- pytube==15.0.0
- html2text==2024.2.26
# Ollama plugin
ollama:
plugin: dump
source:
- on amd64: https://github.com/ollama/ollama/releases/download/v0.3.12/ollama-linux-amd64.tgz
- on arm64: https://github.com/ollama/ollama/releases/download/v0.3.12/ollama-linux-arm64.tgz
# Alpaca app
alpaca:
plugin: meson
source-type: git
source: https://github.com/Jeffser/Alpaca.git
source-tag: 2.6.5
source-depth: 1
meson-parameters:
- --prefix=/snap/alpaca/current/usr
override-build: |
craftctl default
sed -i '1c#!/usr/bin/env python3' $CRAFT_PART_INSTALL/snap/alpaca/current/usr/bin/alpaca
parse-info:
- usr/share/metainfo/com.jeffser.Alpaca.metainfo.xml
organize:
snap/alpaca/current: .
after: [python-deps]
deps:
plugin: nil
after: [alpaca]
stage-packages:
- libnuma1
prime:
- usr/lib/*/libnuma.so.1*
+4
View File
@@ -30,6 +30,10 @@
<file alias="icons/scalable/status/image-missing-symbolic.svg">icons/image-missing-symbolic.svg</file>
<file alias="icons/scalable/status/update-symbolic.svg">icons/update-symbolic.svg</file>
<file alias="icons/scalable/status/down-symbolic.svg">icons/down-symbolic.svg</file>
<file alias="icons/scalable/status/chat-bubble-text-symbolic.svg">icons/chat-bubble-text-symbolic.svg</file>
<file alias="icons/scalable/status/execute-from-symbolic.svg">icons/execute-from-symbolic.svg</file>
<file alias="icons/scalable/status/cross-large-symbolic.svg">icons/cross-large-symbolic.svg</file>
<file alias="icons/scalable/status/info-outline-symbolic.svg">icons/info-outline-symbolic.svg</file>
<file preprocess="xml-stripblanks">window.ui</file>
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
</gresource>
+20534 -16806
View File
File diff suppressed because it is too large Load Diff
+76 -57
View File
@@ -1,11 +1,13 @@
descriptions = {
'llama3.2': _("Meta's Llama 3.2 goes small with 1B and 3B models."),
'llama3.1': _("Llama 3.1 is a new state-of-the-art model from Meta available in 8B, 70B and 405B parameter sizes."),
'gemma2': _("Google Gemma 2 is now available in 2 sizes, 9B and 27B."),
'gemma2': _("Google Gemma 2 is a high-performing and efficient model available in three sizes: 2B, 9B, and 27B."),
'qwen2.5': _("Qwen2.5 models are pretrained on Alibaba's latest large-scale dataset, encompassing up to 18 trillion tokens. The model supports up to 128K tokens and has multilingual support."),
'phi3.5': _("A lightweight AI model with 3.8 billion parameters with performance overtaking similarly and larger sized models."),
'nemotron-mini': _("A commercial-friendly small language model by NVIDIA optimized for roleplay, RAG QA, and function calling."),
'mistral-small': _("Mistral Small is a lightweight model designed for cost-effective use in tasks like translation and summarization."),
'mistral-nemo': _("A state-of-the-art 12B model with 128k context length, built by Mistral AI in collaboration with NVIDIA."),
'mistral-large': _("Mistral Large 2 is Mistral's new flagship model that is significantly more capable in code generation, mathematics, and reasoning with 128k context window and support for dozens of languages."),
'qwen2': _("Qwen2 is a new series of large language models from Alibaba group"),
'deepseek-coder-v2': _("An open-source Mixture-of-Experts code language model that achieves performance comparable to GPT4-Turbo in code-specific tasks."),
'phi3': _("Phi-3 is a family of lightweight 3B (Mini) and 14B (Medium) state-of-the-art open models by Microsoft."),
'mistral': _("The 7B model released by Mistral AI, updated to version 0.3."),
'mixtral': _("A set of Mixture of Experts (MoE) model with open weights by Mistral AI in 8x7b and 8x22b parameter sizes."),
'codegemma': _("CodeGemma is a collection of powerful, lightweight models that can perform a variety of coding tasks like fill-in-the-middle code completion, code generation, natural language understanding, mathematical reasoning, and instruction following."),
@@ -15,91 +17,108 @@ descriptions = {
'llama3': _("Meta Llama 3: The most capable openly available LLM to date"),
'gemma': _("Gemma is a family of lightweight, state-of-the-art open models built by Google DeepMind. Updated to version 1.1"),
'qwen': _("Qwen 1.5 is a series of large language models by Alibaba Cloud spanning from 0.5B to 110B parameters"),
'qwen2': _("Qwen2 is a new series of large language models from Alibaba group"),
'phi3': _("Phi-3 is a family of lightweight 3B (Mini) and 14B (Medium) state-of-the-art open models by Microsoft."),
'llama2': _("Llama 2 is a collection of foundation language models ranging from 7B to 70B parameters."),
'codellama': _("A large language model that can use text prompts to generate and discuss code."),
'dolphin-mixtral': _("Uncensored, 8x7b and 8x22b fine-tuned models based on the Mixtral mixture of experts models that excels at coding tasks. Created by Eric Hartford."),
'nomic-embed-text': _("A high-performing open embedding model with a large token context window."),
'llama2-uncensored': _("Uncensored Llama 2 model by George Sung and Jarrad Hope."),
'mxbai-embed-large': _("State-of-the-art large embedding model from mixedbread.ai"),
'dolphin-mixtral': _("Uncensored, 8x7b and 8x22b fine-tuned models based on the Mixtral mixture of experts models that excels at coding tasks. Created by Eric Hartford."),
'phi': _("Phi-2: a 2.7B language model by Microsoft Research that demonstrates outstanding reasoning and language understanding capabilities."),
'deepseek-coder': _("DeepSeek Coder is a capable coding model trained on two trillion code and natural language tokens."),
'dolphin-mistral': _("The uncensored Dolphin model based on Mistral that excels at coding tasks. Updated to version 2.8."),
'orca-mini': _("A general-purpose model ranging from 3 billion parameters to 70 billion, suitable for entry-level hardware."),
'dolphin-llama3': _("Dolphin 2.9 is a new model with 8B and 70B sizes by Eric Hartford based on Llama 3 that has a variety of instruction, conversational, and coding skills."),
'mxbai-embed-large': _("State-of-the-art large embedding model from mixedbread.ai"),
'starcoder2': _("StarCoder2 is the next generation of transparently trained open code LLMs that comes in three sizes: 3B, 7B and 15B parameters."),
'mistral-openorca': _("Mistral OpenOrca is a 7 billion parameter model, fine-tuned on top of the Mistral 7B model using the OpenOrca dataset."),
'yi': _("Yi 1.5 is a high-performing, bilingual language model."),
'llama2-uncensored': _("Uncensored Llama 2 model by George Sung and Jarrad Hope."),
'dolphin-mistral': _("The uncensored Dolphin model based on Mistral that excels at coding tasks. Updated to version 2.8."),
'zephyr': _("Zephyr is a series of fine-tuned versions of the Mistral and Mixtral models that are trained to act as helpful assistants."),
'llama2-chinese': _("Llama 2 based model fine tuned to improve Chinese dialogue ability."),
'yi': _("Yi 1.5 is a high-performing, bilingual language model."),
'dolphin-llama3': _("Dolphin 2.9 is a new model with 8B and 70B sizes by Eric Hartford based on Llama 3 that has a variety of instruction, conversational, and coding skills."),
'orca-mini': _("A general-purpose model ranging from 3 billion parameters to 70 billion, suitable for entry-level hardware."),
'llava-llama3': _("A LLaVA model fine-tuned from Llama 3 Instruct with better scores in several benchmarks."),
'vicuna': _("General use chat model based on Llama and Llama 2 with 2K to 16K context sizes."),
'nous-hermes2': _("The powerful family of models by Nous Research that excels at scientific discussion and coding tasks."),
'tinyllama': _("The TinyLlama project is an open endeavor to train a compact 1.1B Llama model on 3 trillion tokens."),
'wizard-vicuna-uncensored': _("Wizard Vicuna Uncensored is a 7B, 13B, and 30B parameter model based on Llama 2 uncensored by Eric Hartford."),
'codestral': _("Codestral is Mistral AIs first-ever code model designed for code generation tasks."),
'qwen2.5-coder': _("The latest series of Code-Specific Qwen models, with significant improvements in code generation, code reasoning, and code fixing."),
'mistral-openorca': _("Mistral OpenOrca is a 7 billion parameter model, fine-tuned on top of the Mistral 7B model using the OpenOrca dataset."),
'starcoder': _("StarCoder is a code generation model trained on 80+ programming languages."),
'wizardlm2': _("State of the art large language model from Microsoft AI with improved performance on complex chat, multilingual, reasoning and agent use cases."),
'tinyllama': _("The TinyLlama project is an open endeavor to train a compact 1.1B Llama model on 3 trillion tokens."),
'codestral': _("Codestral is Mistral AIs first-ever code model designed for code generation tasks."),
'vicuna': _("General use chat model based on Llama and Llama 2 with 2K to 16K context sizes."),
'llama2-chinese': _("Llama 2 based model fine tuned to improve Chinese dialogue ability."),
'snowflake-arctic-embed': _("A suite of text embedding models by Snowflake, optimized for performance."),
'wizard-vicuna-uncensored': _("Wizard Vicuna Uncensored is a 7B, 13B, and 30B parameter model based on Llama 2 uncensored by Eric Hartford."),
'granite-code': _("A family of open foundation models by IBM for Code Intelligence"),
'codegeex4': _("A versatile model for AI software development scenarios, including code completion."),
'nous-hermes2': _("The powerful family of models by Nous Research that excels at scientific discussion and coding tasks."),
'all-minilm': _("Embedding models on very large sentence level datasets."),
'openchat': _("A family of open-source models trained on a wide variety of data, surpassing ChatGPT on various benchmarks. Updated to version 3.5-0106."),
'aya': _("Aya 23, released by Cohere, is a new family of state-of-the-art, multilingual models that support 23 languages."),
'codeqwen': _("CodeQwen1.5 is a large language model pretrained on a large amount of code data."),
'wizardlm2': _("State of the art large language model from Microsoft AI with improved performance on complex chat, multilingual, reasoning and agent use cases."),
'tinydolphin': _("An experimental 1.1B parameter model trained on the new Dolphin 2.8 dataset by Eric Hartford and based on TinyLlama."),
'openhermes': _("OpenHermes 2.5 is a 7B model fine-tuned by Teknium on Mistral with fully open datasets."),
'wizardcoder': _("State-of-the-art code generation model"),
'stable-code': _("Stable Code 3B is a coding model with instruct and code completion variants on par with models such as Code Llama 7B that are 2.5x larger."),
'codeqwen': _("CodeQwen1.5 is a large language model pretrained on a large amount of code data."),
'wizard-math': _("Model focused on math and logic problems"),
'neural-chat': _("A fine-tuned model based on Mistral with good coverage of domain and language."),
'openhermes': _("OpenHermes 2.5 is a 7B model fine-tuned by Teknium on Mistral with fully open datasets."),
'qwen2-math': _("Qwen2 Math is a series of specialized math language models built upon the Qwen2 LLMs, which significantly outperforms the mathematical capabilities of open-source models and even closed-source models (e.g., GPT4o)."),
'bakllava': _("BakLLaVA is a multimodal model consisting of the Mistral 7B base model augmented with the LLaVA architecture."),
'stablelm2': _("Stable LM 2 is a state-of-the-art 1.6B and 12B parameter language model trained on multilingual data in English, Spanish, German, Italian, French, Portuguese, and Dutch."),
'granite-code': _("A family of open foundation models by IBM for Code Intelligence"),
'all-minilm': _("Embedding models on very large sentence level datasets."),
'llama3-gradient': _("This model extends LLama-3 8B's context length from 8k to over 1m tokens."),
'deepseek-llm': _("An advanced language model crafted with 2 trillion bilingual tokens."),
'wizard-math': _("Model focused on math and logic problems"),
'glm4': _("A strong multi-lingual general language model with competitive performance to Llama 3."),
'neural-chat': _("A fine-tuned model based on Mistral with good coverage of domain and language."),
'reflection': _("A high-performing model trained with a new technique called Reflection-tuning that teaches a LLM to detect mistakes in its reasoning and correct course."),
'llama3-chatqa': _("A model from NVIDIA based on Llama 3 that excels at conversational question answering (QA) and retrieval-augmented generation (RAG)."),
'mistral-large': _("Mistral Large 2 is Mistral's new flagship model that is significantly more capable in code generation, mathematics, and reasoning with 128k context window and support for dozens of languages."),
'moondream': _("moondream2 is a small vision language model designed to run efficiently on edge devices."),
'xwinlm': _("Conversational model based on Llama 2 that performs competitively on various benchmarks."),
'phind-codellama': _("Code generation model based on Code Llama."),
'dolphincoder': _("A 7B and 15B uncensored variant of the Dolphin model family that excels at coding, based on StarCoder2."),
'nous-hermes': _("General use models based on Llama and Llama 2 from Nous Research."),
'sqlcoder': _("SQLCoder is a code completion model fined-tuned on StarCoder for SQL generation tasks"),
'llama3-gradient': _("This model extends LLama-3 8B's context length from 8k to over 1m tokens."),
'starling-lm': _("Starling is a large language model trained by reinforcement learning from AI feedback focused on improving chatbot helpfulness."),
'dolphincoder': _("A 7B and 15B uncensored variant of the Dolphin model family that excels at coding, based on StarCoder2."),
'yarn-llama2': _("An extension of Llama 2 that supports a context of up to 128k tokens."),
'xwinlm': _("Conversational model based on Llama 2 that performs competitively on various benchmarks."),
'deepseek-llm': _("An advanced language model crafted with 2 trillion bilingual tokens."),
'llama3-chatqa': _("A model from NVIDIA based on Llama 3 that excels at conversational question answering (QA) and retrieval-augmented generation (RAG)."),
'orca2': _("Orca 2 is built by Microsoft research, and are a fine-tuned version of Meta's Llama 2 models. The model is designed to excel particularly in reasoning."),
'smollm': _("🪐 A family of small models with 135M, 360M, and 1.7B parameters, trained on a new high-quality dataset."),
'wizardlm': _("General use model based on Llama 2."),
'solar': _("A compact, yet powerful 10.7B large language model designed for single-turn conversation."),
'samantha-mistral': _("A companion assistant trained in philosophy, psychology, and personal relationships. Based on Mistral."),
'dolphin-phi': _("2.7B uncensored Dolphin model by Eric Hartford, based on the Phi language model by Microsoft Research."),
'stable-beluga': _("Llama 2 based model fine tuned on an Orca-style dataset. Originally called Free Willy."),
'moondream': _("moondream2 is a small vision language model designed to run efficiently on edge devices."),
'bakllava': _("BakLLaVA is a multimodal model consisting of the Mistral 7B base model augmented with the LLaVA architecture."),
'wizardlm-uncensored': _("Uncensored version of Wizard LM model"),
'snowflake-arctic-embed': _("A suite of text embedding models by Snowflake, optimized for performance."),
'deepseek-v2': _("A strong, economical, and efficient Mixture-of-Experts language model."),
'medllama2': _("Fine-tuned Llama 2 model to answer medical questions based on an open source medical dataset."),
'starling-lm': _("Starling is a large language model trained by reinforcement learning from AI feedback focused on improving chatbot helpfulness."),
'samantha-mistral': _("A companion assistant trained in philosophy, psychology, and personal relationships. Based on Mistral."),
'solar': _("A compact, yet powerful 10.7B large language model designed for single-turn conversation."),
'orca2': _("Orca 2 is built by Microsoft research, and are a fine-tuned version of Meta's Llama 2 models. The model is designed to excel particularly in reasoning."),
'stable-beluga': _("Llama 2 based model fine tuned on an Orca-style dataset. Originally called Free Willy."),
'dolphin-phi': _("2.7B uncensored Dolphin model by Eric Hartford, based on the Phi language model by Microsoft Research."),
'wizardlm-uncensored': _("Uncensored version of Wizard LM model"),
'hermes3': _("Hermes 3 is the latest version of the flagship Hermes series of LLMs by Nous Research"),
'yi-coder': _("Yi-Coder is a series of open-source code language models that delivers state-of-the-art coding performance with fewer than 10 billion parameters."),
'llava-phi3': _("A new small LLaVA model fine-tuned from Phi 3 Mini."),
'internlm2': _("InternLM2.5 is a 7B parameter model tailored for practical scenarios with outstanding reasoning capability."),
'yarn-mistral': _("An extension of Mistral to support context windows of 64K or 128K."),
'llama-pro': _("An expansion of Llama 2 that specializes in integrating both general language understanding and domain-specific knowledge, particularly in programming and mathematics."),
'nous-hermes2-mixtral': _("The Nous Hermes 2 model from Nous Research, now trained over Mixtral."),
'medllama2': _("Fine-tuned Llama 2 model to answer medical questions based on an open source medical dataset."),
'meditron': _("Open-source medical large language model adapted from Llama 2 to the medical domain."),
'codeup': _("Great code generation model based on Llama2."),
'nexusraven': _("Nexus Raven is a 13B instruction tuned model for function calling tasks."),
'nous-hermes2-mixtral': _("The Nous Hermes 2 model from Nous Research, now trained over Mixtral."),
'codeup': _("Great code generation model based on Llama2."),
'llama3-groq-tool-use': _("A series of models from Groq that represent a significant advancement in open-source AI capabilities for tool use/function calling."),
'everythinglm': _("Uncensored Llama2 based model with support for a 16K context window."),
'llava-phi3': _("A new small LLaVA model fine-tuned from Phi 3 Mini."),
'codegeex4': _("A versatile model for AI software development scenarios, including code completion."),
'glm4': _("A strong multi-lingual general language model with competitive performance to Llama 3."),
'magicoder': _("🎩 Magicoder is a family of 7B parameter models trained on 75K synthetic instruction data using OSS-Instruct, a novel approach to enlightening LLMs with open-source code snippets."),
'stablelm-zephyr': _("A lightweight chat model allowing accurate, and responsive output without requiring high-end hardware."),
'codebooga': _("A high-performing code instruct model created by merging two existing code models."),
'mistrallite': _("MistralLite is a fine-tuned model based on Mistral with enhanced capabilities of processing long contexts."),
'wizard-vicuna': _("Wizard Vicuna is a 13B parameter model based on Llama 2 trained by MelodysDreamj."),
'duckdb-nsql': _("7B parameter text-to-SQL model made by MotherDuck and Numbers Station."),
'megadolphin': _("MegaDolphin-2.2-120b is a transformation of Dolphin-2.2-70b created by interleaving the model with itself."),
'goliath': _("A language model created by combining two fine-tuned Llama 2 70B models into one."),
'notux': _("A top-performing mixture of experts model, fine-tuned with high-quality data."),
'open-orca-platypus2': _("Merge of the Open Orca OpenChat model and the Garage-bAInd Platypus 2 model. Designed for chat and code generation."),
'mistrallite': _("MistralLite is a fine-tuned model based on Mistral with enhanced capabilities of processing long contexts."),
'falcon2': _("Falcon2 is an 11B parameters causal decoder-only model built by TII and trained over 5T tokens."),
'duckdb-nsql': _("7B parameter text-to-SQL model made by MotherDuck and Numbers Station."),
'minicpm-v': _("A series of multimodal LLMs (MLLMs) designed for vision-language understanding."),
'megadolphin': _("MegaDolphin-2.2-120b is a transformation of Dolphin-2.2-70b created by interleaving the model with itself."),
'notux': _("A top-performing mixture of experts model, fine-tuned with high-quality data."),
'goliath': _("A language model created by combining two fine-tuned Llama 2 70B models into one."),
'open-orca-platypus2': _("Merge of the Open Orca OpenChat model and the Garage-bAInd Platypus 2 model. Designed for chat and code generation."),
'notus': _("A 7B chat model fine-tuned with high-quality data and based on Zephyr."),
'dbrx': _("DBRX is an open, general-purpose LLM created by Databricks."),
'internlm2': _("InternLM2.5 is a 7B parameter model tailored for practical scenarios with outstanding reasoning capability."),
'alfred': _("A robust conversational model designed to be used for both chat and instruct use cases."),
'llama3-groq-tool-use': _("A series of models from Groq that represent a significant advancement in open-source AI capabilities for tool use/function calling."),
'bge-m3': _("BGE-M3 is a new model from BAAI distinguished for its versatility in Multi-Functionality, Multi-Linguality, and Multi-Granularity."),
'mathstral': _("MathΣtral: a 7B model designed for math reasoning and scientific discovery by Mistral AI."),
'firefunction-v2': _("An open weights function calling model based on Llama 3, competitive with GPT-4o function calling capabilities."),
'dbrx': _("DBRX is an open, general-purpose LLM created by Databricks."),
'solar-pro': _("Solar Pro Preview: an advanced large language model (LLM) with 22 billion parameters designed to fit into a single GPU"),
'nuextract': _("A 3.8B model fine-tuned on a private high-quality synthetic dataset for information extraction, based on Phi-3."),
'alfred': _("A robust conversational model designed to be used for both chat and instruct use cases."),
'firefunction-v2': _("An open weights function calling model based on Llama 3, competitive with GPT-4o function calling capabilities."),
'reader-lm': _("A series of models that convert HTML content to Markdown content, which is useful for content conversion tasks."),
'bge-large': _("Embedding model from BAAI mapping texts to vectors."),
'deepseek-v2.5': _("An upgraded version of DeekSeek-V2 that integrates the general and coding abilities of both DeepSeek-V2-Chat and DeepSeek-Coder-V2-Instruct."),
'bespoke-minicheck': _("A state-of-the-art fact-checking model developed by Bespoke Labs."),
'paraphrase-multilingual': _("Sentence-transformers model that can be used for tasks like clustering or semantic search."),
}
+147 -25
View File
@@ -2,33 +2,155 @@
"""
Handles requests to remote and integrated instances of Ollama
"""
import json
import requests
#OK=200 response.status_code
URL = None
BEARER_TOKEN = None
import json, os, requests, subprocess, threading, shutil
from .internal import data_dir, cache_dir
from logging import getLogger
from time import sleep
def get_headers(include_json:bool) -> dict:
headers = {}
if include_json:
headers["Content-Type"] = "application/json"
if BEARER_TOKEN:
headers["Authorization"] = "Bearer {}".format(BEARER_TOKEN)
return headers if len(headers.keys()) > 0 else None
logger = getLogger(__name__)
def simple_get(connection_url:str) -> dict:
return requests.get(connection_url, headers=get_headers(False))
window = None
def simple_post(connection_url:str, data) -> dict:
return requests.post(connection_url, headers=get_headers(True), data=data, stream=False)
AMD_support_label = "\n<a href='https://github.com/Jeffser/Alpaca/wiki/AMD-Support'>{}</a>".format(_('Alpaca Support'))
def simple_delete(connection_url:str, data) -> dict:
return requests.delete(connection_url, headers=get_headers(False), json=data)
def log_output(pipe):
with open(os.path.join(data_dir, 'tmp.log'), 'a') as f:
with pipe:
try:
for line in iter(pipe.readline, ''):
print(line, end='')
f.write(line)
f.flush()
if 'msg="model request too large for system"' in line:
window.show_toast(_("Model request too large for system"), window.main_overlay)
elif 'msg="amdgpu detected, but no compatible rocm library found.' in line:
if bool(os.getenv("FLATPAK_ID")):
window.ollama_information_label.set_label(_("AMD GPU detected but the extension is missing, Ollama will use CPU.") + AMD_support_label)
else:
window.ollama_information_label.set_label(_("AMD GPU detected but ROCm is missing, Ollama will use CPU.") + AMD_support_label)
window.ollama_information_label.set_css_classes(['dim-label', 'error'])
elif 'msg="amdgpu is supported"' in line:
window.ollama_information_label.set_label(_("Using AMD GPU type '{}'").format(line.split('=')[-1]))
window.ollama_information_label.set_css_classes(['dim-label', 'success'])
except Exception as e:
pass
def stream_post(connection_url:str, data, callback:callable) -> dict:
response = requests.post(connection_url, headers=get_headers(True), data=data, stream=True)
if response.status_code == 200:
for line in response.iter_lines():
if line:
callback(json.loads(line.decode("utf-8")))
return response
class instance():
def __init__(self, local_port:int, remote_url:str, remote:bool, tweaks:dict, overrides:dict, bearer_token:str, idle_timer_delay:int):
self.local_port=local_port
self.remote_url=remote_url
self.remote=remote
self.tweaks=tweaks
self.overrides=overrides
self.bearer_token=bearer_token
self.idle_timer_delay=idle_timer_delay
self.idle_timer_stop_event=threading.Event()
self.idle_timer=None
self.instance=None
self.busy=0
if not self.remote:
self.start()
def get_headers(self, include_json:bool) -> dict:
headers = {}
if include_json:
headers["Content-Type"] = "application/json"
if self.bearer_token and self.remote:
headers["Authorization"] = "Bearer " + self.bearer_token
return headers if len(headers.keys()) > 0 else None
def request(self, connection_type:str, connection_url:str, data:dict=None, callback:callable=None) -> requests.models.Response:
self.busy += 1
if self.idle_timer and not self.remote:
self.idle_timer_stop_event.set()
self.idle_timer=None
if not self.instance and not self.remote:
self.start()
connection_url = '{}/{}'.format(self.remote_url if self.remote else 'http://127.0.0.1:{}'.format(self.local_port), connection_url)
logger.info('{} : {}'.format(connection_type, connection_url))
response = None
match connection_type:
case "GET":
response = requests.get(connection_url, headers=self.get_headers(False))
case "POST":
if callback:
response = requests.post(connection_url, headers=self.get_headers(True), data=data, stream=True)
if response.status_code == 200:
for line in response.iter_lines():
if line:
callback(json.loads(line.decode("utf-8")))
else:
response = requests.post(connection_url, headers=self.get_headers(True), data=data, stream=False)
case "DELETE":
response = requests.delete(connection_url, headers=self.get_headers(False), data=data)
self.busy -= 1
if not self.idle_timer and not self.remote:
self.start_timer()
return response
def run_timer(self):
if not self.idle_timer_stop_event.wait(self.idle_timer_delay*60):
window.show_toast(_("Ollama instance was shut down due to inactivity"), window.main_overlay)
self.stop()
def start_timer(self):
if self.busy == 0:
if self.idle_timer:
self.idle_timer_stop_event.set()
self.idle_timer=None
if self.idle_timer_delay > 0 and self.busy == 0:
self.idle_timer_stop_event.clear()
self.idle_timer = threading.Thread(target=self.run_timer)
self.idle_timer.start()
def start(self):
self.stop()
if shutil.which('ollama'):
if not os.path.isdir(os.path.join(cache_dir, 'tmp/ollama')):
os.mkdir(os.path.join(cache_dir, 'tmp/ollama'))
self.instance = None
params = self.overrides.copy()
params["OLLAMA_DEBUG"] = "1"
params["OLLAMA_HOST"] = f"127.0.0.1:{self.local_port}" # You can't change this directly sorry :3
params["HOME"] = data_dir
params["TMPDIR"] = os.path.join(cache_dir, 'tmp/ollama')
instance = subprocess.Popen(["ollama", "serve"], env={**os.environ, **params}, stderr=subprocess.PIPE, stdout=subprocess.PIPE, text=True)
threading.Thread(target=log_output, args=(instance.stdout,)).start()
threading.Thread(target=log_output, args=(instance.stderr,)).start()
logger.info("Starting Alpaca's Ollama instance...")
logger.debug(params)
logger.info("Started Alpaca's Ollama instance")
try:
v_str = subprocess.check_output("ollama -v", shell=True).decode('utf-8')
logger.info(v_str.split('\n')[1].strip('Warning: ').strip())
except Exception as e:
logger.error(e)
self.instance = instance
if not self.idle_timer:
self.start_timer()
window.ollama_information_label.set_label(_("Integrated Ollama instance is running"))
window.ollama_information_label.set_css_classes(['dim-label', 'success'])
else:
self.remote = True
window.remote_connection_switch.set_sensitive(True)
window.remote_connection_switch.set_active(True)
def stop(self):
if self.idle_timer:
self.idle_timer_stop_event.set()
self.idle_timer=None
if self.instance:
logger.info("Stopping Alpaca's Ollama instance")
self.instance.terminate()
self.instance.wait()
self.instance = None
window.ollama_information_label.set_label(_("Integrated Ollama instance is not running"))
window.ollama_information_label.set_css_classes(['dim-label'])
logger.info("Stopped Alpaca's Ollama instance")
def reset(self):
logger.info("Resetting Alpaca's Ollama instance")
self.stop()
sleep(1)
self.start()
+458
View File
@@ -0,0 +1,458 @@
#chat_widget.py
"""
Handles the chat widget (testing)
"""
import gi
gi.require_version('Gtk', '4.0')
gi.require_version('GtkSource', '5')
from gi.repository import Gtk, Gio, Adw, Gdk, GLib
import logging, os, datetime, shutil, random, tempfile, tarfile, json
from ..internal import data_dir
from .message_widget import message
logger = logging.getLogger(__name__)
window = None
possible_prompts = [
"What can you do?",
"Give me a pancake recipe",
"Why is the sky blue?",
"Can you tell me a joke?",
"Give me a healthy breakfast recipe",
"How to make a pizza",
"Can you write a poem?",
"Can you write a story?",
"What is GNU-Linux?",
"Which is the best Linux distro?",
"Why is Pluto not a planet?",
"What is a black-hole?",
"Tell me how to stay fit",
"Write a conversation between sun and Earth",
"Why is the grass green?",
"Write an Haïku about AI",
"What is the meaning of life?",
"Explain quantum physics in simple terms",
"Explain the theory of relativity",
"Explain how photosynthesis works",
"Recommend a film about nature",
"What is nostalgia?"
]
class chat(Gtk.ScrolledWindow):
__gtype_name__ = 'AlpacaChat'
def __init__(self, name:str):
self.container = Gtk.Box(
orientation=1,
hexpand=True,
vexpand=True,
spacing=12,
margin_top=12,
margin_bottom=12,
margin_start=12,
margin_end=12
)
self.clamp = Adw.Clamp(
maximum_size=1000,
tightening_threshold=800,
child=self.container
)
super().__init__(
child=self.clamp,
propagate_natural_height=True,
kinetic_scrolling=True,
vexpand=True,
hexpand=True,
css_classes=["undershoot-bottom"],
name=name,
hscrollbar_policy=2
)
self.messages = {}
self.welcome_screen = None
self.regenerate_button = None
self.busy = False
#self.get_vadjustment().connect('notify::page-size', lambda va, *_: va.set_value(va.get_upper() - va.get_page_size()) if va.get_value() == 0 else None)
##TODO Figure out how to do this with the search thing
def stop_message(self):
self.busy = False
window.switch_send_stop_button(True)
def clear_chat(self):
if self.busy:
self.stop_message()
self.messages = {}
self.stop_message()
for widget in list(self.container):
self.container.remove(widget)
self.show_welcome_screen(len(window.model_manager.get_model_list()) > 0)
print('clear chat for some reason')
def add_message(self, message_id:str, model:str=None):
msg = message(message_id, model)
self.messages[message_id] = msg
self.container.append(msg)
def send_sample_prompt(self, prompt):
buffer = window.message_text_view.get_buffer()
buffer.delete(buffer.get_start_iter(), buffer.get_end_iter())
buffer.insert(buffer.get_start_iter(), prompt, len(prompt.encode('utf-8')))
window.send_message()
def show_welcome_screen(self, show_prompts:bool):
if self.welcome_screen:
self.container.remove(self.welcome_screen)
self.welcome_screen = None
if len(list(self.container)) > 0:
self.clear_chat()
return
button_container = Gtk.Box(
orientation=1,
spacing=10,
halign=3
)
if show_prompts:
for prompt in random.sample(possible_prompts, 3):
prompt_button = Gtk.Button(
label=prompt,
tooltip_text=_("Send prompt: '{}'").format(prompt)
)
prompt_button.connect('clicked', lambda *_, prompt=prompt : self.send_sample_prompt(prompt))
button_container.append(prompt_button)
else:
button = Gtk.Button(
label=_("Open Model Manager"),
tooltip_text=_("Open Model Manager"),
css_classes=["suggested-action", "pill"]
)
button.set_action_name('app.manage_models')
button_container.append(button)
self.welcome_screen = Adw.StatusPage(
icon_name="com.jeffser.Alpaca",
title="Alpaca",
description=_("Try one of these prompts") if show_prompts else _("It looks like you don't have any models downloaded yet. Download models to get started!"),
child=button_container,
vexpand=True
)
self.container.append(self.welcome_screen)
def load_chat_messages(self, messages:dict):
if len(messages.keys()) > 0:
if self.welcome_screen:
self.container.remove(self.welcome_screen)
self.welcome_screen = None
for message_id, message_data in messages.items():
if message_data['content']:
self.add_message(message_id, message_data['model'] if message_data['role'] == 'assistant' else None)
message_element = self.messages[message_id]
if 'images' in message_data:
images=[]
for image in message_data['images']:
images.append(os.path.join(data_dir, "chats", self.get_name(), message_id, image))
message_element.add_images(images)
if 'files' in message_data:
files={}
for file_name, file_type in message_data['files'].items():
files[os.path.join(data_dir, "chats", self.get_name(), message_id, file_name)] = file_type
message_element.add_attachments(files)
GLib.idle_add(message_element.set_text, message_data['content'])
GLib.idle_add(message_element.add_footer, datetime.datetime.strptime(message_data['date'] + (":00" if message_data['date'].count(":") == 1 else ""), '%Y/%m/%d %H:%M:%S'))
else:
self.show_welcome_screen(len(window.model_manager.get_model_list()) > 0)
def messages_to_dict(self) -> dict:
messages_dict = {}
for message_id, message_element in self.messages.items():
if message_element.text and message_element.dt:
messages_dict[message_id] = {
'role': 'assistant' if message_element.bot else 'user',
'model': message_element.model,
'date': message_element.dt.strftime("%Y/%m/%d %H:%M:%S"),
'content': message_element.text
}
if message_element.image_c:
images = []
for file in message_element.image_c.files:
images.append(file.image_name)
messages_dict[message_id]['images'] = images
if message_element.attachment_c:
files = {}
for file in message_element.attachment_c.files:
files[file.file_name] = file.file_type
messages_dict[message_id]['files'] = files
return messages_dict
def show_regenerate_button(self, msg:message):
if self.regenerate_button:
self.remove(self.regenerate_button)
self.regenerate_button = Gtk.Button(
child=Adw.ButtonContent(
icon_name='update-symbolic',
label=_('Regenerate Response')
),
css_classes=["suggested-action"],
halign=3
)
self.regenerate_button.connect('clicked', lambda *_: msg.action_buttons.regenerate_message())
self.container.append(self.regenerate_button)
class chat_tab(Gtk.ListBoxRow):
__gtype_name__ = 'AlpacaChatTab'
def __init__(self, chat_window:chat):
self.chat_window=chat_window
self.spinner = Gtk.Spinner(
spinning=True,
visible=False
)
self.label = Gtk.Label(
label=self.chat_window.get_name(),
tooltip_text=self.chat_window.get_name(),
hexpand=True,
halign=0,
wrap=True,
ellipsize=3,
wrap_mode=2,
xalign=0
)
self.indicator = Gtk.Image.new_from_icon_name("chat-bubble-text-symbolic")
self.indicator.set_visible(False)
self.indicator.set_css_classes(['accent'])
container = Gtk.Box(
orientation=0,
spacing=5
)
container.append(self.label)
container.append(self.spinner)
container.append(self.indicator)
super().__init__(
css_classes = ["chat_row"],
height_request = 45,
child = container
)
self.gesture = Gtk.GestureClick(button=3)
self.gesture.connect("released", self.chat_click_handler)
self.add_controller(self.gesture)
def chat_click_handler(self, gesture, n_press, x, y):
chat_row = gesture.get_widget()
popover = Gtk.PopoverMenu(
menu_model=window.chat_right_click_menu,
has_arrow=False,
halign=1,
height_request=155
)
window.selected_chat_row = chat_row
position = Gdk.Rectangle()
position.x = x
position.y = y
popover.set_parent(chat_row.get_child())
popover.set_pointing_to(position)
popover.popup()
class chat_list(Gtk.ListBox):
__gtype_name__ = 'AlpacaChatList'
def __init__(self):
super().__init__(
selection_mode=1,
css_classes=["navigation-sidebar"]
)
self.connect("row-selected", lambda listbox, row: self.chat_changed(row))
self.tab_list = []
def update_welcome_screens(self, show_prompts:bool):
for tab in self.tab_list:
if tab.chat_window.welcome_screen:
tab.chat_window.show_welcome_screen(show_prompts)
def get_tab_by_name(self, chat_name:str) -> chat_tab:
for tab in self.tab_list:
if tab.chat_window.get_name() == chat_name:
return tab
def get_chat_by_name(self, chat_name:str) -> chat:
tab = self.get_tab_by_name(chat_name)
if tab:
return tab.chat_window
def get_current_chat(self) -> chat:
row = self.get_selected_row()
if row:
return self.get_selected_row().chat_window
def send_tab_to_top(self, tab:chat_tab):
self.unselect_all()
self.tab_list.remove(tab)
self.tab_list.insert(0, tab)
self.remove(tab)
self.prepend(tab)
self.select_row(tab)
def append_chat(self, chat_name:str) -> chat:
chat_name = window.generate_numbered_name(chat_name, [tab.chat_window.get_name() for tab in self.tab_list])
chat_window = chat(chat_name)
tab = chat_tab(chat_window)
self.append(tab)
self.tab_list.append(tab)
window.chat_stack.add_child(chat_window)
return chat_window
def prepend_chat(self, chat_name:str) -> chat:
chat_name = window.generate_numbered_name(chat_name, [tab.chat_window.get_name() for tab in self.tab_list])
chat_window = chat(chat_name)
tab = chat_tab(chat_window)
self.prepend(tab)
self.tab_list.insert(0, tab)
chat_window.show_welcome_screen(len(window.model_manager.get_model_list()) > 0)
window.chat_stack.add_child(chat_window)
window.chat_list_box.select_row(tab)
return chat_window
def new_chat(self):
window.save_history(self.prepend_chat(_("New Chat")))
def delete_chat(self, chat_name:str):
chat_tab = None
for c in self.tab_list:
if c.chat_window.get_name() == chat_name:
chat_tab = c
if chat_tab:
chat_tab.chat_window.stop_message()
window.chat_stack.remove(chat_tab.chat_window)
self.tab_list.remove(chat_tab)
self.remove(chat_tab)
if os.path.exists(os.path.join(data_dir, "chats", chat_name)):
shutil.rmtree(os.path.join(data_dir, "chats", chat_name))
if len(self.tab_list) == 0:
self.new_chat()
if not self.get_current_chat() or self.get_current_chat() == chat_tab.chat_window:
self.select_row(self.get_row_at_index(0))
window.save_history()
def rename_chat(self, old_chat_name:str, new_chat_name:str):
if new_chat_name == old_chat_name:
return
tab = self.get_tab_by_name(old_chat_name)
if tab:
new_chat_name = window.generate_numbered_name(new_chat_name, [tab.chat_window.get_name() for tab in self.tab_list])
tab.label.set_label(new_chat_name)
tab.label.set_tooltip_text(new_chat_name)
tab.chat_window.set_name(new_chat_name)
if os.path.exists(os.path.join(data_dir, "chats", old_chat_name)):
shutil.move(os.path.join(data_dir, "chats", old_chat_name), os.path.join(data_dir, "chats", new_chat_name))
window.save_history(tab.chat_window)
def duplicate_chat(self, chat_name:str):
new_chat_name = window.generate_numbered_name(_("Copy of {}").format(chat_name), [tab.chat_window.get_name() for tab in self.tab_list])
try:
shutil.copytree(os.path.join(data_dir, "chats", chat_name), os.path.join(data_dir, "chats", new_chat_name))
except Exception as e:
logger.error(e)
self.prepend_chat(new_chat_name)
created_chat = self.get_tab_by_name(new_chat_name).chat_window
created_chat.load_chat_messages(self.get_tab_by_name(chat_name).chat_window.messages_to_dict())
window.save_history(created_chat)
def on_replace_contents(self, file, result):
file.replace_contents_finish(result)
window.show_toast(_("Chat exported successfully"), window.main_overlay)
def on_export_chat(self, file_dialog, result, chat_name):
file = file_dialog.save_finish(result)
if not file:
return
json_data = json.dumps({chat_name: {"messages": self.get_chat_by_name(chat_name).messages_to_dict()}}, indent=4).encode("UTF-8")
with tempfile.TemporaryDirectory() as temp_dir:
json_path = os.path.join(temp_dir, "data.json")
with open(json_path, "wb") as json_file:
json_file.write(json_data)
tar_path = os.path.join(temp_dir, chat_name)
with tarfile.open(tar_path, "w") as tar:
tar.add(json_path, arcname="data.json")
directory = os.path.join(data_dir, "chats", chat_name)
if os.path.exists(directory) and os.path.isdir(directory):
tar.add(directory, arcname=os.path.basename(directory))
with open(tar_path, "rb") as tar:
tar_content = tar.read()
file.replace_contents_async(
tar_content,
etag=None,
make_backup=False,
flags=Gio.FileCreateFlags.NONE,
cancellable=None,
callback=self.on_replace_contents
)
def export_chat(self, chat_name:str):
logger.info("Exporting chat")
file_dialog = Gtk.FileDialog(initial_name=f"{chat_name}.tar")
file_dialog.save(parent=window, cancellable=None, callback=lambda file_dialog, result, chat_name=chat_name: self.on_export_chat(file_dialog, result, chat_name))
def on_chat_imported(self, file_dialog, result):
file = file_dialog.open_finish(result)
if not file:
return
stream = file.read(None)
data_stream = Gio.DataInputStream.new(stream)
tar_content = data_stream.read_bytes(1024 * 1024, None)
with tempfile.TemporaryDirectory() as temp_dir:
tar_filename = os.path.join(temp_dir, "imported_chat.tar")
with open(tar_filename, "wb") as tar_file:
tar_file.write(tar_content.get_data())
with tarfile.open(tar_filename, "r") as tar:
tar.extractall(path=temp_dir)
chat_name = None
chat_content = None
for member in tar.getmembers():
if member.name == "data.json":
json_filepath = os.path.join(temp_dir, member.name)
with open(json_filepath, "r", encoding="utf-8") as json_file:
data = json.load(json_file)
for chat_name, chat_content in data.items():
new_chat_name = window.generate_numbered_name(chat_name, [tab.chat_window.get_name() for tab in self.tab_list])
src_path = os.path.join(temp_dir, chat_name)
dest_path = os.path.join(data_dir, "chats", new_chat_name)
if os.path.exists(src_path) and os.path.isdir(src_path) and not os.path.exists(dest_path):
shutil.copytree(src_path, dest_path)
created_chat = self.prepend_chat(new_chat_name)
created_chat.load_chat_messages(chat_content['messages'])
window.save_history(created_chat)
window.show_toast(_("Chat imported successfully"), window.main_overlay)
def import_chat(self):
logger.info("Importing chat")
file_dialog = Gtk.FileDialog(default_filter=window.file_filter_tar)
file_dialog.open(window, None, self.on_chat_imported)
def chat_changed(self, row):
if row:
current_tab_i = next((i for i, t in enumerate(self.tab_list) if t.chat_window == window.chat_stack.get_visible_child()), -1)
if self.tab_list.index(row) != current_tab_i:
if window.searchentry_messages.get_text() != '':
window.searchentry_messages.set_text('')
window.message_search_changed(window.searchentry_messages, window.chat_stack.get_visible_child())
window.message_searchbar.set_search_mode(False)
window.chat_stack.set_transition_type(4 if self.tab_list.index(row) > current_tab_i else 5)
window.chat_stack.set_visible_child(row.chat_window)
window.switch_send_stop_button(not row.chat_window.busy)
if len(row.chat_window.messages) > 0:
last_model_used = row.chat_window.messages[list(row.chat_window.messages)[-1]].model
window.model_manager.change_model(last_model_used)
if row.indicator.get_visible():
row.indicator.set_visible(False)
+173
View File
@@ -0,0 +1,173 @@
#dialog_widget.py
"""
Handles all dialogs
"""
import gi
gi.require_version('Gtk', '4.0')
gi.require_version('GtkSource', '5')
from gi.repository import Gtk, Gio, Adw, Gdk, GLib
window=None
button_appearance={
'suggested': Adw.ResponseAppearance.SUGGESTED,
'destructive': Adw.ResponseAppearance.DESTRUCTIVE
}
# Don't call this directly outside this script
class baseDialog(Adw.AlertDialog):
__gtype_name__ = 'AlpacaDialogBase'
def __init__(self, heading:str, body:str, close_response:str, options:dict):
self.options = options
super().__init__(
heading=heading,
body=body,
close_response=close_response
)
for option, data in self.options.items():
self.add_response(option, option)
if 'appearance' in data:
self.set_response_appearance(option, button_appearance[data['appearance']])
if 'default' in data and data['default']:
self.set_default_response(option)
class Options(baseDialog):
__gtype_name__ = 'AlpacaDialogOptions'
def __init__(self, heading:str, body:str, close_response:str, options:dict):
super().__init__(
heading,
body,
close_response,
options
)
self.choose(
parent = window,
cancellable = None,
callback = self.response
)
def response(self, dialog, task):
result = dialog.choose_finish(task)
if result in self.options and 'callback' in self.options[result]:
self.options[result]['callback']()
class Entry(baseDialog):
__gtype_name__ = 'AlpacaDialogEntry'
def __init__(self, heading:str, body:str, close_response:str, options:dict, entries:list or dict):
super().__init__(
heading,
body,
close_response,
options
)
self.container = Gtk.Box(
orientation=1,
spacing=10
)
if isinstance(entries, dict):
entries = [entries]
for data in entries:
entry = Gtk.Entry()
if 'placeholder' in data and data['placeholder']:
entry.set_placeholder_text(data['placeholder'])
if 'css' in data and data['css']:
entry.set_css_classes(data['css'])
if 'text' in data and data['text']:
entry.set_text(data['text'])
self.container.append(entry)
self.set_extra_child(self.container)
self.connect('realize', lambda *_: list(self.container)[0].grab_focus())
self.choose(
parent = window,
cancellable = None,
callback = self.response
)
def response(self, dialog, task):
result = dialog.choose_finish(task)
if result in self.options and 'callback' in self.options[result]:
entry_results = []
for entry in list(self.container):
entry_results.append(entry.get_text())
self.options[result]['callback'](*entry_results)
class DropDown(baseDialog):
__gtype_name__ = 'AlpacaDialogDropDown'
def __init__(self, heading:str, body:str, close_response:str, options:dict, items:list):
super().__init__(
heading,
body,
close_response,
options
)
string_list = Gtk.StringList()
for item in items:
string_list.append(item)
self.set_extra_child(Gtk.DropDown(
enable_search=len(items) > 10,
model=string_list
))
self.connect('realize', lambda *_: self.get_extra_child().grab_focus())
self.choose(
parent = window,
cancellable = None,
callback = lambda dialog, task, dropdown=self.get_extra_child(): self.response(dialog, task, dropdown.get_selected_item().get_string())
)
def response(self, dialog, task, item:str):
result = dialog.choose_finish(task)
if result in self.options and 'callback' in self.options[result]:
self.options[result]['callback'](item)
def simple(heading:str, body:str, callback:callable, button_name:str=_('Accept'), button_appearance:str='suggested'):
options = {
_('Cancel'): {},
button_name: {
'appearance': button_appearance,
'callback': callback,
'default': True
}
}
return Options(heading, body, 'cancel', options)
def simple_entry(heading:str, body:str, callback:callable, entries:list or dict, button_name:str=_('Accept'), button_appearance:str='suggested'):
options = {
_('Cancel'): {},
button_name: {
'appearance': button_appearance,
'callback': callback,
'default': True
}
}
return Entry(heading, body, 'cancel', options, entries)
def simple_dropdown(heading:str, body:str, callback:callable, items:list, button_name:str=_('Accept'), button_appearance:str='suggested'):
options = {
_('Cancel'): {},
button_name: {
'appearance': button_appearance,
'callback': callback,
'default': True
}
}
return DropDown(heading, body, 'cancel', options, items)
def simple_file(file_filter:Gtk.FileFilter, callback:callable):
file_dialog = Gtk.FileDialog(default_filter=file_filter)
file_dialog.open(window, None, lambda file_dialog, result: callback(file_dialog.open_finish(result)) if result else None)
+634
View File
@@ -0,0 +1,634 @@
#message_widget.py
"""
Handles the message widget (testing)
"""
import gi
gi.require_version('Gtk', '4.0')
gi.require_version('GtkSource', '5')
from gi.repository import Gtk, GObject, Gio, Adw, GtkSource, GLib, Gdk
import logging, os, datetime, re, shutil, threading, sys
from ..internal import config_dir, data_dir, cache_dir, source_dir
from .table_widget import TableWidget
from . import dialog_widget, terminal_widget
logger = logging.getLogger(__name__)
window = None
class edit_text_block(Gtk.Box):
__gtype_name__ = 'AlpacaEditTextBlock'
def __init__(self, text:str):
super().__init__(
hexpand=True,
halign=0,
margin_top=5,
margin_bottom=5,
margin_start=5,
margin_end=5,
spacing=5,
orientation=1
)
self.text_view = Gtk.TextView(
halign=0,
hexpand=True,
css_classes=["view", "editing_message_textview"],
wrap_mode=3
)
cancel_button = Gtk.Button(
vexpand=False,
valign=2,
halign=2,
tooltip_text=_("Cancel"),
css_classes=['flat', 'circular'],
icon_name='cross-large-symbolic'
)
cancel_button.connect('clicked', lambda *_: self.cancel_edit())
save_button = Gtk.Button(
vexpand=False,
valign=2,
halign=2,
tooltip_text=_("Save Message"),
css_classes=['flat', 'circular'],
icon_name='paper-plane-symbolic'
)
save_button.connect('clicked', lambda *_: self.edit_message())
self.append(self.text_view)
button_container = Gtk.Box(
halign=2,
spacing=5
)
button_container.append(cancel_button)
button_container.append(save_button)
self.append(button_container)
self.text_view.get_buffer().insert(self.text_view.get_buffer().get_start_iter(), text, len(text.encode('utf-8')))
key_controller = Gtk.EventControllerKey.new()
key_controller.connect("key-pressed", self.handle_key)
self.text_view.add_controller(key_controller)
def handle_key(self, controller, keyval, keycode, state):
if keyval==Gdk.KEY_Return and not (state & Gdk.ModifierType.SHIFT_MASK):
self.save_edit()
return True
elif keyval==Gdk.KEY_Escape:
self.cancel_edit()
return True
def save_edit(self):
message_element = self.get_parent().get_parent()
message_element.action_buttons.set_visible(True)
message_element.set_text(self.text_view.get_buffer().get_text(self.text_view.get_buffer().get_start_iter(), self.text_view.get_buffer().get_end_iter(), False))
message_element.add_footer(message_element.dt)
window.save_history(message_element.get_parent().get_parent().get_parent().get_parent())
self.get_parent().remove(self)
window.show_toast(_("Message edited successfully"), window.main_overlay)
def cancel_edit(self):
message_element = self.get_parent().get_parent()
message_element.action_buttons.set_visible(True)
message_element.set_text(message_element.text)
message_element.add_footer(message_element.dt)
self.get_parent().remove(self)
class text_block(Gtk.Label):
__gtype_name__ = 'AlpacaTextBlock'
def __init__(self, bot:bool):
super().__init__(
hexpand=True,
halign=0,
wrap=True,
wrap_mode=0,
xalign=0,
margin_top=5,
margin_start=5,
margin_end=5,
focusable=True,
selectable=True
)
self.update_property([4, 7], [_("Response message") if bot else _("User message"), False])
self.connect('notify::has-focus', lambda *_: GLib.idle_add(self.remove_selection) if self.has_focus() else None)
def remove_selection(self):
self.set_selectable(False)
self.set_selectable(True)
def insert_at_end(self, text:str, markdown:bool):
if markdown:
self.set_markup(self.get_text() + text)
else:
self.set_text(self.get_text() + text)
self.update_property([1], [self.get_text()])
def clear_text(self):
self.buffer.delete(self.textbuffer.get_start_iter(), self.textbuffer.get_end_iter())
self.update_property([1], [""])
class code_block(Gtk.Box):
__gtype_name__ = 'AlpacaCodeBlock'
def __init__(self, text:str, language_name:str=None):
super().__init__(
css_classes=["card", "code_block"],
orientation=1,
overflow=1,
margin_start=5,
margin_end=5
)
self.language = None
if language_name:
self.language = GtkSource.LanguageManager.get_default().get_language(language_name)
if self.language:
self.buffer = GtkSource.Buffer.new_with_language(self.language)
else:
self.buffer = GtkSource.Buffer()
self.buffer.set_style_scheme(GtkSource.StyleSchemeManager.get_default().get_scheme('Adwaita-dark'))
self.source_view = GtkSource.View(
auto_indent=True, indent_width=4, buffer=self.buffer, show_line_numbers=True, editable=None,
top_margin=6, bottom_margin=6, left_margin=12, right_margin=12, css_classes=["code_block"]
)
self.source_view.update_property([4], [_("{}Code Block").format('{} '.format(self.language.get_name()) if self.language else "")])
title_box = Gtk.Box(margin_start=12, margin_top=3, margin_bottom=3, margin_end=3)
title_box.append(Gtk.Label(label=self.language.get_name() if self.language else (language_name.title() if language_name else _("Code Block")), hexpand=True, xalign=0))
copy_button = Gtk.Button(icon_name="edit-copy-symbolic", css_classes=["flat", "circular"], tooltip_text=_("Copy Message"))
copy_button.connect("clicked", lambda *_: self.on_copy())
title_box.append(copy_button)
if language_name and language_name.lower() in ['bash', 'python3']:
run_button = Gtk.Button(icon_name="execute-from-symbolic", css_classes=["flat", "circular"], tooltip_text=_("Run Script"))
run_button.connect("clicked", lambda *_: self.run_script(language_name))
title_box.append(run_button)
self.append(title_box)
self.append(Gtk.Separator())
self.append(self.source_view)
self.buffer.set_text(text)
def on_copy(self):
logger.debug("Copying code")
clipboard = Gdk.Display().get_default().get_clipboard()
start = self.buffer.get_start_iter()
end = self.buffer.get_end_iter()
text = self.buffer.get_text(start, end, False)
clipboard.set(text)
window.show_toast(_("Code copied to the clipboard"), window.main_overlay)
def run_script(self, language_name):
logger.debug("Running script")
start = self.buffer.get_start_iter()
end = self.buffer.get_end_iter()
dialog_widget.simple(
_('Run Script'),
_('Make sure you understand what this script does before running it, Alpaca is not responsible for any damages to your device or data'),
lambda script=self.buffer.get_text(start, end, False), language_name=language_name: terminal_widget.run_terminal(script, language_name),
_('Execute'),
'destructive'
)
class attachment(Gtk.Button):
__gtype_name__ = 'AlpacaAttachment'
def __init__(self, file_name:str, file_path:str, file_type:str):
self.file_name = file_name
self.file_path = file_path
self.file_type = file_type
directory, file_name = os.path.split(self.file_path)
head, last_dir = os.path.split(directory)
head, second_last_dir = os.path.split(head)
self.file_path = os.path.join(head, '{selected_chat}', last_dir, file_name)
button_content = Adw.ButtonContent(
label=self.file_name,
icon_name={
"plain_text": "document-text-symbolic",
"pdf": "document-text-symbolic",
"youtube": "play-symbolic",
"website": "globe-symbolic"
}[self.file_type]
)
super().__init__(
vexpand=False,
valign=3,
name=self.file_name,
css_classes=["flat"],
tooltip_text=self.file_name,
child=button_content
)
self.connect("clicked", lambda button, file_path=self.file_path, file_type=self.file_type: window.preview_file(file_path, file_type, None))
class attachment_container(Gtk.ScrolledWindow):
__gtype_name__ = 'AlpacaAttachmentContainer'
def __init__(self):
self.files = []
self.container = Gtk.Box(
orientation=0,
spacing=10,
valign=1
)
super().__init__(
margin_top=10,
margin_start=10,
margin_end=10,
hexpand=True,
child=self.container,
vscrollbar_policy=2
)
def add_file(self, file:attachment):
self.container.append(file)
self.files.append(file)
class image(Gtk.Button):
__gtype_name__ = 'AlpacaImage'
def __init__(self, image_path:str):
self.image_path = image_path
self.image_name = os.path.basename(self.image_path)
directory, file_name = os.path.split(self.image_path)
head, last_dir = os.path.split(directory)
head, second_last_dir = os.path.split(head)
try:
if not os.path.isfile(self.image_path):
raise FileNotFoundError("'{}' was not found or is a directory".format(self.image_path))
image = Gtk.Image.new_from_file(self.image_path)
image.set_size_request(240, 240)
super().__init__(
child=image,
css_classes=["flat", "chat_image_button"],
name=self.image_name,
tooltip_text=_("Image")
)
image.update_property([4], [_("Image")])
except Exception as e:
logger.error(e)
image_texture = Gtk.Image.new_from_icon_name("image-missing-symbolic")
image_texture.set_icon_size(2)
image_texture.set_vexpand(True)
image_texture.set_pixel_size(120)
image_label = Gtk.Label(
label=_("Missing Image"),
)
image_box = Gtk.Box(
spacing=10,
orientation=1,
margin_top=10,
margin_bottom=10,
margin_start=10,
margin_end=10
)
image_box.append(image_texture)
image_box.append(image_label)
image_box.set_size_request(220, 220)
super().__init__(
child=image_box,
css_classes=["flat", "chat_image_button"],
tooltip_text=_("Missing Image")
)
image_texture.update_property([4], [_("Missing image")])
self.set_overflow(1)
self.connect("clicked", lambda button, file_path=os.path.join(head, '{selected_chat}', last_dir, file_name): window.preview_file(file_path, 'image', None))
class image_container(Gtk.ScrolledWindow):
__gtype_name__ = 'AlpacaImageContainer'
def __init__(self):
self.files = []
self.container = Gtk.Box(
orientation=0,
spacing=12
)
super().__init__(
margin_top=10,
margin_start=10,
margin_end=10,
hexpand=True,
height_request = 240,
child=self.container
)
def add_image(self, img:image):
self.container.append(img)
self.files.append(img)
class footer(Gtk.Label):
__gtype_name__ = 'AlpacaMessageFooter'
def __init__(self, dt:datetime.datetime, model:str=None):
super().__init__(
hexpand=False,
halign=0,
wrap=True,
ellipsize=3,
wrap_mode=2,
xalign=0,
margin_bottom=5,
margin_start=5,
focusable=True
)
self.set_markup("<small>{}{}</small>".format((window.convert_model_name(model, 0) + "") if model else "", GLib.markup_escape_text(self.format_datetime(dt))))
def format_datetime(self, dt:datetime) -> str:
date = GLib.DateTime.new(GLib.DateTime.new_now_local().get_timezone(), dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)
current_date = GLib.DateTime.new_now_local()
if date.format("%Y/%m/%d") == current_date.format("%Y/%m/%d"):
return date.format("%H:%M %p")
if date.format("%Y") == current_date.format("%Y"):
return date.format("%b %d, %H:%M %p")
return date.format("%b %d %Y, %H:%M %p")
class action_buttons(Gtk.Box):
__gtype_name__ = 'AlpacaActionButtonContainer'
def __init__(self, bot:bool):
super().__init__(
orientation=0,
spacing=6,
margin_end=6,
margin_bottom=6,
valign="end",
halign="end"
)
self.delete_button = Gtk.Button(
icon_name = "user-trash-symbolic",
css_classes = ["flat", "circular"],
tooltip_text = _("Remove Message")
)
self.delete_button.connect('clicked', lambda *_: self.delete_message())
self.append(self.delete_button)
self.copy_button = Gtk.Button(
icon_name = "edit-copy-symbolic",
css_classes = ["flat", "circular"],
tooltip_text = _("Copy Message")
)
self.copy_button.connect('clicked', lambda *_: self.copy_message())
self.append(self.copy_button)
self.regenerate_button = Gtk.Button(
icon_name = "update-symbolic",
css_classes = ["flat", "circular"],
tooltip_text = _("Regenerate Message")
)
self.regenerate_button.connect('clicked', lambda *_: self.regenerate_message())
self.edit_button = Gtk.Button(
icon_name = "edit-symbolic",
css_classes = ["flat", "circular"],
tooltip_text = _("Edit Message")
)
self.edit_button.connect('clicked', lambda *_: self.edit_message())
self.append(self.regenerate_button if bot else self.edit_button)
def delete_message(self):
logger.debug("Deleting message")
chat = self.get_parent().get_parent().get_parent().get_parent().get_parent()
message_id = self.get_parent().message_id
self.get_parent().get_parent().remove(self.get_parent())
if os.path.exists(os.path.join(data_dir, "chats", window.chat_list_box.get_current_chat().get_name(), self.get_parent().message_id)):
shutil.rmtree(os.path.join(data_dir, "chats", window.chat_list_box.get_current_chat().get_name(), self.get_parent().message_id))
del chat.messages[message_id]
window.save_history(chat)
if len(chat.messages) == 0:
chat.show_welcome_screen(len(window.model_manager.get_model_list()) > 0)
def copy_message(self):
logger.debug("Copying message")
clipboard = Gdk.Display().get_default().get_clipboard()
clipboard.set(self.get_parent().text)
window.show_toast(_("Message copied to the clipboard"), window.main_overlay)
def regenerate_message(self):
chat = self.get_parent().get_parent().get_parent().get_parent().get_parent()
message_element = self.get_parent()
if message_element.spinner:
message_element.container.remove(message_element.spinner)
message_element.spinner = None
if not chat.busy:
message_element.set_text()
if message_element.footer:
message_element.container.remove(message_element.footer)
message_element.remove_overlay(self)
message_element.action_buttons = None
history = window.convert_history_to_ollama(chat)[:list(chat.messages).index(message_element.message_id)]
data = {
"model": window.model_manager.get_selected_model(),
"messages": history,
"options": {"temperature": window.ollama_instance.tweaks["temperature"], "seed": window.ollama_instance.tweaks["seed"]},
"keep_alive": f"{window.ollama_instance.tweaks['keep_alive']}m"
}
thread = threading.Thread(target=window.run_message, args=(data, message_element, chat))
thread.start()
else:
window.show_toast(_("Message cannot be regenerated while receiving a response"), window.main_overlay)
def edit_message(self):
logger.debug("Editing message")
self.get_parent().action_buttons.set_visible(False)
for child in self.get_parent().content_children:
self.get_parent().container.remove(child)
self.get_parent().content_children = []
self.get_parent().container.remove(self.get_parent().footer)
self.get_parent().footer = None
edit_text_b = edit_text_block(self.get_parent().text)
self.get_parent().container.append(edit_text_b)
window.set_focus(edit_text_b)
class message(Gtk.Overlay):
__gtype_name__ = 'AlpacaMessage'
def __init__(self, message_id:str, model:str=None):
self.message_id = message_id
self.bot = model != None
self.dt = None
self.model = model
self.action_buttons = None
self.content_children = [] #These are the code blocks, text blocks and tables
self.footer = None
self.image_c = None
self.attachment_c = None
self.spinner = None
self.text = None
self.container = Gtk.Box(
orientation=1,
halign='fill',
css_classes=["response_message"] if self.bot else ["card", "user_message"],
spacing=5,
width_request=-1 if self.bot else 375
)
super().__init__(
css_classes=["message"],
name=message_id,
halign=0 if self.bot else 2
)
self.set_child(self.container)
def add_attachments(self, attachments:dict):
self.attachment_c = attachment_container()
self.container.append(self.attachment_c)
for file_path, file_type in attachments.items():
file = attachment(os.path.basename(file_path), file_path, file_type)
self.attachment_c.add_file(file)
def add_images(self, images:list):
self.image_c = image_container()
self.container.append(self.image_c)
for image_path in images:
image_element = image(image_path)
self.image_c.add_image(image_element)
def add_footer(self, dt:datetime.datetime):
self.dt = dt
self.footer = footer(self.dt, self.model)
self.container.append(self.footer)
def add_action_buttons(self):
if not self.action_buttons:
self.action_buttons = action_buttons(self.bot)
self.add_overlay(self.action_buttons)
if not self.text:
self.action_buttons.set_visible(False)
def update_message(self, data:dict):
chat = self.get_parent().get_parent().get_parent().get_parent()
if chat.busy:
vadjustment = chat.get_vadjustment()
if self.spinner:
self.container.remove(self.spinner)
self.spinner = None
self.content_children[-1].set_visible(True)
GLib.idle_add(vadjustment.set_value, vadjustment.get_upper())
elif vadjustment.get_value() + 50 >= vadjustment.get_upper() - vadjustment.get_page_size():
GLib.idle_add(vadjustment.set_value, vadjustment.get_upper() - vadjustment.get_page_size())
GLib.idle_add(self.content_children[-1].insert_at_end, data['message']['content'], False)
if 'done' in data and data['done']:
window.chat_list_box.get_tab_by_name(chat.get_name()).spinner.set_visible(False)
if window.chat_list_box.get_current_chat().get_name() != chat.get_name():
window.chat_list_box.get_tab_by_name(chat.get_name()).indicator.set_visible(True)
if chat.welcome_screen:
chat.container.remove(chat.welcome_screen)
chat.welcome_screen = None
chat.stop_message()
self.text = self.content_children[-1].get_label()
GLib.idle_add(self.set_text, self.content_children[-1].get_label())
self.dt = datetime.datetime.now()
GLib.idle_add(self.add_footer, self.dt)
window.show_notification(chat.get_name(), self.text[:200] + (self.text[200:] and '...'), Gio.ThemedIcon.new("chat-message-new-symbolic"))
GLib.idle_add(window.save_history, chat)
else:
if self.spinner:
GLib.idle_add(self.container.remove, self.spinner)
self.spinner = None
chat_tab = window.chat_list_box.get_tab_by_name(chat.get_name())
if chat_tab.spinner:
GLib.idle_add(chat_tab.spinner.set_visible, False)
sys.exit()
def set_text(self, text:str=None):
self.text = text
for child in self.content_children:
self.container.remove(child)
self.content_children = []
if text:
self.content_children = []
code_block_pattern = re.compile(r'```(\w*)\n(.*?)\n\s*```', re.DOTALL)
no_language_code_block_pattern = re.compile(r'`(\w*)\n(.*?)\n\s*`', re.DOTALL)
table_pattern = re.compile(r'((\r?\n){2}|^)([^\r\n]*\|[^\r\n]*(\r?\n)?)+(?=(\r?\n){2}|$)', re.MULTILINE)
markup_pattern = re.compile(r'<(b|u|tt|span.*)>(.*?)<\/(b|u|tt|span)>') #heh butt span, I'm so funny
parts = []
pos = 0
# Code blocks
for match in code_block_pattern.finditer(self.text[pos:]):
start, end = match.span()
if pos < start:
normal_text = self.text[pos:start]
parts.append({"type": "normal", "text": normal_text.strip()})
language = match.group(1)
code_text = match.group(2)
parts.append({"type": "code", "text": code_text, "language": 'python3' if language == 'python' else language})
pos = end
for match in no_language_code_block_pattern.finditer(self.text[pos:]):
start, end = match.span()
if pos < start:
normal_text = self.text[pos:start]
parts.append({"type": "normal", "text": normal_text.strip()})
language = match.group(1)
code_text = match.group(2)
parts.append({"type": "code", "text": code_text, "language": None})
pos = end
# Tables
for match in table_pattern.finditer(self.text[pos:]):
start, end = match.span()
if pos < start:
normal_text = self.text[pos:start]
parts.append({"type": "normal", "text": normal_text.strip()})
table_text = match.group(0)
parts.append({"type": "table", "text": table_text})
pos = end
# Text blocks
if pos < len(self.text):
normal_text = self.text[pos:]
if normal_text.strip():
parts.append({"type": "normal", "text": normal_text.strip()})
for part in parts:
if part['type'] == 'normal':
text_b = text_block(self.bot)
part['text'] = part['text'].replace("\n* ", "\n")
part['text'] = re.sub(r'`([^`\n]*?)`', r'<tt>\1</tt>', part['text'])
part['text'] = re.sub(r'\*\*(.*?)\*\*', r'<b>\1</b>', part['text'], flags=re.MULTILINE)
part['text'] = re.sub(r'^#\s+(.*)', r'<span size="x-large">\1</span>', part['text'], flags=re.MULTILINE)
part['text'] = re.sub(r'^##\s+(.*)', r'<span size="large">\1</span>', part['text'], flags=re.MULTILINE)
part['text'] = re.sub(r'_(\((.*?)\)|\d+)', r'<sub>\2\1</sub>', part['text'], flags=re.MULTILINE)
part['text'] = re.sub(r'\^(\((.*?)\)|\d+)', r'<sup>\2\1</sup>', part['text'], flags=re.MULTILINE)
pos = 0
for match in markup_pattern.finditer(part['text']):
start, end = match.span()
if pos < start:
text_b.insert_at_end(part['text'][pos:start], False)
text_b.insert_at_end(match.group(0), True)
pos = end
if pos < len(part['text']):
text_b.insert_at_end(part['text'][pos:], False)
self.content_children.append(text_b)
self.container.append(text_b)
elif part['type'] == 'code':
code_b = code_block(part['text'], part['language'])
self.content_children.append(code_b)
self.container.append(code_b)
elif part['type'] == 'table':
table_w = TableWidget(part['text'])
self.content_children.append(table_w)
self.container.append(table_w)
self.add_action_buttons()
else:
text_b = text_block(self.bot)
text_b.set_visible(False)
self.content_children.append(text_b)
if self.spinner:
self.container.remove(self.spinner)
self.spinner = None
self.spinner = Gtk.Spinner(spinning=True, margin_top=10, margin_bottom=10, hexpand=True)
self.container.append(self.spinner)
self.container.append(text_b)
self.container.queue_draw()
+673
View File
@@ -0,0 +1,673 @@
#model_widget.py
"""
Handles the model widget (testing)
"""
import gi
gi.require_version('Gtk', '4.0')
gi.require_version('GtkSource', '5')
from gi.repository import Gtk, GObject, Gio, Adw, GtkSource, GLib, Gdk
import logging, os, datetime, re, shutil, threading, json, sys, glob
from ..internal import config_dir, data_dir, cache_dir, source_dir
from .. import available_models_descriptions
from . import dialog_widget
logger = logging.getLogger(__name__)
window = None
class model_selector_popup(Gtk.Popover):
__gtype_name__ = 'AlpacaModelSelectorPopup'
def __init__(self):
manage_models_button = Gtk.Button(
tooltip_text=_('Manage Models'),
child=Gtk.Label(label=_('Manage Models'), halign=1),
hexpand=True,
css_classes=['manage_models_button', 'flat']
)
manage_models_button.set_action_name("app.manage_models")
manage_models_button.connect("clicked", lambda *_: self.hide())
self.model_list_box = Gtk.ListBox(
css_classes=['navigation-sidebar', 'model_list_box'],
height_request=0
)
container = Gtk.Box(
orientation=1,
spacing=5
)
container.append(self.model_list_box)
container.append(Gtk.Separator())
container.append(manage_models_button)
scroller = Gtk.ScrolledWindow(
max_content_height=300,
propagate_natural_width=True,
propagate_natural_height=True,
child=container
)
super().__init__(
css_classes=['model_popover'],
has_arrow=False,
child=scroller
)
class model_selector_row(Gtk.ListBoxRow):
__gtype_name__ = 'AlpacaModelSelectorRow'
def __init__(self, model_name:str, data:dict):
super().__init__(
child = Gtk.Label(
label=window.convert_model_name(model_name, 0),
halign=1,
hexpand=True
),
halign=0,
hexpand=True,
name=model_name,
tooltip_text=window.convert_model_name(model_name, 0)
)
self.data = data
self.image_recognition = 'projector_info' in self.data
class model_selector_button(Gtk.MenuButton):
__gtype_name__ = 'AlpacaModelSelectorButton'
def __init__(self):
self.popover = model_selector_popup()
self.popover.model_list_box.connect('selected-rows-changed', self.model_changed)
self.popover.model_list_box.connect('row-activated', lambda *_: self.get_popover().hide())
container = Gtk.Box(
orientation=0,
spacing=5
)
self.label = Gtk.Label()
container.append(self.label)
container.append(Gtk.Image.new_from_icon_name("down-symbolic"))
super().__init__(
child=container,
popover=self.popover,
halign=3
)
def change_model(self, model_name:str):
for model_row in list(self.get_popover().model_list_box):
if model_name == model_row.get_name():
self.get_popover().model_list_box.select_row(model_row)
break
def model_changed(self, listbox:Gtk.ListBox):
row = listbox.get_selected_row()
if row:
model_name = row.get_name()
self.label.set_label(window.convert_model_name(model_name, 0))
self.set_tooltip_text(window.convert_model_name(model_name, 0))
elif len(list(listbox)) == 0:
window.title_stack.set_visible_child_name('no_models')
window.model_manager.verify_if_image_can_be_used()
def add_model(self, model_name:str):
data = None
response = window.ollama_instance.request("POST", "api/show", json.dumps({"name": model_name}))
if response.status_code != 200:
logger.error(f"Status code was {response.status_code}")
return
try:
data = json.loads(response.text)
except Exception as e:
logger.error(f"Error fetching 'api - show' info: {str(e)}")
model_row = model_selector_row(model_name, data)
GLib.idle_add(self.get_popover().model_list_box.append, model_row)
GLib.idle_add(self.change_model, model_name)
GLib.idle_add(window.title_stack.set_visible_child_name, 'model_selector')
def remove_model(self, model_name:str):
self.get_popover().model_list_box.remove(next((model for model in list(self.get_popover().model_list_box) if model.get_name() == model_name), None))
self.model_changed(self.get_popover().model_list_box)
window.title_stack.set_visible_child_name('model_selector' if len(window.model_manager.get_model_list()) > 0 else 'no_models')
def clear_list(self):
self.get_popover().model_list_box.remove_all()
class pulling_model(Gtk.ListBoxRow):
__gtype_name__ = 'AlpacaPullingModel'
def __init__(self, model_name:str):
model_label = Gtk.Label(
css_classes=["heading"],
label=model_name.split(":")[0].replace("-", " ").title(),
hexpand=True,
halign=1
)
tag_label = Gtk.Label(
css_classes=["subtitle"],
label=model_name.split(":")[1]
)
self.prc_label = Gtk.Label(
css_classes=["subtitle", "numeric"],
label='50%',
hexpand=True,
halign=2
)
subtitle_box = Gtk.Box(
hexpand=True,
spacing=5,
orientation=0
)
subtitle_box.append(tag_label)
subtitle_box.append(self.prc_label)
self.progress_bar = Gtk.ProgressBar(
valign=2,
show_text=False,
css_classes=["horizontal"],
fraction=.5
)
description_box = Gtk.Box(
hexpand=True,
vexpand=True,
spacing=5,
orientation=1
)
description_box.append(model_label)
description_box.append(subtitle_box)
description_box.append(self.progress_bar)
stop_button = Gtk.Button(
icon_name = "media-playback-stop-symbolic",
vexpand = False,
valign = 3,
css_classes = ["error", "circular"],
tooltip_text = _("Stop Pulling '{}'").format(window.convert_model_name(model_name, 0))
)
stop_button.connect('clicked', lambda *i: dialog_widget.simple(
_('Stop Download?'),
_("Are you sure you want to stop pulling '{}'?").format(window.convert_model_name(self.get_name(), 0)),
self.stop,
_('Stop'),
'destructive'
))
container_box = Gtk.Box(
hexpand=True,
vexpand=True,
spacing=10,
orientation=0,
margin_top=10,
margin_bottom=10,
margin_start=10,
margin_end=10
)
container_box.append(description_box)
container_box.append(stop_button)
super().__init__(
child=container_box,
name=model_name
)
self.error = None
self.digests = []
def stop(self):
if len(list(self.get_parent())) == 1:
self.get_parent().set_visible(False)
self.get_parent().remove(self)
def update(self, data):
if 'digest' in data and data['digest'] not in self.digests:
self.digests.append(data['digest'].replace(':', '-'))
if not self.get_parent():
logger.info("Pulling of '{}' was canceled".format(self.get_name()))
directory = os.path.join(data_dir, '.ollama', 'models', 'blobs')
for digest in self.digests:
files_to_delete = glob.glob(os.path.join(directory, digest + '*'))
for file in files_to_delete:
logger.info("Deleting '{}'".format(file))
try:
os.remove(file)
except Exception as e:
logger.error(f"Can't delete file {file}: {e}")
sys.exit()
if 'error' in data:
self.error = data['error']
if 'total' in data and 'completed' in data:
fraction = round(data['completed'] / data['total'], 4)
GLib.idle_add(self.prc_label.set_label, f"{fraction:05.2%}")
GLib.idle_add(self.progress_bar.set_fraction, fraction)
else:
GLib.idle_add(self.prc_label.set_label, data['status'])
GLib.idle_add(self.progress_bar.pulse)
class pulling_model_list(Gtk.ListBox):
__gtype_name__ = 'AlpacaPullingModelList'
def __init__(self):
super().__init__(
selection_mode=0,
css_classes=["boxed-list"],
visible=False
)
class information_bow(Gtk.Box):
__gtype_name__ = 'AlpacaModelInformationBow'
def __init__(self, title:str, subtitle:str):
self.title = title
self.subtitle = subtitle
title_label = Gtk.Label(
label=self.title,
css_classes=['subtitle', 'caption', 'dim-label'],
hexpand=True,
margin_top=10,
margin_start=0,
margin_end=0
)
subtitle_label = Gtk.Label(
label=self.subtitle if self.subtitle else '(none)',
css_classes=['heading'],
hexpand=True,
margin_bottom=10,
margin_start=0,
margin_end=0
)
super().__init__(
spacing=5,
orientation=1,
css_classes=['card']
)
self.append(title_label)
self.append(subtitle_label)
class local_model(Gtk.ListBoxRow):
__gtype_name__ = 'AlpacaLocalModel'
def __init__(self, model_name:str):
model_title = window.convert_model_name(model_name, 0)
model_label = Gtk.Label(
css_classes=["heading"],
label=model_title.split(" (")[0],
hexpand=True,
halign=1
)
tag_label = Gtk.Label(
css_classes=["subtitle"],
label=model_title.split(" (")[1][:-1],
hexpand=True,
halign=1
)
description_box = Gtk.Box(
hexpand=True,
vexpand=True,
spacing=5,
orientation=1
)
description_box.append(model_label)
description_box.append(tag_label)
info_button = Gtk.Button(
icon_name = "info-outline-symbolic",
vexpand = False,
valign = 3,
css_classes = ["circular"],
tooltip_text = _("Details")
)
info_button.connect('clicked', self.show_information)
delete_button = Gtk.Button(
icon_name = "user-trash-symbolic",
vexpand = False,
valign = 3,
css_classes = ["error", "circular"],
tooltip_text = _("Remove '{}'").format(window.convert_model_name(model_name, 0))
)
delete_button.connect('clicked', lambda *i: dialog_widget.simple(
_('Delete Model?'),
_("Are you sure you want to delete '{}'?").format(model_title),
lambda model_name=model_name: window.model_manager.remove_local_model(model_name),
_('Delete'),
'destructive'
))
container_box = Gtk.Box(
hexpand=True,
vexpand=True,
spacing=10,
orientation=0,
margin_top=10,
margin_bottom=10,
margin_start=10,
margin_end=10
)
container_box.append(description_box)
container_box.append(info_button)
container_box.append(delete_button)
super().__init__(
child=container_box,
name=model_name
)
def show_information(self, button):
model = next((element for element in list(window.model_manager.model_selector.get_popover().model_list_box) if element.get_name() == self.get_name()), None)
model_name = model.get_child().get_label()
window.model_detail_page.set_title(' ('.join(model_name.split(' (')[:-1]))
window.model_detail_page.set_description(' ('.join(model_name.split(' (')[-1:])[:-1])
window.model_detail_create_button.set_name(model_name)
window.model_detail_create_button.set_tooltip_text(_("Create Model Based on '{}'").format(model_name))
details_flow_box = Gtk.FlowBox(
valign=1,
hexpand=True,
vexpand=False,
selection_mode=0,
max_children_per_line=2,
min_children_per_line=1,
margin_top=12,
margin_bottom=12,
margin_start=12,
margin_end=12
)
translation_strings={
'modified_at': _('Modified At'),
'parent_model': _('Parent Model'),
'format': _('Format'),
'family': _('Family'),
'parameter_size': _('Parameter Size'),
'quantization_level': _('Quantization Level')
}
if 'modified_at' in model.data and model.data['modified_at']:
details_flow_box.append(information_bow(
title=translation_strings['modified_at'],
subtitle=datetime.datetime.strptime(':'.join(model.data['modified_at'].split(':')[:2]), '%Y-%m-%dT%H:%M').strftime('%Y-%m-%d %H:%M')
))
for name, value in model.data['details'].items():
if isinstance(value, str):
details_flow_box.append(information_bow(
title=translation_strings[name] if name in translation_strings else name.replace('_', ' ').title(),
subtitle=value
))
window.model_detail_page.set_child(details_flow_box)
window.navigation_view_manage_models.push_by_tag('model_information')
class local_model_list(Gtk.ListBox):
__gtype_name__ = 'AlpacaLocalModelList'
def __init__(self):
super().__init__(
selection_mode=0,
css_classes=["boxed-list"],
visible=False
)
def add_model(self, model_name:str):
model = local_model(model_name)
GLib.idle_add(self.append, model)
if not self.get_visible():
self.set_visible(True)
def remove_model(self, model_name:str):
self.remove(next((model for model in list(self) if model.get_name() == model_name), None))
class available_model(Gtk.ListBoxRow):
__gtype_name__ = 'AlpacaAvailableModel'
def __init__(self, model_name:str, model_author:str, model_description:str, image_recognition:bool):
self.model_description = model_description
self.model_title = model_name.replace("-", " ").title()
self.model_author = model_author
self.image_recognition = image_recognition
model_label = Gtk.Label(
css_classes=["heading"],
label="<b>{}</b> <small>by {}</small>".format(self.model_title, self.model_author),
hexpand=True,
halign=1,
use_markup=True,
wrap=True,
wrap_mode=0
)
description_label = Gtk.Label(
css_classes=["subtitle"],
label=self.model_description,
hexpand=True,
halign=1,
wrap=True,
wrap_mode=0,
)
image_recognition_indicator = Gtk.Button(
css_classes=["success", "pill", "image_recognition_indicator"],
child=Gtk.Label(
label=_("Image Recognition"),
css_classes=["subtitle"]
),
halign=1
)
description_box = Gtk.Box(
hexpand=True,
vexpand=True,
spacing=5,
orientation=1
)
description_box.append(model_label)
description_box.append(description_label)
if self.image_recognition: description_box.append(image_recognition_indicator)
container_box = Gtk.Box(
hexpand=True,
vexpand=True,
spacing=10,
orientation=0,
margin_top=10,
margin_bottom=10,
margin_start=10,
margin_end=10
)
next_icon = Gtk.Image.new_from_icon_name("go-next")
next_icon.update_property([4], [_("Enter download menu for {}").format(self.model_title)])
container_box.append(description_box)
container_box.append(next_icon)
super().__init__(
child=container_box,
name=model_name
)
gesture_click = Gtk.GestureClick.new()
gesture_click.connect("pressed", lambda *_: self.show_pull_menu())
event_controller_key = Gtk.EventControllerKey.new()
event_controller_key.connect("key-pressed", lambda controller, key, *_: self.show_pull_menu() if key in (Gdk.KEY_space, Gdk.KEY_Return) else None)
self.add_controller(gesture_click)
self.add_controller(event_controller_key)
def confirm_pull_model(self, model_name):
threading.Thread(target=window.model_manager.pull_model, args=(model_name,)).start()
window.navigation_view_manage_models.pop()
def show_pull_menu(self):
with open(os.path.join(source_dir, 'available_models.json'), 'r', encoding="utf-8") as f:
data = json.load(f)
window.navigation_view_manage_models.push_by_tag('model_tags_page')
window.navigation_view_manage_models.find_page('model_tags_page').set_title(self.get_name().replace("-", " ").title())
window.model_link_button.set_name(data[self.get_name()]['url'])
window.model_link_button.set_tooltip_text(data[self.get_name()]['url'])
window.model_tag_list_box.remove_all()
tags = data[self.get_name()]['tags']
for tag_data in tags:
if f"{self.get_name()}:{tag_data[0]}" not in window.model_manager.get_model_list():
tag_row = Adw.ActionRow(
title = tag_data[0],
subtitle = tag_data[1],
name = f"{self.get_name()}:{tag_data[0]}"
)
download_icon = Gtk.Image.new_from_icon_name("folder-download-symbolic")
tag_row.add_suffix(download_icon)
download_icon.update_property([4], [_("Download {}:{}").format(self.get_name(), tag_data[0])])
gesture_click = Gtk.GestureClick.new()
gesture_click.connect("pressed", lambda *_, name=f"{self.get_name()}:{tag_data[0]}" : self.confirm_pull_model(name))
event_controller_key = Gtk.EventControllerKey.new()
event_controller_key.connect("key-pressed", lambda controller, key, *_, name=f"{self.get_name()}:{tag_data[0]}" : self.confirm_pull_model(name) if key in (Gdk.KEY_space, Gdk.KEY_Return) else None)
tag_row.add_controller(gesture_click)
tag_row.add_controller(event_controller_key)
window.model_tag_list_box.append(tag_row)
class available_model_list(Gtk.ListBox):
__gtype_name__ = 'AlpacaAvailableModelList'
def __init__(self):
super().__init__(
selection_mode=0,
css_classes=["boxed-list"],
visible=False
)
def add_model(self, model_name:str, model_author:str, model_description:str, image_recognition:bool):
model = available_model(model_name, model_author, model_description, image_recognition)
self.append(model)
if not self.get_visible():
self.set_visible(True)
class model_manager_container(Gtk.Box):
__gtype_name__ = 'AlpacaModelManagerContainer'
def __init__(self):
super().__init__(
margin_top=12,
margin_bottom=12,
margin_start=12,
margin_end=12,
spacing=12,
orientation=1
)
self.pulling_list = pulling_model_list()
self.append(self.pulling_list)
self.local_list = local_model_list()
self.append(self.local_list)
self.available_list = available_model_list()
self.append(self.available_list)
self.model_selector = model_selector_button()
window.title_stack.add_named(self.model_selector, 'model_selector')
def add_local_model(self, model_name:str):
self.local_list.add_model(model_name)
if not self.local_list.get_visible():
self.local_list.set_visible(True)
self.model_selector.add_model(model_name)
def remove_local_model(self, model_name:str):
logger.debug("Deleting model")
response = window.ollama_instance.request("DELETE", "api/delete", json.dumps({"name": model_name}))
if response.status_code == 200:
self.local_list.remove_model(model_name)
self.model_selector.remove_model(model_name)
if len(self.get_model_list()) == 0:
self.local_list.set_visible(False)
window.chat_list_box.update_welcome_screens(False)
window.show_toast(_("Model deleted successfully"), window.manage_models_overlay)
else:
window.manage_models_dialog.close()
window.connection_error()
def get_selected_model(self) -> str:
row = self.model_selector.get_popover().model_list_box.get_selected_row()
if row:
return row.get_name()
def get_model_list(self) -> list:
return [model.get_name() for model in list(self.model_selector.get_popover().model_list_box)]
#Should only be called when the app starts
def update_local_list(self):
try:
response = window.ollama_instance.request("GET", "api/tags")
if response.status_code == 200:
self.model_selector.popover.model_list_box.remove_all()
self.local_list.remove_all()
data = json.loads(response.text)
if len(data['models']) == 0:
self.local_list.set_visible(False)
else:
self.local_list.set_visible(True)
for model in data['models']:
threading.Thread(target=self.add_local_model, args=(model['name'], )).start()
else:
window.connection_error()
except Exception as e:
logger.error(e)
window.connection_error()
window.title_stack.set_visible_child_name('model_selector' if len(window.model_manager.get_model_list()) > 0 else 'no_models')
#window.title_stack.set_visible_child_name('model_selector')
window.chat_list_box.update_welcome_screens(len(self.get_model_list()) > 0)
#Should only be called when the app starts
def update_available_list(self):
with open(os.path.join(source_dir, 'available_models.json'), 'r', encoding="utf-8") as f:
for name, model_info in json.load(f).items():
self.available_list.add_model(name, model_info['author'], available_models_descriptions.descriptions[name], model_info['image'])
def change_model(self, model_name:str):
self.model_selector.change_model(model_name)
def verify_if_image_can_be_used(self):
logger.debug("Verifying if image can be used")
selected = self.model_selector.get_popover().model_list_box.get_selected_row()
if selected and selected.image_recognition:
for name, content in window.attachments.items():
if content['type'] == 'image':
content['button'].set_css_classes(["flat"])
return True
elif selected:
for name, content in window.attachments.items():
if content['type'] == 'image':
content['button'].set_css_classes(["flat", "error"])
def pull_model(self, model_name:str, modelfile:str=None):
if ':' not in model_name:
model_name += ':latest'
if model_name not in [model.get_name() for model in list(self.pulling_list)] and model_name not in [model.get_name() for model in list(self.local_list)]:
logger.info("Pulling model: {}".format(model_name))
model = pulling_model(model_name)
self.pulling_list.append(model)
if not self.pulling_list.get_visible():
GLib.idle_add(self.pulling_list.set_visible, True)
if modelfile:
response = window.ollama_instance.request("POST", "api/create", json.dumps({"name": model_name, "modelfile": modelfile}), lambda data: model.update(data))
else:
response = window.ollama_instance.request("POST", "api/pull", json.dumps({"name": model_name}), lambda data: model.update(data))
if response.status_code == 200 and not model.error:
GLib.idle_add(window.show_notification, _("Task Complete"), _("Model '{}' pulled successfully.").format(model_name), Gio.ThemedIcon.new("emblem-ok-symbolic"))
GLib.idle_add(window.show_toast, _("Model '{}' pulled successfully.").format(model_name), window.manage_models_overlay)
self.add_local_model(model_name)
elif response.status_code == 200:
GLib.idle_add(window.show_notification, _("Pull Model Error"), _("Failed to pull model '{}': {}").format(model_name, model.error), Gio.ThemedIcon.new("dialog-error-symbolic"))
GLib.idle_add(window.show_toast, _("Error pulling '{}': {}").format(model_name, model.error), window.manage_models_overlay)
else:
GLib.idle_add(window.show_notification, _("Pull Model Error"), _("Failed to pull model '{}' due to network error.").format(model_name), Gio.ThemedIcon.new("dialog-error-symbolic"))
GLib.idle_add(window.show_toast, _("Error pulling '{}'").format(model_name), window.manage_models_overlay)
GLib.idle_add(window.manage_models_dialog.close)
GLib.idle_add(window.connection_error)
self.pulling_list.remove(model)
GLib.idle_add(window.chat_list_box.update_welcome_screens, len(self.get_model_list()) > 0)
if len(list(self.pulling_list)) == 0:
GLib.idle_add(self.pulling_list.set_visible, False)
@@ -37,7 +37,8 @@ class TableWidget(Gtk.Frame):
def __init__(self, markdown):
super().__init__()
self.set_margin_start(5)
self.set_margin_end(5)
self.table = MarkdownTable()
self.set_halign(Gtk.Align.START)
+91
View File
@@ -0,0 +1,91 @@
#chat_widget.py
"""
Handles the terminal widget
"""
import gi
gi.require_version('Gtk', '4.0')
gi.require_version('Vte', '3.91')
from gi.repository import Gtk, Vte, GLib, Pango, GLib, Gdk
import logging, os, shutil, subprocess, re
from ..internal import data_dir
logger = logging.getLogger(__name__)
window = None
class terminal(Vte.Terminal):
__gtype_name__ = 'AlpacaTerminal'
def __init__(self, script:list):
super().__init__(css_classes=["terminal"])
self.set_font(Pango.FontDescription.from_string("Monospace 12"))
self.set_clear_background(False)
pty = Vte.Pty.new_sync(Vte.PtyFlags.DEFAULT, None)
self.set_pty(pty)
pty.spawn_async(
GLib.get_current_dir(),
script,
[],
GLib.SpawnFlags.DEFAULT,
None,
None,
-1,
None,
None
)
key_controller = Gtk.EventControllerKey()
key_controller.connect("key-pressed", self.on_key_press)
self.add_controller(key_controller)
def on_key_press(self, controller, keyval, keycode, state):
ctrl = state & Gdk.ModifierType.CONTROL_MASK
shift = state & Gdk.ModifierType.SHIFT_MASK
if ctrl and keyval == Gdk.KEY_c:
self.copy_clipboard()
return True
return False
def show_terminal(script):
window.terminal_scroller.set_child(terminal(script))
window.terminal_dialog.present(window)
def run_terminal(script:str, language_name:str):
logger.info('Running: \n{}'.format(language_name))
if language_name == 'python3':
if not os.path.isdir(os.path.join(data_dir, 'pyenv')):
os.mkdir(os.path.join(data_dir, 'pyenv'))
with open(os.path.join(data_dir, 'pyenv', 'main.py'), 'w') as f:
f.write(script)
script = [
'echo "🐍 {}\n"'.format(_('Setting up Python environment...')),
'python3 -m venv "{}"'.format(os.path.join(data_dir, 'pyenv')),
'{} {}'.format(os.path.join(data_dir, 'pyenv', 'bin', 'python3').replace(' ', '\\ '), os.path.join(data_dir, 'pyenv', 'main.py').replace(' ', '\\ '))
]
if os.path.isfile(os.path.join(data_dir, 'pyenv', 'requirements.txt')):
script.insert(1, '{} install -r {} | grep -v "already satisfied"; clear'.format(os.path.join(data_dir, 'pyenv', 'bin', 'pip3'), os.path.join(data_dir, 'pyenv', 'requirements.txt')))
else:
with open(os.path.join(data_dir, 'pyenv', 'requirements.txt'), 'w') as f:
f.write('')
script = ';\n'.join(script)
script += '; echo "\n🦙 {}"'.format(_('Script exited'))
if language_name == 'bash':
script = re.sub(r'(?m)^\s*sudo', 'pkexec', script)
if shutil.which('flatpak-spawn') and language_name == 'bash':
sandbox = True
try:
process = subprocess.run(['flatpak-spawn', '--host', 'bash', '-c', 'echo "test"'], check=True)
sandbox = False
except Exception as e:
pass
if sandbox:
script = 'echo "🦙 {}\n";'.format(_('The script is contained inside Flatpak')) + script
show_terminal(['bash', '-c', script])
else:
show_terminal(['flatpak-spawn', '--host', 'bash', '-c', script])
else:
show_terminal(['bash', '-c', script])
-409
View File
@@ -1,409 +0,0 @@
# dialogs.py
"""
Handles UI dialogs
"""
import os
import logging
from pytube import YouTube
from html2text import html2text
from gi.repository import Adw, Gtk
from . import connection_handler
logger = logging.getLogger(__name__)
# CLEAR CHAT | WORKS
def clear_chat_response(self, dialog, task):
if dialog.choose_finish(task) == "clear":
self.clear_chat()
def clear_chat(self):
if self.bot_message is not None:
self.show_toast(_("Chat cannot be cleared while receiving a message"), self.main_overlay)
return
dialog = Adw.AlertDialog(
heading=_("Clear Chat?"),
body=_("Are you sure you want to clear the chat?"),
close_response="cancel"
)
dialog.add_response("cancel", _("Cancel"))
dialog.add_response("clear", _("Clear"))
dialog.set_response_appearance("clear", Adw.ResponseAppearance.DESTRUCTIVE)
dialog.set_default_response("clear")
dialog.choose(
parent = self,
cancellable = None,
callback = lambda dialog, task: clear_chat_response(self, dialog, task)
)
# DELETE CHAT | WORKS
def delete_chat_response(self, dialog, task, chat_name):
if dialog.choose_finish(task) == "delete":
self.delete_chat(chat_name)
def delete_chat(self, chat_name):
dialog = Adw.AlertDialog(
heading=_("Delete Chat?"),
body=_("Are you sure you want to delete '{}'?").format(chat_name),
close_response="cancel"
)
dialog.add_response("cancel", _("Cancel"))
dialog.add_response("delete", _("Delete"))
dialog.set_response_appearance("delete", Adw.ResponseAppearance.DESTRUCTIVE)
dialog.set_default_response("delete")
dialog.choose(
parent = self,
cancellable = None,
callback = lambda dialog, task, chat_name=chat_name: delete_chat_response(self, dialog, task, chat_name)
)
# RENAME CHAT | WORKS
def rename_chat_response(self, dialog, task, old_chat_name, entry, label_element):
if not entry:
return
new_chat_name = entry.get_text()
if old_chat_name == new_chat_name:
return
if new_chat_name and (task is None or dialog.choose_finish(task) == "rename"):
self.rename_chat(old_chat_name, new_chat_name, label_element)
def rename_chat(self, chat_name, label_element):
entry = Gtk.Entry()
dialog = Adw.AlertDialog(
heading=_("Rename Chat?"),
body=_("Renaming '{}'").format(chat_name),
extra_child=entry,
close_response="cancel"
)
dialog.add_response("cancel", _("Cancel"))
dialog.add_response("rename", _("Rename"))
dialog.set_response_appearance("rename", Adw.ResponseAppearance.SUGGESTED)
dialog.set_default_response("rename")
dialog.choose(
parent = self,
cancellable = None,
callback = lambda dialog, task, old_chat_name=chat_name, entry=entry, label_element=label_element: rename_chat_response(self, dialog, task, old_chat_name, entry, label_element)
)
# NEW CHAT | WORKS | UNUSED REASON: The 'Add Chat' button now creates a chat without a name AKA "New Chat"
def new_chat_response(self, dialog, task, entry):
chat_name = _("New Chat")
if entry is not None and entry.get_text() != "":
chat_name = entry.get_text()
if chat_name and (task is None or dialog.choose_finish(task) == "create"):
self.new_chat(chat_name)
def new_chat(self):
entry = Gtk.Entry()
dialog = Adw.AlertDialog(
heading=_("Create Chat?"),
body=_("Enter name for new chat"),
extra_child=entry,
close_response="cancel"
)
dialog.add_response("cancel", _("Cancel"))
dialog.add_response("create", _("Create"))
dialog.set_response_appearance("create", Adw.ResponseAppearance.SUGGESTED)
dialog.set_default_response("create")
dialog.choose(
parent = self,
cancellable = None,
callback = lambda dialog, task, entry=entry: new_chat_response(self, dialog, task, entry)
)
# STOP PULL MODEL | WORKS
def stop_pull_model_response(self, dialog, task, model_name):
if dialog.choose_finish(task) == "stop":
self.stop_pull_model(model_name)
def stop_pull_model(self, model_name):
#self.pulling_model_list_box.unselect_all()
dialog = Adw.AlertDialog(
heading=_("Stop Download?"),
body=_("Are you sure you want to stop pulling '{} ({})'?").format(model_name.split(":")[0].capitalize(), model_name.split(":")[1]),
close_response="cancel"
)
dialog.add_response("cancel", _("Cancel"))
dialog.add_response("stop", _("Stop"))
dialog.set_response_appearance("stop", Adw.ResponseAppearance.DESTRUCTIVE)
dialog.set_default_response("stop")
dialog.choose(
parent = self.manage_models_dialog,
cancellable = None,
callback = lambda dialog, task, model_name = model_name: stop_pull_model_response(self, dialog, task, model_name)
)
# DELETE MODEL | WORKS
def delete_model_response(self, dialog, task, model_name):
if dialog.choose_finish(task) == "delete":
self.delete_model(model_name)
def delete_model(self, model_name):
dialog = Adw.AlertDialog(
heading=_("Delete Model?"),
body=_("Are you sure you want to delete '{}'?").format(model_name),
close_response="cancel"
)
dialog.add_response("cancel", _("Cancel"))
dialog.add_response("delete", _("Delete"))
dialog.set_response_appearance("delete", Adw.ResponseAppearance.DESTRUCTIVE)
dialog.set_default_response("delete")
dialog.choose(
parent = self.manage_models_dialog,
cancellable = None,
callback = lambda dialog, task, model_name = model_name: delete_model_response(self, dialog, task, model_name)
)
# REMOVE IMAGE | WORKS
def remove_attached_file_response(self, dialog, task, name):
if dialog.choose_finish(task) == 'remove':
self.file_preview_dialog.close()
self.remove_attached_file(name)
def remove_attached_file(self, name):
dialog = Adw.AlertDialog(
heading=_("Remove Attachment?"),
body=_("Are you sure you want to remove attachment?"),
close_response="cancel"
)
dialog.add_response("cancel", _("Cancel"))
dialog.add_response("remove", _("Remove"))
dialog.set_response_appearance("remove", Adw.ResponseAppearance.DESTRUCTIVE)
dialog.set_default_response("remove")
dialog.choose(
parent = self,
cancellable = None,
callback = lambda dialog, task, name=name: remove_attached_file_response(self, dialog, task, name)
)
# RECONNECT REMOTE | WORKS
def reconnect_remote_response(self, dialog, task, url_entry, bearer_entry):
response = dialog.choose_finish(task)
if not task or response == "remote":
self.connect_remote(url_entry.get_text(), bearer_entry.get_text())
elif response == "local":
self.connect_local()
elif response == "close":
self.destroy()
def reconnect_remote(self, current_url, current_bearer_token):
entry_url = Gtk.Entry(
css_classes = ["error"],
text = current_url,
placeholder_text = "URL"
)
entry_bearer_token = Gtk.Entry(
css_classes = ["error"] if current_bearer_token else None,
text = current_bearer_token,
placeholder_text = "Bearer Token (Optional)"
)
container = Gtk.Box(
orientation = 1,
spacing = 10
)
container.append(entry_url)
container.append(entry_bearer_token)
dialog = Adw.AlertDialog(
heading=_("Connection Error"),
body=_("The remote instance has disconnected"),
extra_child=container
)
dialog.add_response("close", _("Close Alpaca"))
dialog.add_response("local", _("Use local instance"))
dialog.add_response("remote", _("Connect"))
dialog.set_response_appearance("remote", Adw.ResponseAppearance.SUGGESTED)
dialog.set_default_response("remote")
dialog.choose(
parent = self,
cancellable = None,
callback = lambda dialog, task, url_entry=entry_url, bearer_entry=entry_bearer_token: reconnect_remote_response(self, dialog, task, url_entry, bearer_entry)
)
# CREATE MODEL | WORKS
def create_model_from_existing_response(self, dialog, task, dropdown):
model = dropdown.get_selected_item().get_string()
if dialog.choose_finish(task) == 'accept' and model:
self.create_model(model, False)
def create_model_from_existing(self):
string_list = Gtk.StringList()
for model in self.local_models:
string_list.append(self.convert_model_name(model, 0))
dropdown = Gtk.DropDown()
dropdown.set_model(string_list)
dialog = Adw.AlertDialog(
heading=_("Select Model"),
body=_("This model will be used as the base for the new model"),
extra_child=dropdown
)
dialog.add_response("cancel", _("Cancel"))
dialog.add_response("accept", _("Accept"))
dialog.set_response_appearance("accept", Adw.ResponseAppearance.SUGGESTED)
dialog.set_default_response("accept")
dialog.choose(
parent = self,
cancellable = None,
callback = lambda dialog, task, dropdown=dropdown: create_model_from_existing_response(self, dialog, task, dropdown)
)
def create_model_from_file_response(self, file_dialog, result):
try:
file = file_dialog.open_finish(result)
try:
self.create_model(file.get_path(), True)
except Exception as e:
logger.error(e)
self.show_toast(_("An error occurred while creating the model"), self.main_overlay)
except Exception as e:
logger.error(e)
def create_model_from_file(self):
file_dialog = Gtk.FileDialog(default_filter=self.file_filter_gguf)
file_dialog.open(self, None, lambda file_dialog, result: create_model_from_file_response(self, file_dialog, result))
def create_model_from_name_response(self, dialog, task, entry):
model = entry.get_text().lower().strip()
if dialog.choose_finish(task) == 'accept' and model:
self.pull_model(model)
def create_model_from_name(self):
entry = Gtk.Entry()
entry.get_delegate().connect("insert-text", lambda *_ : self.check_alphanumeric(*_, ['-', '.', ':', '_', '/']))
dialog = Adw.AlertDialog(
heading=_("Pull Model"),
body=_("Input the name of the model in this format\nname:tag"),
extra_child=entry
)
dialog.add_response("cancel", _("Cancel"))
dialog.add_response("accept", _("Accept"))
dialog.set_response_appearance("accept", Adw.ResponseAppearance.SUGGESTED)
dialog.set_default_response("accept")
dialog.choose(
parent = self,
cancellable = None,
callback = lambda dialog, task, entry=entry: create_model_from_name_response(self, dialog, task, entry)
)
# FILE CHOOSER | WORKS
def attach_file_response(self, file_dialog, result):
file_types = {
"plain_text": ["txt", "md", "html", "css", "js", "py", "java", "json", "xml"],
"image": ["png", "jpeg", "jpg", "webp", "gif"],
"pdf": ["pdf"]
}
try:
file = file_dialog.open_finish(result)
except Exception as e:
logger.error(e)
return
extension = file.get_path().split(".")[-1]
file_type = next(key for key, value in file_types.items() if extension in value)
if not file_type:
return
if file_type == 'image' and not self.verify_if_image_can_be_used():
self.show_toast(_("Image recognition is only available on specific models"), self.main_overlay)
return
self.attach_file(file.get_path(), file_type)
def attach_file(self, file_filter):
file_dialog = Gtk.FileDialog(default_filter=file_filter)
file_dialog.open(self, None, lambda file_dialog, result: attach_file_response(self, file_dialog, result))
# YouTube caption | WORKS
def youtube_caption_response(self, dialog, task, video_url, caption_drop_down):
if dialog.choose_finish(task) == "accept":
buffer = self.message_text_view.get_buffer()
text = buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter(), False).replace(video_url, "")
buffer.delete(buffer.get_start_iter(), buffer.get_end_iter())
buffer.insert(buffer.get_start_iter(), text, len(text))
yt = YouTube(video_url)
text = "{}\n{}\n{}\n\n".format(yt.title, yt.author, yt.watch_url)
selected_caption = caption_drop_down.get_selected_item().get_string()
for event in yt.captions[selected_caption.split(' | ')[1]].json_captions['events']:
text += "{}\n".format(event['segs'][0]['utf8'].replace('\n', '\\n'))
if not os.path.exists(os.path.join(self.cache_dir, 'tmp/youtube')):
os.makedirs(os.path.join(self.cache_dir, 'tmp/youtube'))
file_path = os.path.join(os.path.join(self.cache_dir, 'tmp/youtube'), f'{yt.title} ({selected_caption.split(" | ")[0]})')
with open(file_path, 'w+', encoding="utf-8") as f:
f.write(text)
self.attach_file(file_path, 'youtube')
def youtube_caption(self, video_url):
yt = YouTube(video_url)
video_title = yt.title
captions = yt.captions
if len(captions) == 0:
self.show_toast(_("This video does not have any transcriptions"), self.main_overlay)
return
caption_list = Gtk.StringList()
for caption in captions:
caption_list.append("{} | {}".format(caption.name, caption.code))
caption_drop_down = Gtk.DropDown(
enable_search=True,
model=caption_list
)
dialog = Adw.AlertDialog(
heading=_("Attach YouTube Video?"),
body=_("{}\n\nPlease select a transcript to include").format(video_title),
extra_child=caption_drop_down,
close_response="cancel"
)
dialog.add_response("cancel", _("Cancel"))
dialog.add_response("accept", _("Accept"))
dialog.set_response_appearance("accept", Adw.ResponseAppearance.SUGGESTED)
dialog.set_default_response("accept")
dialog.choose(
parent = self,
cancellable = None,
callback = lambda dialog, task, video_url = video_url, caption_drop_down = caption_drop_down: youtube_caption_response(self, dialog, task, video_url, caption_drop_down)
)
# Website extraction |
def attach_website_response(self, dialog, task, url):
if dialog.choose_finish(task) == "accept":
response = connection_handler.simple_get(url)
if response.status_code == 200:
html = response.text
md = html2text(html)
buffer = self.message_text_view.get_buffer()
textview_text = buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter(), False).replace(url, "")
buffer.delete(buffer.get_start_iter(), buffer.get_end_iter())
buffer.insert(buffer.get_start_iter(), textview_text, len(textview_text))
if not os.path.exists('/tmp/alpaca/websites/'):
os.makedirs('/tmp/alpaca/websites/')
md_name = self.generate_numbered_name('website.md', os.listdir('/tmp/alpaca/websites'))
file_path = os.path.join('/tmp/alpaca/websites/', md_name)
with open(file_path, 'w+', encoding="utf-8") as f:
f.write('{}\n\n{}'.format(url, md))
self.attach_file(file_path, 'website')
else:
self.show_toast(_("An error occurred while extracting text from the website"), self.main_overlay)
def attach_website(self, url):
dialog = Adw.AlertDialog(
heading=_("Attach Website? (Experimental)"),
body=_("Are you sure you want to attach\n'{}'?").format(url),
close_response="cancel"
)
dialog.add_response("cancel", _("Cancel"))
dialog.add_response("accept", _("Accept"))
dialog.set_response_appearance("accept", Adw.ResponseAppearance.SUGGESTED)
dialog.set_default_response("accept")
dialog.choose(
parent = self,
cancellable = None,
callback = lambda dialog, task, url=url: attach_website_response(self, dialog, task, url)
)
+82
View File
@@ -0,0 +1,82 @@
#generic_actions.py
"""
Working on organizing the code
"""
import os, requests
from youtube_transcript_api import YouTubeTranscriptApi
from html2text import html2text
from .internal import cache_dir
window = None
def connect_remote(remote_url:str, bearer_token:str):
window.ollama_instance.remote_url=remote_url
window.ollama_instance.bearer_token=bearer_token
window.ollama_instance.remote = True
window.ollama_instance.stop()
window.model_manager.update_local_list()
window.save_server_config()
def attach_youtube(video_title:str, video_author:str, watch_url:str, video_url:str, video_id:str, caption_name:str):
buffer = window.message_text_view.get_buffer()
text = buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter(), False).replace(video_url, "")
buffer.delete(buffer.get_start_iter(), buffer.get_end_iter())
buffer.insert(buffer.get_start_iter(), text, len(text))
result_text = "{}\n{}\n{}\n\n".format(video_title, video_author, watch_url)
caption_name = caption_name.split(' (')[-1][:-1]
if caption_name.startswith('Translate:'):
original_caption_name = get_youtube_transcripts(video_id)[0].split(' (')[-1][:-1]
transcript = YouTubeTranscriptApi.list_transcripts(video_id).find_transcript([original_caption_name]).translate(caption_name.split(':')[-1]).fetch()
result_text += '(Auto translated from Japanese)\n'
else:
transcript = YouTubeTranscriptApi.get_transcript(video_id, languages=[caption_name])
result_text += '\n'.join([t['text'] for t in transcript])
if not os.path.exists(os.path.join(cache_dir, 'tmp/youtube')):
os.makedirs(os.path.join(cache_dir, 'tmp/youtube'))
file_path = os.path.join(os.path.join(cache_dir, 'tmp/youtube'), '{} ({})'.format(video_title.replace('/', ' '), caption_name))
with open(file_path, 'w+', encoding="utf-8") as f:
f.write(result_text)
window.attach_file(file_path, 'youtube')
def get_youtube_transcripts(video_id:str):
return ['{} ({})'.format(t.language, t.language_code) for t in YouTubeTranscriptApi.list_transcripts(video_id)]
def attach_website(url:str):
response = requests.get(url)
if response.status_code == 200:
html = response.text
md = html2text(html)
buffer = window.message_text_view.get_buffer()
textview_text = buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter(), False).replace(url, "")
buffer.delete(buffer.get_start_iter(), buffer.get_end_iter())
buffer.insert(buffer.get_start_iter(), textview_text, len(textview_text))
if not os.path.exists('/tmp/alpaca/websites/'):
os.makedirs('/tmp/alpaca/websites/')
md_name = window.generate_numbered_name('website.md', os.listdir('/tmp/alpaca/websites'))
file_path = os.path.join('/tmp/alpaca/websites/', md_name)
with open(file_path, 'w+', encoding="utf-8") as f:
f.write('{}\n\n{}'.format(url, md))
window.attach_file(file_path, 'website')
else:
window.show_toast(_("An error occurred while extracting text from the website"), window.main_overlay)
def attach_file(file):
file_types = {
"plain_text": ["txt", "md", "html", "css", "js", "py", "java", "json", "xml"],
"image": ["png", "jpeg", "jpg", "webp", "gif"],
"pdf": ["pdf"]
}
extension = file.get_path().split(".")[-1]
file_type = next(key for key, value in file_types.items() if extension in value)
if not file_type:
return
if file_type == 'image' and not window.model_manager.verify_if_image_can_be_used():
window.show_toast(_("Image recognition is only available on specific models"), window.main_overlay)
return
window.attach_file(file.get_path(), file_type)
+2
View File
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><g fill="#222222"><path d="m 3 0 c -1.644531 0 -3 1.355469 -3 3 v 6 c 0 1.644531 1.355469 3 3 3 h 1 v 4 l 4 -4 h 5 c 1.644531 0 3 -1.355469 3 -3 v -6 c 0 -1.644531 -1.355469 -3 -3 -3 z m 0 2 h 10 c 0.570312 0 1 0.429688 1 1 v 6 c 0 0.570312 -0.429688 1 -1 1 h -10 c -0.570312 0 -1 -0.429688 -1 -1 v -6 c 0 -0.570312 0.429688 -1 1 -1 z m 0 0"/><path d="m 3 3 h 9 v 2 h -9 z m 0 0"/><path d="m 3 6 h 6 v 2 h -6 z m 0 0"/></g></svg>

After

Width:  |  Height:  |  Size: 556 B

+2
View File
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><path d="m 3 2 c -0.265625 0 -0.519531 0.105469 -0.707031 0.292969 c -0.390625 0.390625 -0.390625 1.023437 0 1.414062 l 4.292969 4.292969 l -4.292969 4.292969 c -0.390625 0.390625 -0.390625 1.023437 0 1.414062 s 1.023437 0.390625 1.414062 0 l 4.292969 -4.292969 l 4.292969 4.292969 c 0.390625 0.390625 1.023437 0.390625 1.414062 0 s 0.390625 -1.023437 0 -1.414062 l -4.292969 -4.292969 l 4.292969 -4.292969 c 0.390625 -0.390625 0.390625 -1.023437 0 -1.414062 c -0.1875 -0.1875 -0.441406 -0.292969 -0.707031 -0.292969 s -0.519531 0.105469 -0.707031 0.292969 l -4.292969 4.292969 l -4.292969 -4.292969 c -0.1875 -0.1875 -0.441406 -0.292969 -0.707031 -0.292969 z m 0 0" fill="#222222"/></svg>

After

Width:  |  Height:  |  Size: 816 B

+2
View File
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><path d="m 4.992188 2.996094 v 10 h 1 c 0.175781 0 0.347656 -0.039063 0.5 -0.125 l 7 -4 c 0.308593 -0.171875 0.46875 -0.523438 0.46875 -0.875 c 0 -0.351563 -0.160157 -0.703125 -0.46875 -0.875 l -7 -4 c -0.152344 -0.085938 -0.324219 -0.125 -0.5 -0.125 z m 0 0" fill="#222222"/></svg>

After

Width:  |  Height:  |  Size: 409 B

+2
View File
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><path d="m 8 0 c -4.410156 0 -8 3.589844 -8 8 s 3.589844 8 8 8 s 8 -3.589844 8 -8 s -3.589844 -8 -8 -8 z m 0 2 c 3.332031 0 6 2.667969 6 6 s -2.667969 6 -6 6 s -6 -2.667969 -6 -6 s 2.667969 -6 6 -6 z m 0 1.875 c -0.621094 0 -1.125 0.503906 -1.125 1.125 s 0.503906 1.125 1.125 1.125 s 1.125 -0.503906 1.125 -1.125 s -0.503906 -1.125 -1.125 -1.125 z m -1.523438 3.125 c -0.265624 0.011719 -0.476562 0.230469 -0.476562 0.5 c 0 0.277344 0.222656 0.5 0.5 0.5 h 0.5 v 3 h -0.5 c -0.277344 0 -0.5 0.222656 -0.5 0.5 s 0.222656 0.5 0.5 0.5 h 3 c 0.277344 0 0.5 -0.222656 0.5 -0.5 s -0.222656 -0.5 -0.5 -0.5 h -0.5 v -4 h -2.5 c -0.007812 0 -0.015625 0 -0.023438 0 z m 0 0" fill="#222222"/></svg>

After

Width:  |  Height:  |  Size: 813 B

-47
View File
@@ -1,47 +0,0 @@
# local_instance.py
"""
Handles running, stopping and resetting the integrated Ollama instance
"""
import subprocess
import os
from time import sleep
from logging import getLogger
from .internal import data_dir, cache_dir
logger = getLogger(__name__)
instance = None
port = 11435
overrides = {}
def start():
if not os.path.isdir(os.path.join(cache_dir, 'tmp/ollama')):
os.mkdir(os.path.join(cache_dir, 'tmp/ollama'))
global instance
params = overrides.copy()
params["OLLAMA_HOST"] = f"127.0.0.1:{port}" # You can't change this directly sorry :3
params["HOME"] = data_dir
params["TMPDIR"] = os.path.join(cache_dir, 'tmp/ollama')
instance = subprocess.Popen(["ollama", "serve"], env={**os.environ, **params}, stderr=subprocess.PIPE, text=True)
logger.info("Starting Alpaca's Ollama instance...")
logger.debug(params)
sleep(1)
logger.info("Started Alpaca's Ollama instance")
v_str = subprocess.check_output("ollama -v", shell=True).decode('utf-8')
logger.info('Ollama version: {}'.format(v_str.split('client version is ')[1].strip()))
def stop():
logger.info("Stopping Alpaca's Ollama instance")
global instance
if instance:
instance.terminate()
instance.wait()
instance = None
logger.info("Stopped Alpaca's Ollama instance")
def reset():
logger.info("Resetting Alpaca's Ollama instance")
stop()
sleep(1)
start()
+8 -3
View File
@@ -44,7 +44,10 @@ translators = [
'Aritra Saha (Bengali) https://github.com/olumolu',
'Yuehao Sui (Simplified Chinese) https://github.com/8ar10der',
'Aleksana (Simplified Chinese) https://github.com/Aleksanaa',
'Aritra Saha (Hindi) https://github.com/olumolu'
'Aritra Saha (Hindi) https://github.com/olumolu',
'YusaBecerikli (Turkish) https://github.com/YusaBecerikli',
'Simon (Ukrainian) https://github.com/OriginalSimon',
'Marcel Margenberg (German) https://github.com/MehrzweckMandala'
]
class AlpacaApplication(Adw.Application):
@@ -53,9 +56,11 @@ class AlpacaApplication(Adw.Application):
def __init__(self, version):
super().__init__(application_id='com.jeffser.Alpaca',
flags=Gio.ApplicationFlags.DEFAULT_FLAGS)
self.create_action('quit', lambda *_: self.quit(), ['<primary>w', '<primary>q'])
self.create_action('preferences', lambda *_: AlpacaWindow.show_preferences_dialog(self.props.active_window), ['<primary>comma'])
self.create_action('quit', lambda *_: self.props.active_window.closing_app(None), ['<primary>q'])
self.set_accels_for_action('app.delete_current_chat', ['<primary>w'])
self.create_action('preferences', lambda *_: self.props.active_window.preferences_dialog.present(self.props.active_window), ['<primary>comma'])
self.create_action('about', self.on_about_action)
self.set_accels_for_action("win.show-help-overlay", ['<primary>slash'])
self.version = version
def do_activate(self):
+12 -4
View File
@@ -40,12 +40,20 @@ alpaca_sources = [
'main.py',
'window.py',
'connection_handler.py',
'dialogs.py',
'local_instance.py',
'available_models.json',
'available_models_descriptions.py',
'table_widget.py',
'internal.py'
'internal.py',
'generic_actions.py'
]
custom_widgets = [
'custom_widgets/table_widget.py',
'custom_widgets/message_widget.py',
'custom_widgets/chat_widget.py',
'custom_widgets/model_widget.py',
'custom_widgets/terminal_widget.py',
'custom_widgets/dialog_widget.py'
]
install_data(alpaca_sources, install_dir: moduledir)
install_data(custom_widgets, install_dir: moduledir / 'custom_widgets')
+22 -3
View File
@@ -4,6 +4,9 @@
.chat_image_button {
padding: 0;
}
.chat_image_button, .chat_image_button image {
border-radius: 10px;
}
.editing_message_textview {
border-radius: 5px;
padding: 5px;
@@ -13,14 +16,30 @@
}
.manage_models_button {
padding: 6px 8px 6px 8px;
font-weight: 400;
}
.model_list_box > * {
margin: 0;
}
.user_message, .response_message {
padding: 12px;
.user_message > label, .response_message > label {
padding: 7px;
border-radius: 10px;
}
.user_message:focus, .response_message:focus, .editing_message_textview:focus, .code_block:focus {
.user_message label:focus, .response_message label:focus, .editing_message_textview:focus, .code_block:focus {
box-shadow: 0 0 1px 2px mix(@accent_color, @window_bg_color, 0.5);
}
.model_popover {
margin-top: 6px;
}
stacksidebar {
border: none;
}
.image_recognition_indicator {
padding: 0px 10px;
}
.code_block {
font-family: monospace;
}
.terminal {
padding: 10px;
}
+482 -1356
View File
File diff suppressed because it is too large Load Diff
+388 -330
View File
@@ -6,7 +6,7 @@
<signal name="close-request" handler="closing_app"/>
<property name="resizable">True</property>
<property name="width-request">400</property>
<property name="height-request">400</property>
<property name="height-request">600</property>
<property name="default-width">1300</property>
<property name="default-height">800</property>
<property name="title">Alpaca</property>
@@ -14,317 +14,281 @@
<object class="AdwBreakpoint">
<condition>max-width: 690sp</condition>
<setter object="split_view_overlay" property="collapsed">true</setter>
<setter object="terminal_dialog" property="width-request">400</setter>
</object>
</child>
<property name="content">
<object class="AdwOverlaySplitView" id="split_view_overlay">
<property name="show-sidebar" bind-source="show_sidebar_button" bind-property="active" bind-flags="sync-create"/>
<property name="sidebar-width-fraction">0.4</property>
<property name="sidebar">
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar">
<child type="start">
<object class="GtkButton" id="add_chat_button">
<property name="tooltip-text" translatable="yes">New Chat</property>
<property name="icon-name">chat-message-new-symbolic</property>
<style>
<class name="flat"/>
</style>
</object>
</child>
<child type="end">
<object class="GtkMenuButton">
<property name="primary">True</property>
<property name="icon-name">open-menu-symbolic</property>
<property name="tooltip-text" translatable="yes">Menu</property>
<property name="menu-model">primary_menu</property>
</object>
</child>
<object class="AdwOverlaySplitView" id="split_view_overlay">
<property name="show-sidebar" bind-source="show_sidebar_button" bind-property="active" bind-flags="sync-create"/>
<property name="sidebar-width-fraction">0.3</property>
<property name="sidebar">
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar">
<child type="start">
<object class="GtkButton" id="add_chat_button">
<property name="action-name">app.new_chat</property>
<property name="tooltip-text" translatable="yes">New Chat</property>
<property name="icon-name">chat-message-new-symbolic</property>
<style>
<class name="flat"/>
</style>
</object>
</child>
<property name="content">
<object class="GtkScrolledWindow">
<property name="vexpand">true</property>
<property name="hexpand">true</property>
<child>
<object class="GtkListBox" id="chat_list_box">
<signal name="row-selected" handler="chat_changed"/>
<property name="selection-mode">single</property>
<style>
<class name="navigation-sidebar"/>
</style>
</object>
</child>
<child type="end">
<object class="GtkMenuButton">
<property name="primary">True</property>
<property name="icon-name">open-menu-symbolic</property>
<property name="tooltip-text" translatable="yes">Menu</property>
<property name="menu-model">primary_menu</property>
</object>
</property>
</child>
</object>
</child>
<property name="content">
<object class="GtkScrolledWindow" id="chat_list_container">
<property name="vexpand">true</property>
<property name="hexpand">true</property>
</object>
</property>
<child>
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar" id="header_bar">
<child type="start">
<object class="GtkToggleButton" id="show_sidebar_button">
<property name="icon-name">sidebar-show-symbolic</property>
<property name="tooltip-text" translatable="yes">Toggle Sidebar</property>
<property name="active" bind-source="split_view_overlay" bind-property="show-sidebar" bind-flags="sync-create"/>
</object>
</property>
<child>
<object class="AdwToolbarView">
<property name="height-request">140</property>
<child type="top">
<object class="AdwHeaderBar">
<child type="start">
<object class="GtkToggleButton" id="show_sidebar_button">
<property name="icon-name">sidebar-show-symbolic</property>
<property name="tooltip-text" translatable="yes">Toggle Sidebar</property>
<property name="active" bind-source="split_view_overlay" bind-property="show-sidebar" bind-flags="sync-create"/>
</object>
</child>
<child type="start">
<object class="GtkToggleButton" id="message_search_button">
<property name="icon-name">edit-find-symbolic</property>
<property name="tooltip-text" translatable="yes">Search Messages</property>
<signal name="clicked" handler="message_search_toggle"/>
</object>
</child>
<child type="title">
<object class="GtkStack" id="title_stack">
<property name="transition_duration">100</property>
<property name="transition_type">1</property>
<child>
<object class="GtkStackPage">
<property name="name">loading</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">0</property>
<property name="spacing">10</property>
<child>
<object class="GtkSpinner">
<property name="spinning">true</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Loading Instance</property>
</object>
</child>
</object>
</property>
</object>
</child>
<property name="title-widget">
<object class="GtkBox">
<property name="orientation">0</property>
<property name="spacing">12</property>
<child>
<object class="GtkMenuButton" id="model_selector_button">
<property name="tooltip-text" translatable="yes">Select Model</property>
<property name="child">
<object class="GtkBox">
<property name="spacing">10</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Select a Model</property>
<property name="ellipsize">2</property>
</object>
</child>
<child>
<object class="GtkImage">
<property name="icon-name">down-symbolic</property>
</object>
</child>
</object>
</property>
<property name="halign">1</property>
<style>
<class name="raised"/>
</style>
<property name="popover">
<object class="GtkPopover" id="model_popover">
<property name="has-arrow">false</property>
<child>
<object class="GtkBox">
<property name="orientation">1</property>
<property name="spacing">5</property>
<child>
<object class="GtkButton">
<property name="child">
<object class="GtkLabel">
<property name="label" translatable="yes">Manage Models</property>
<property name="justify">left</property>
<property name="halign">1</property>
</object>
</property>
<property name="hexpand">true</property>
<property name="tooltip-text" translatable="yes">Manage Models</property>
<property name="action-name">app.manage_models</property>
<signal name="clicked" handler="close_model_popup"/>
<style>
<class name="flat"/>
<class name="manage_models_button"/>
</style>
</object>
</child>
<child>
<object class="GtkSeparator"/>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="max-content-height">300</property>
<property name="propagate-natural-width">true</property>
<property name="propagate-natural-height">true</property>
<child>
<object class="GtkListBox" id="model_list_box">
<property name="hexpand">true</property>
<style>
<class name="navigation-sidebar"/>
<class name="model_list_box"/>
</style>
<signal name="row-selected" handler="change_model"/>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</property>
<child>
<object class="GtkStackPage">
<property name="name">no_models</property>
<property name="child">
<object class="GtkButton">
<property name="label" translatable="yes">Manage Models</property>
<property name="tooltip-text" translatable="yes">Manage Models</property>
<property name="action-name">app.manage_models</property>
</object>
</child>
</object>
</property>
<child type="end">
<object class="GtkMenuButton" id="secondary_menu_button">
<property name="primary">False</property>
<property name="icon-name">view-more-symbolic</property>
<property name="tooltip-text" translatable="yes">Chat Menu</property>
<property name="menu-model">secondary_menu</property>
</property>
</object>
</child>
</object>
</child>
<property name="content">
<object class="GtkBox"><!--ACTUAL CONTENT-->
<property name="orientation">1</property>
<property name="vexpand">true</property>
<child type="end">
<object class="GtkMenuButton" id="secondary_menu_button">
<property name="primary">False</property>
<property name="icon-name">view-more-symbolic</property>
<property name="tooltip-text" translatable="yes">Chat Menu</property>
<property name="menu-model">secondary_menu</property>
</object>
</child>
</object>
</child>
<child type="top">
<object class="GtkSearchBar" id="message_searchbar">
<accessibility>
<property name="label" translatable="yes">Message search bar</property>
</accessibility>
<property name="key-capture-widget">AlpacaWindow</property>
<child>
<object class="GtkSearchEntry" id="searchentry_messages">
<signal name="search-changed" handler="message_search_changed"/>
<property name="search-delay">200</property>
<property name="placeholder-text" translatable="yes">Search messages</property>
<accessibility>
<property name="label" translatable="yes">Search messages</property>
</accessibility>
</object>
</child>
</object>
</child>
<property name="content">
<object class="GtkBox"><!--ACTUAL CONTENT-->
<property name="orientation">1</property>
<property name="vexpand">true</property>
<property name="hexpand">true</property>
<child>
<object class="AdwBanner" id="banner">
<property name="button-label" translatable="true">Close</property>
<property name="title" translatable="yes">Warning: Power saver mode is enabled, this will slow down message generation</property>
</object>
</child>
<child>
<object class="AdwToastOverlay" id="main_overlay">
<child>
<object class="GtkStack" id="chat_stack">
<property name="hexpand">true</property>
<property name="vexpand">true</property>
<property name="hhomogeneous">true</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwClamp">
<property name="maximum-size">1000</property>
<property name="tightening-threshold">800</property>
<child>
<object class="AdwToastOverlay" id="main_overlay">
<child>
<object class="GtkScrolledWindow" id="chat_window">
<property name="propagate-natural-height">true</property>
<property name="kinetic-scrolling">true</property>
<property name="vexpand">true</property>
<style>
<class name="undershoot-bottom"/>
</style>
<object class="GtkBox">
<property name="orientation">1</property>
<property name="spacing">12</property>
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<child>
<object class="AdwClamp">
<property name="maximum-size">1000</property>
<property name="tightening-threshold">800</property>
<object class="GtkScrolledWindow" id="attachment_box">
<property name="visible">false</property>
<child>
<object class="GtkBox" id="chat_container">
<property name="orientation">1</property>
<property name="homogeneous">false</property>
<property name="hexpand">true</property>
<property name="vexpand">true</property>
<object class="GtkBox" id="attachment_container">
<property name="orientation">0</property>
<property name="vexpand">false</property>
<property name="spacing">12</property>
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwClamp">
<property name="maximum-size">1000</property>
<property name="tightening-threshold">800</property>
<child>
<object class="GtkBox">
<property name="orientation">1</property>
<property name="orientation">0</property>
<property name="spacing">12</property>
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<child>
<object class="GtkScrolledWindow" id="attachment_box">
<property name="visible">false</property>
<object class="GtkButton" id="attachment_button">
<property name="vexpand">false</property>
<property name="valign">3</property>
<property name="sensitive">false</property>
<property name="tooltip-text" translatable="yes">Attach File</property>
<style>
<class name="circular"/>
</style>
<child>
<object class="GtkBox" id="attachment_container">
<property name="orientation">0</property>
<property name="vexpand">false</property>
<property name="spacing">12</property>
<object class="AdwButtonContent">
<property name="icon-name">chain-link-loose-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">0</property>
<property name="spacing">12</property>
<style>
<class name="card"/>
</style>
<child>
<object class="GtkButton" id="attachment_button">
<property name="vexpand">false</property>
<property name="valign">3</property>
<property name="tooltip-text" translatable="yes">Attach File</property>
<object class="GtkScrolledWindow">
<property name="max-content-height">150</property>
<property name="propagate-natural-height">true</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<style>
<class name="circular"/>
<class name="message_input_scroll_window"/>
</style>
<child>
<object class="AdwButtonContent">
<property name="icon-name">chain-link-loose-symbolic</property>
<object class="GtkTextView" id="message_text_view">
<signal name="paste-clipboard" handler="on_clipboard_paste"/>
<style>
<class name="message_text_view"/>
<class name="undershoot-bottom"/>
</style>
<property name="wrap-mode">word</property>
<property name="top-margin">10</property>
<property name="bottom-margin">10</property>
<property name="hexpand">true</property>
<property name="input-hints">spellcheck</property>
<accessibility>
<property name="label" translatable="yes">Message text box</property>
</accessibility>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<style>
<class name="card"/>
</style>
<child>
<object class="GtkScrolledWindow">
<property name="max-content-height">150</property>
<property name="propagate-natural-height">true</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<style>
<class name="message_input_scroll_window"/>
</style>
<child>
<object class="GtkTextView" id="message_text_view">
<style>
<class name="message_text_view"/>
</style>
<property name="wrap-mode">word</property>
<property name="top-margin">10</property>
<property name="bottom-margin">10</property>
<property name="hexpand">true</property>
<property name="input-hints">spellcheck</property>
<accessibility>
<property name="label" translatable="yes">Message text box</property>
</accessibility>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="send_button">
<signal name="clicked" handler="send_message"/>
<property name="vexpand">false</property>
<property name="valign">3</property>
<property name="tooltip-text" translatable="yes">Send Message</property>
<property name="sensitive">false</property>
<style>
<class name="accent"/>
<class name="circular"/>
<class name="suggested-action"/>
</style>
<child>
<object class="GtkButton" id="send_button">
<signal name="clicked" handler="send_message"/>
<property name="vexpand">false</property>
<property name="valign">3</property>
<property name="tooltip-text" translatable="yes">Send Message</property>
<style>
<class name="accent"/>
<class name="circular"/>
<class name="suggested-action"/>
</style>
<child>
<object class="AdwButtonContent">
<property name="icon-name">paper-plane-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="stop_button">
<signal name="clicked" handler="stop_message"/>
<property name="vexpand">false</property>
<property name="valign">3</property>
<property name="visible">false</property>
<style>
<class name="destructive-action"/>
<class name="circular"/>
</style>
<child>
<object class="AdwButtonContent">
<property name="icon-name">media-playback-stop-symbolic</property>
</object>
</child>
<object class="AdwButtonContent">
<property name="icon-name">paper-plane-symbolic</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="stop_button">
<signal name="clicked" handler="stop_message"/>
<property name="vexpand">false</property>
<property name="valign">3</property>
<property name="visible">false</property>
<style>
<class name="destructive-action"/>
<class name="circular"/>
</style>
<child>
<object class="AdwButtonContent">
<property name="icon-name">media-playback-stop-symbolic</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object><!--END OF CONTENT-->
</property>
</object>
</child>
</object><!--END OF CONTENT-->
</property>
</object>
</child>
</object>
</property>
<object class="AdwPreferencesDialog" id="preferences_dialog">
@@ -343,35 +307,28 @@
<property name="title" translatable="yes">Use Remote Connection to Ollama</property>
</object>
</child>
<child>
<object class="AdwEntryRow" id="remote_connection_entry">
<signal name="apply" handler="change_remote_url"/>
<property name="title" translatable="yes">URL of Remote Instance</property>
<property name="show-apply-button">true</property>
</object>
</child>
<child>
<object class="AdwEntryRow" id="remote_bearer_token_entry">
<signal name="apply" handler="change_remote_bearer_token"/>
<property name="title" translatable="yes">Bearer Token (Optional)</property>
<property name="show-apply-button">true</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwSwitchRow" id="background_switch">
<signal name="notify::active" handler="switch_run_on_background"/>
<property name="title" translatable="yes">Run Alpaca In Background</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="powersaver_warning_switch">
<signal name="notify::active" handler="switch_powersaver_warning"/>
<property name="title" translatable="yes">Show Power Saver Warning</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<object class="AdwPreferencesGroup" id="tweaks_group">
<child>
<object class="AdwSpinRow" id="temperature_spin">
<object class="AdwSpinRow">
<signal name="changed" handler="model_spin_changed"/>
<property name="name">temperature</property>
<property name="title" translatable="yes">Temperature</property>
@@ -387,7 +344,7 @@
</object>
</child>
<child>
<object class="AdwSpinRow" id="seed_spin">
<object class="AdwSpinRow">
<signal name="changed" handler="model_spin_changed"/>
<property name="name">seed</property>
<property name="title" translatable="yes">Seed</property>
@@ -402,7 +359,7 @@
</object>
</child>
<child>
<object class="AdwSpinRow" id="keep_alive_spin">
<object class="AdwSpinRow">
<signal name="changed" handler="model_spin_changed"/>
<property name="name">keep_alive</property>
<property name="title" translatable="yes">Keep Alive Time</property>
@@ -425,11 +382,11 @@
<property name="title" translatable="yes">Ollama Instance</property>
<property name="icon-name">brain-augemnted-symbolic</property>
<child>
<object class="AdwPreferencesGroup">
<object class="AdwPreferencesGroup" id="overrides_group">
<property name="title" translatable="yes">Ollama Overrides</property>
<property name="description" translatable="yes">Manage the arguments used on Ollama, any changes on this page only applies to the integrated instance, the instance will restart if you make changes.</property>
<child>
<object class="AdwEntryRow" id="override_HSA_OVERRIDE_GFX_VERSION">
<object class="AdwEntryRow">
<signal name="apply" handler="override_changed"/>
<property name="name">HSA_OVERRIDE_GFX_VERSION</property>
<property name="title" translatable="no">HSA_OVERRIDE_GFX_VERSION</property>
@@ -450,7 +407,7 @@
</object>
</child>
<child>
<object class="AdwEntryRow" id="override_CUDA_VISIBLE_DEVICES">
<object class="AdwEntryRow">
<signal name="apply" handler="override_changed"/>
<property name="name">CUDA_VISIBLE_DEVICES</property>
<property name="title" translatable="no">CUDA_VISIBLE_DEVICES</property>
@@ -471,7 +428,7 @@
</object>
</child>
<child>
<object class="AdwEntryRow" id="override_HIP_VISIBLE_DEVICES">
<object class="AdwEntryRow">
<signal name="apply" handler="override_changed"/>
<property name="name">HIP_VISIBLE_DEVICES</property>
<property name="title" translatable="no">HIP_VISIBLE_DEVICES</property>
@@ -493,6 +450,64 @@
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwSpinRow" id="instance_idle_timer">
<signal name="changed" handler="instance_idle_timer_changed"/>
<property name="name">timer</property>
<property name="title" translatable="yes">Idle Timer</property>
<property name="subtitle" translatable="yes">Number of minutes the instance should remain idle before it is shut down (0 means it won't be shut down)</property>
<property name="digits">0</property>
<property name="adjustment">
<object class="GtkAdjustment">
<property name="lower">0</property>
<property name="upper">60</property>
<property name="step-increment">5</property>
</object>
</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="GtkLabel" id="ollama_information_label">
<property name="wrap">true</property>
<property name="use-markup">true</property>
<property name="label" translatable="yes">Integrated Ollama instance is not running</property>
<property name="justify">2</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<object class="AdwDialog" id="terminal_dialog">
<accessibility>
<property name="label" translatable="yes">Manage models dialog</property>
</accessibility>
<property name="title" translatable="yes">Terminal</property>
<property name="can-close">true</property>
<property name="width-request">600</property>
<property name="height-request">600</property>
<child>
<object class="AdwToolbarView">
<style>
<class name="osd"/>
</style>
<child type="top">
<object class="AdwHeaderBar"/>
</child>
<property name="content">
<object class="GtkScrolledWindow" id="terminal_scroller"/>
</property>
</object>
</child>
</object>
@@ -552,51 +567,39 @@
</object>
</child>
<property name="content">
<object class="GtkScrolledWindow">
<object class="GtkBox">
<property name="hexpand">true</property>
<property name="vexpand">true</property>
<child>
<object class="GtkBox">
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="orientation">1</property>
<property name="spacing">12</property>
<child>
<object class="GtkListBox" id="pulling_model_list_box">
<property name="visible">false</property>
<property name="selection-mode">none</property>
<object class="GtkScrolledWindow" id="model_scroller">
<property name="hscrollbar-policy">2</property>
<property name="hexpand">true</property>
<property name="vexpand">true</property>
</object>
</child>
<child>
<object class="AdwStatusPage" id="no_results_page">
<property name="visible">false</property>
<property name="vexpand">true</property>
<property name="hexpand">true</property>
<property name="icon-name">edit-find-symbolic</property>
<property name="title" translatable="yes">No Models Found</property>
<property name="description" translatable="yes">Try a different search or pull an unlisted model from it's name</property>
<property name="child">
<object class="GtkButton">
<property name="tooltip-text">Pull Model From Name</property>
<property name="action-name">app.create_model_from_name</property>
<property name="halign">center</property>
<property name="child">
<object class="GtkLabel">
<property name="label" translatable="yes">Pull Model From Name</property>
</object>
</property>
<style>
<class name="boxed-list"/>
<class name="suggested-action"/>
</style>
</object>
</child>
<child>
<object class="GtkListBox" id="local_model_list_box">
<property name="selection-mode">none</property>
<style>
<class name="boxed-list"/>
</style>
</object>
</child>
<child>
<object class="GtkListBox" id="available_model_list_box">
<property name="selection-mode">none</property>
<style>
<class name="boxed-list"/>
</style>
</object>
</child>
<child>
<object class="AdwStatusPage" id="no_results_page">
<property name="visible">false</property>
<property name="vexpand">true</property>
<property name="icon-name">edit-find-symbolic</property>
<property name="title" translatable="yes">No Models Found</property>
<property name="description" translatable="yes">Try a different search</property>
</object>
</child>
</property>
</object>
</child>
</object>
@@ -640,6 +643,9 @@
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="label" translatable="yes">By downloading this model you accept the license agreement available on the model's website.</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
@@ -661,20 +667,48 @@
</child>
<child>
<object class="AdwNavigationPage">
<property name="title" translatable="yes">Create Model</property>
<property name="tag">model_create_page</property>
<property name="title" translatable="yes">Model Details</property>
<property name="tag">model_information</property>
<property name="child">
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar">
<child type="start">
<object class="GtkButton">
<signal name="clicked" handler="link_button_handler"/>
<property name="icon-name">globe-symbolic</property>
<object class="GtkButton" id="model_detail_create_button">
<signal name="clicked" handler="model_detail_create_button_clicked"/>
<property name="icon-name">edit-copy-symbolic</property>
</object>
</child>
</object>
</child>
<property name="content">
<object class="GtkScrolledWindow">
<property name="vexpand">true</property>
<property name="hexpand">true</property>
<child>
<object class="AdwStatusPage" id="model_detail_page">
<property name="icon-name">brain-augemnted-symbolic</property>
<property name="description">text</property>
<style>
<class name="compact"/>
</style>
</object>
</child>
</object>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="AdwNavigationPage">
<property name="title" translatable="yes">Create Model</property>
<property name="tag">model_create_page</property>
<property name="child">
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar"/>
</child>
<property name="content">
<object class="GtkScrolledWindow">
<property name="vexpand">true</property>
@@ -748,6 +782,9 @@
<object class="GtkScrolledWindow">
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<style>
<class name="undershoot-bottom"/>
</style>
<child>
<object class="GtkTextView" id="create_model_modelfile">
<style>
@@ -847,14 +884,13 @@
<child>
<object class="GtkBox">
<child>
<object class="GtkTextView" id="file_preview_text_view">
<object class="GtkLabel" id="file_preview_text_label">
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="hexpand">true</property>
<property name="vexpand">true</property>
<property name="editable">false</property>
<property name="selectable">true</property>
</object>
</child>
<child>
@@ -992,6 +1028,10 @@
<attribute name="label" translatable="yes">Rename Chat</attribute>
<attribute name="action">app.rename_current_chat</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Duplicate Chat</attribute>
<attribute name="action">app.duplicate_current_chat</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Export Chat</attribute>
<attribute name="action">app.export_current_chat</attribute>
@@ -1014,6 +1054,10 @@
<attribute name="label" translatable="yes">Rename Chat</attribute>
<attribute name="action">app.rename_chat</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Duplicate Chat</attribute>
<attribute name="action">app.duplicate_chat</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Export Chat</attribute>
<attribute name="action">app.export_chat</attribute>
@@ -1082,10 +1126,16 @@
<property name="title" translatable="yes">General</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;ctrl&gt;W</property>
<property name="accelerator">&lt;ctrl&gt;Q</property>
<property name="title" translatable="yes">Close application</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;ctrl&gt;W</property>
<property name="title" translatable="yes">Delete current chat</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;ctrl&gt;I</property>
@@ -1128,6 +1178,12 @@
<property name="title" translatable="yes">Toggle sidebar</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">F2</property>
<property name="title" translatable="yes">Rename chat</property>
</object>
</child>
</object>
</child>
<child>
@@ -1164,3 +1220,5 @@
</object>
</interface>
-15
View File
@@ -1,15 +0,0 @@
"""
Moves the descriptions of models to src/available_models_descriptions.py
so they can be translated
"""
import json
if __name__ == "__main__":
with open('src/available_models.json', 'r', encoding="utf-8") as f:
data = json.load(f)
RESULTS = 'descriptions = {\n'
for key, value in data.items():
RESULTS += f" '{key}': _(\"{value['description']}\"),\n"
RESULTS += '}'
with open('src/available_models_descriptions.py', 'w+', encoding="utf-8") as f:
f.write(RESULTS)
+11 -1
View File
@@ -15,6 +15,16 @@ msgmerge --no-fuzzy-matching -U po/nb_NO.po po/alpaca.pot
echo "Updating Bengali"
msgmerge --no-fuzzy-matching -U po/bn.po po/alpaca.pot
echo "Updating Simplified Chinese"
msgmerge --no-fuzzy-matching -U po/zh_CN.po po/alpaca.pot
msgmerge --no-fuzzy-matching -U po/zh_Hans.po po/alpaca.pot
echo "Updating Hindi"
msgmerge --no-fuzzy-matching -U po/hi.po po/alpaca.pot
echo "Updating Turkish"
msgmerge --no-fuzzy-matching -U po/tr.po po/alpaca.pot
echo "Updating Ukrainian"
msgmerge --no-fuzzy-matching -U po/uk.po po/alpaca.pot
echo "Updating German"
msgmerge --no-fuzzy-matching -U po/de.po po/alpaca.pot
echo "Updating Hebrew"
msgmerge --no-fuzzy-matching -U po/he.po po/alpaca.pot
echo "Updating Telugu"
msgmerge --no-fuzzy-matching -U po/te.po po/alpaca.pot