git: 7d0b9dcc61f2 - main - misc/koboldcpp: New port: Simple way to run GGML and GGUF AI models with a KoboldAI WebUI

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Mon, 12 Aug 2024 06:21:29 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=7d0b9dcc61f252eefbf75b7079ae31e54f4f35ed

commit 7d0b9dcc61f252eefbf75b7079ae31e54f4f35ed
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2024-08-12 06:03:02 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2024-08-12 06:21:25 +0000

    misc/koboldcpp: New port: Simple way to run GGML and GGUF AI models with a KoboldAI WebUI
---
 misc/Makefile            |  1 +
 misc/koboldcpp/Makefile  | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 misc/koboldcpp/distinfo  |  3 +++
 misc/koboldcpp/pkg-descr |  8 ++++++++
 misc/koboldcpp/pkg-plist | 15 +++++++++++++++
 5 files changed, 74 insertions(+)

diff --git a/misc/Makefile b/misc/Makefile
index 7fb74f1ef16b..1ddda70e5b02 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -216,6 +216,7 @@
     SUBDIR += kf6-purpose
     SUBDIR += kgeography
     SUBDIR += klettres
+    SUBDIR += koboldcpp
     SUBDIR += kookbook
     SUBDIR += ktouch
     SUBDIR += kwordquiz
diff --git a/misc/koboldcpp/Makefile b/misc/koboldcpp/Makefile
new file mode 100644
index 000000000000..d3472c36e95b
--- /dev/null
+++ b/misc/koboldcpp/Makefile
@@ -0,0 +1,47 @@
+PORTNAME=	koboldcpp
+DISTVERSIONPREFIX=	v
+DISTVERSION=	1.72
+CATEGORIES=	misc # machine-learning
+
+MAINTAINER=	yuri@FreeBSD.org
+COMMENT=	Simple way to run GGML and GGUF AI models with a KoboldAI WebUI
+WWW=		https://github.com/lostruins/koboldcpp
+
+LICENSE=	AGPLv3
+LICENSE_FILE=	${WRKSRC}/LICENSE.md
+
+LIB_DEPENDS=	libopenblas.so:math/openblas \
+		libvulkan.so:graphics/vulkan-loader
+
+RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}customtkinter>0:x11-toolkits/py-customtkinter@${PY_FLAVOR}
+
+USES=		gmake localbase:ldflags python shebangfix
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	LostRuins
+
+SHEBANG_FILES=	koboldcpp.py
+
+MAKE_ARGS=	LLAMA_OPENBLAS=1 LLAMA_VULKAN=1 LLAMA_PORTABLE=1 LDFLAGS="${LDFLAGS}"
+
+ALL_TARGET=
+
+do-install:
+	# dir
+	${MKDIR} ${STAGEDIR}${DATADIR}
+	# prog
+	${INSTALL_DATA} ${WRKSRC}/koboldcpp.py ${STAGEDIR}${DATADIR}/koboldcpp.py
+	${CHMOD} +x ${STAGEDIR}${DATADIR}/koboldcpp.py
+	${RLN} ${STAGEDIR}${DATADIR}/koboldcpp.py ${STAGEDIR}${PREFIX}/bin/koboldcpp
+	# libraries
+.for lib in koboldcpp_default.so koboldcpp_failsafe.so koboldcpp_noavx2.so \
+	    koboldcpp_openblas.so koboldcpp_vulkan.so koboldcpp_vulkan_noavx2.so
+	${INSTALL_LIB} ${WRKSRC}/${lib} ${STAGEDIR}${DATADIR}
+.endfor
+	# embd files
+.for embd in klite.embd kcpp_docs.embd rwkv_vocab.embd rwkv_world_vocab.embd \
+	     kcpp_sdui.embd taesd.embd taesd_xl.embd
+	${INSTALL_DATA} ${WRKSRC}/${embd} ${STAGEDIR}${DATADIR}
+.endfor
+
+.include <bsd.port.mk>
diff --git a/misc/koboldcpp/distinfo b/misc/koboldcpp/distinfo
new file mode 100644
index 000000000000..ddceb1356f08
--- /dev/null
+++ b/misc/koboldcpp/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1723347219
+SHA256 (LostRuins-koboldcpp-v1.72_GH0.tar.gz) = 1159980d2cda0a9dfde9024454034b7b163e483395b78f6a8d41b58883476bd5
+SIZE (LostRuins-koboldcpp-v1.72_GH0.tar.gz) = 28440368
diff --git a/misc/koboldcpp/pkg-descr b/misc/koboldcpp/pkg-descr
new file mode 100644
index 000000000000..cfcd1f317314
--- /dev/null
+++ b/misc/koboldcpp/pkg-descr
@@ -0,0 +1,8 @@
+KoboldCpp is an easy-to-use AI text-generation software for GGML and GGUF
+models, inspired by the original KoboldAI. It's a single self-contained
+distributable from Concedo, that builds off llama.cpp, and adds a versatile
+KoboldAI API endpoint, additional format support, Stable Diffusion image
+generation, speech-to-text, backward compatibility, as well as a fancy UI with
+persistent stories, editing tools, save formats, memory, world info, author's
+note, characters, scenarios and everything KoboldAI and KoboldAI Lite have to
+offer.
diff --git a/misc/koboldcpp/pkg-plist b/misc/koboldcpp/pkg-plist
new file mode 100644
index 000000000000..8efacd4bc51e
--- /dev/null
+++ b/misc/koboldcpp/pkg-plist
@@ -0,0 +1,15 @@
+bin/koboldcpp
+%%DATADIR%%/kcpp_docs.embd
+%%DATADIR%%/kcpp_sdui.embd
+%%DATADIR%%/klite.embd
+%%DATADIR%%/koboldcpp.py
+%%DATADIR%%/koboldcpp_default.so
+%%DATADIR%%/koboldcpp_failsafe.so
+%%DATADIR%%/koboldcpp_noavx2.so
+%%DATADIR%%/koboldcpp_openblas.so
+%%DATADIR%%/koboldcpp_vulkan.so
+%%DATADIR%%/koboldcpp_vulkan_noavx2.so
+%%DATADIR%%/rwkv_vocab.embd
+%%DATADIR%%/rwkv_world_vocab.embd
+%%DATADIR%%/taesd.embd
+%%DATADIR%%/taesd_xl.embd