Skip to content

Commit 556c839

Browse files
added a shell.nix for pgformatter, and a wip trigger for db size maintenance
1 parent d1af44b commit 556c839

7 files changed

+54
-8
lines changed

README.md

+13-8
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ ircProxy = "socks5://127.0.0.1:9050"
295295
llmProxy = "http://127.0.0.1:8180"
296296
skipTLSVerify = false
297297
useTLS = true
298-
plugins = ["./plugins/rss.lua"]
298+
plugins = ["/plugins/plugin1.lua", "/plugins/plugin2.lua"]
299+
adminOnly = false
299300

300301
[ircd.liberanet]
301302
ircServer = "irc.libera.chat"
@@ -323,14 +324,17 @@ debug = true
323324
out = true
324325
ircProxy = "socks5://127.0.0.1:9051"
325326
llmProxy = "http://127.0.0.1:8181"
326-
[ircd.liberanet.customCommands.digest]
327-
sql = "select log from liberanet_milla_us_market_news;"
328-
limit = 10
329-
prompt = "give me digest of the provided news"
330-
[ircd.liberanet.customCommands.summarize]
331-
sql= "select log from liberanet_milla_us_market_news;"
327+
adminOnly = true
328+
[ircd.devinet_terra.customCommands.digest]
329+
sql = "select log from liberanet_milla_us_market_news order by log desc;"
330+
limit = 300
331+
context = ["you are a sentiment-analysis bot"]
332+
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."
333+
[ircd.devinet_terra.customCommands.summarize]
334+
sql= "select log from liberanet_milla_us_market_news order by log desc;"
332335
limit= 300
333-
prompt= "given all the data, summarize the news for me"
336+
context = ["you are a sentiment-analysis bot"]
337+
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."
334338
```
335339

336340
## Commands
@@ -693,6 +697,7 @@ The following libraries are loaded by milla by default:
693697
- [gluahttp](https://github.com/cjoudrey/gluahttp)
694698
- [gluayaml](https://github.com/kohkimakimoto/gluayaml)
695699
- [gluasocket](https://gitlab.com/megalithic-llc/gluasocket)
700+
- [gluare](https://github.com/yuin/gluare)
696701

697702
## FAQ
698703

config-example.toml

+13
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ ircProxy = "socks5://127.0.0.1:9050"
2727
llmProxy = "http://127.0.0.1:8180"
2828
skipTLSVerify = false
2929
useTLS = true
30+
plugins = ["/plugins/plugin1.lua", "/plugins/plugin2.lua"]
31+
adminOnly = false
3032

3133
[ircd.liberanet]
3234
ircServer = "irc.libera.chat"
@@ -54,3 +56,14 @@ debug = true
5456
out = true
5557
ircProxy = "socks5://127.0.0.1:9051"
5658
llmProxy = "http://127.0.0.1:8181"
59+
adminOnly = true
60+
[ircd.devinet_terra.customCommands.digest]
61+
sql = "select log from liberanet_milla_us_market_news order by log desc;"
62+
limit = 300
63+
context = ["you are a sentiment-analysis bot"]
64+
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."
65+
[ircd.devinet_terra.customCommands.summarize]
66+
sql= "select log from liberanet_milla_us_market_news order by log desc;"
67+
limit= 300
68+
context = ["you are a sentiment-analysis bot"]
69+
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."

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ require (
1212
github.com/kohkimakimoto/gluayaml v0.0.0-20160815032708-6fe413d49d73
1313
github.com/lrstanley/girc v0.0.0-20240125042120-9add3166e52e
1414
github.com/sashabaranov/go-openai v1.19.3
15+
github.com/yuin/gluare v0.0.0-20170607022532-d7c94f1a80ed
1516
github.com/yuin/gopher-lua v1.1.1
1617
gitlab.com/megalithic-llc/gluasocket v0.3.1
1718
golang.org/x/net v0.24.0

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
113113
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
114114
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
115115
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
116+
github.com/yuin/gluare v0.0.0-20170607022532-d7c94f1a80ed h1:I1vcLHWU9m30rA90rMrKPu0eD3NDA4FBlkB8WMaDyUw=
117+
github.com/yuin/gluare v0.0.0-20170607022532-d7c94f1a80ed/go.mod h1:9w6KSdZh23UWqOywWsRLUcJUrUNjRh4Ql3z9uVgnSP4=
116118
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
117119
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
118120
gitlab.com/megalithic-llc/gluasocket v0.3.1 h1:CtsSTZa3G5WnMbhZ3TgvpLwpVlQv6KjO2mqxNOGrhY4=

plugins.go

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/kohkimakimoto/gluayaml"
1414
"github.com/lrstanley/girc"
1515
openai "github.com/sashabaranov/go-openai"
16+
"github.com/yuin/gluare"
1617
lua "github.com/yuin/gopher-lua"
1718
"gitlab.com/megalithic-llc/gluasocket"
1819
)
@@ -332,6 +333,7 @@ func RunScript(scriptPath string, client *girc.Client, appConfig *TomlConfig) {
332333
gluaxmlpath.Preload(luaState)
333334
luaState.PreloadModule("http", gluahttp.NewHttpModule(&http.Client{}).Loader)
334335
luaState.PreloadModule("yaml", gluayaml.Loader)
336+
luaState.PreloadModule("re", gluare.Loader)
335337

336338
log.Print("Running script: ", scriptPath)
337339

scripts/entry_limit_trigger.pgsql

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CREATE OR REPLACE FUNCTION milla.janitor ()
2+
RETURNS TRIGGER
3+
AS $$
4+
BEGIN
5+
UPDATE
6+
posts
7+
SET
8+
updated_at = now()
9+
WHERE
10+
id = NEW.id;
11+
RETURN new;
12+
END;
13+
$$
14+
LANGUAGE plpgsql;
15+
16+
CREATE TRIGGER janitor_trigger
17+
AFTER INSERT ON milla.tables
18+
EXECUTE PROCEDURE milla.janitor ();
19+

shell.nix

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{ pkgs ? import <nixpkgs> {} }:
2+
pkgs.mkShell {
3+
nativeBuildInputs = with pkgs.buildPackages; [ pgformatter ];
4+
}

0 commit comments

Comments
 (0)