From 556c839dc1b5881c1594dbdfede0bd610790967d Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Tue, 11 Jun 2024 10:13:13 -0400 Subject: added a shell.nix for pgformatter, and a wip trigger for db size maintenance --- README.md | 21 +++++++++++++-------- config-example.toml | 13 +++++++++++++ go.mod | 1 + go.sum | 2 ++ plugins.go | 2 ++ scripts/entry_limit_trigger.pgsql | 19 +++++++++++++++++++ shell.nix | 4 ++++ 7 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 scripts/entry_limit_trigger.pgsql create mode 100644 shell.nix diff --git a/README.md b/README.md index a450612..23617b6 100644 --- a/README.md +++ b/README.md @@ -295,7 +295,8 @@ ircProxy = "socks5://127.0.0.1:9050" llmProxy = "http://127.0.0.1:8180" skipTLSVerify = false useTLS = true -plugins = ["./plugins/rss.lua"] +plugins = ["/plugins/plugin1.lua", "/plugins/plugin2.lua"] +adminOnly = false [ircd.liberanet] ircServer = "irc.libera.chat" @@ -323,14 +324,17 @@ debug = true out = true ircProxy = "socks5://127.0.0.1:9051" llmProxy = "http://127.0.0.1:8181" -[ircd.liberanet.customCommands.digest] -sql = "select log from liberanet_milla_us_market_news;" -limit = 10 -prompt = "give me digest of the provided news" -[ircd.liberanet.customCommands.summarize] -sql= "select log from liberanet_milla_us_market_news;" +adminOnly = true +[ircd.devinet_terra.customCommands.digest] +sql = "select log from liberanet_milla_us_market_news order by log desc;" +limit = 300 +context = ["you are a sentiment-analysis bot"] +prompt= "i have provided to you news headlines in the form of previous conversations between you and me using the user role. please provide the digest of the news for me." +[ircd.devinet_terra.customCommands.summarize] +sql= "select log from liberanet_milla_us_market_news order by log desc;" limit= 300 -prompt= "given all the data, summarize the news for me" +context = ["you are a sentiment-analysis bot"] +prompt= "i have provided to you news headlines in the form of previous conversations between you and me using the user role. please summarize the provided news for me. provide some details." ``` ## Commands @@ -693,6 +697,7 @@ The following libraries are loaded by milla by default: - [gluahttp](https://github.com/cjoudrey/gluahttp) - [gluayaml](https://github.com/kohkimakimoto/gluayaml) - [gluasocket](https://gitlab.com/megalithic-llc/gluasocket) +- [gluare](https://github.com/yuin/gluare) ## FAQ diff --git a/config-example.toml b/config-example.toml index 60f32a4..2b12ecb 100644 --- a/config-example.toml +++ b/config-example.toml @@ -27,6 +27,8 @@ ircProxy = "socks5://127.0.0.1:9050" llmProxy = "http://127.0.0.1:8180" skipTLSVerify = false useTLS = true +plugins = ["/plugins/plugin1.lua", "/plugins/plugin2.lua"] +adminOnly = false [ircd.liberanet] ircServer = "irc.libera.chat" @@ -54,3 +56,14 @@ debug = true out = true ircProxy = "socks5://127.0.0.1:9051" llmProxy = "http://127.0.0.1:8181" +adminOnly = true +[ircd.devinet_terra.customCommands.digest] +sql = "select log from liberanet_milla_us_market_news order by log desc;" +limit = 300 +context = ["you are a sentiment-analysis bot"] +prompt= "i have provided to you news headlines in the form of previous conversations between you and me using the user role. please provide the digest of the news for me." +[ircd.devinet_terra.customCommands.summarize] +sql= "select log from liberanet_milla_us_market_news order by log desc;" +limit= 300 +context = ["you are a sentiment-analysis bot"] +prompt= "i have provided to you news headlines in the form of previous conversations between you and me using the user role. please summarize the provided news for me. provide some details." diff --git a/go.mod b/go.mod index f9076b8..7b5085c 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/kohkimakimoto/gluayaml v0.0.0-20160815032708-6fe413d49d73 github.com/lrstanley/girc v0.0.0-20240125042120-9add3166e52e github.com/sashabaranov/go-openai v1.19.3 + github.com/yuin/gluare v0.0.0-20170607022532-d7c94f1a80ed github.com/yuin/gopher-lua v1.1.1 gitlab.com/megalithic-llc/gluasocket v0.3.1 golang.org/x/net v0.24.0 diff --git a/go.sum b/go.sum index 7fea354..349130c 100644 --- a/go.sum +++ b/go.sum @@ -113,6 +113,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/yuin/gluare v0.0.0-20170607022532-d7c94f1a80ed h1:I1vcLHWU9m30rA90rMrKPu0eD3NDA4FBlkB8WMaDyUw= +github.com/yuin/gluare v0.0.0-20170607022532-d7c94f1a80ed/go.mod h1:9w6KSdZh23UWqOywWsRLUcJUrUNjRh4Ql3z9uVgnSP4= github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M= github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= gitlab.com/megalithic-llc/gluasocket v0.3.1 h1:CtsSTZa3G5WnMbhZ3TgvpLwpVlQv6KjO2mqxNOGrhY4= diff --git a/plugins.go b/plugins.go index b25d1c4..08f81a9 100644 --- a/plugins.go +++ b/plugins.go @@ -13,6 +13,7 @@ import ( "github.com/kohkimakimoto/gluayaml" "github.com/lrstanley/girc" openai "github.com/sashabaranov/go-openai" + "github.com/yuin/gluare" lua "github.com/yuin/gopher-lua" "gitlab.com/megalithic-llc/gluasocket" ) @@ -332,6 +333,7 @@ func RunScript(scriptPath string, client *girc.Client, appConfig *TomlConfig) { gluaxmlpath.Preload(luaState) luaState.PreloadModule("http", gluahttp.NewHttpModule(&http.Client{}).Loader) luaState.PreloadModule("yaml", gluayaml.Loader) + luaState.PreloadModule("re", gluare.Loader) log.Print("Running script: ", scriptPath) diff --git a/scripts/entry_limit_trigger.pgsql b/scripts/entry_limit_trigger.pgsql new file mode 100644 index 0000000..d7d99c2 --- /dev/null +++ b/scripts/entry_limit_trigger.pgsql @@ -0,0 +1,19 @@ +CREATE OR REPLACE FUNCTION milla.janitor () + RETURNS TRIGGER + AS $$ +BEGIN + UPDATE + posts + SET + updated_at = now() + WHERE + id = NEW.id; + RETURN new; +END; +$$ +LANGUAGE plpgsql; + +CREATE TRIGGER janitor_trigger + AFTER INSERT ON milla.tables + EXECUTE PROCEDURE milla.janitor (); + diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..442fa42 --- /dev/null +++ b/shell.nix @@ -0,0 +1,4 @@ +{ pkgs ? import {} }: + pkgs.mkShell { + nativeBuildInputs = with pkgs.buildPackages; [ pgformatter ]; +} -- cgit v1.2.3