{"id":16328083,"url":"https://github.com/terminaldweller/milla","last_synced_at":"2025-10-23T02:46:29.566Z","repository":{"id":219485039,"uuid":"749105941","full_name":"terminaldweller/milla","owner":"terminaldweller","description":"terminaldweller's IRC bot","archived":false,"fork":false,"pushed_at":"2025-04-14T18:17:35.000Z","size":1185,"stargazers_count":8,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-20T10:10:09.027Z","etag":null,"topics":["bot","chatbot","chatgpt","gemini-pro","irc","irc-bot","lua","ollama","openrouter","rss","sasl","syntax-highlighting"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/terminaldweller.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-27T15:46:05.000Z","updated_at":"2025-04-14T18:17:38.000Z","dependencies_parsed_at":"2024-02-20T08:24:47.745Z","dependency_job_id":"7e4496bf-1563-4ee5-90ca-4638959ea675","html_url":"https://github.com/terminaldweller/milla","commit_stats":null,"previous_names":["terminaldweller/milla"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terminaldweller%2Fmilla","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terminaldweller%2Fmilla/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terminaldweller%2Fmilla/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terminaldweller%2Fmilla/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/terminaldweller","download_url":"https://codeload.github.com/terminaldweller/milla/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250487526,"owners_count":21438612,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","chatbot","chatgpt","gemini-pro","irc","irc-bot","lua","ollama","openrouter","rss","sasl","syntax-highlighting"],"created_at":"2024-10-10T23:13:41.679Z","updated_at":"2025-10-23T02:46:29.559Z","avatar_url":"https://github.com/terminaldweller.png","language":"Go","funding_links":[],"categories":["Bots"],"sub_categories":["Self-hosted"],"readme":"# milla\n\nMilla is an IRC bot that:\n\n- sends things over to an LLM when you ask it questions and prints the answer with optional syntax-highlighting.Currently supported providers: Ollama, Openai, Gemini, Openrouter \u003cbr/\u003e\n- Milla can run more than one instance of itself\n- Each instance can connect to a different ircd, and will get the full set of configs, e.g. different proxies, different postgres instance, ...\n- You can define custom commands in the form of SQL queries to the database with the SQL query result being passed to the bot along with the given prompt and an optional limit so you don't go bankrupt(unless you are running ollama locally like the smart cookie that you are).\u003cbr/\u003e\n- lua plugin system to extend the bot's functionality.\u003cbr/\u003e\n\n![milla](./milla.png)\n\nmilla accepts one cli arg which tells it where to look for the config file:\u003cbr/\u003e\n\n```txt\n$ milla -help\nUsage of milla:\n  -config string\n          path to the config file (default \"./config.toml\")\n  -prof\n          enable prof server\n```\n\nThe bot will respond to chat prompts if they begin with `botnick:`.\u003cbr/\u003e\nThe bot will see a chat prompt as a command if the message begins with `botnick: /`.\u003cbr/\u003e\n\n## Config\n\nAn example is provided under `config-example.toml`. Please note that all the config options are specific to one instance which is defined by `ircd.nameofyourinstance`.\u003cbr/\u003e\n\n| Option                        | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |\n| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| ircServer                     | The address for the IRC server to connect to                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |\n| ircNick                       | The nick the bot should use                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |\n| enableSasl                    | Whether to use SASL for authentication                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| ircSaslUser                   | The SASL username                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| ircSaslPass                   | The SASL password for SASL plain authentication. Can also be passed as and environment variable                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |\n| Endpoint                      | The address for the Ollama chat endpoint                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |\n| model                         | The name of the model to use                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |\n| chromaStyle                   | The style to use for syntax highlighting done by [chroma](https://github.com/alecthomas/chroma). This is basically what's called a \"theme\"                                                                                                                                                                                                                                                                                                                                                                                                                                      |\n| chromaFormatter               | The formatter to use. This tells chroma how to generate the color in the output. The supported options are:\u003cbr\u003e\u003cbr\u003e- `noop` for no syntax highlighting\u003cbr\u003e- `terminal` for 8-color terminals\u003cbr\u003e- `terminal8` for 8-color terminals\u003cbr\u003e- `terminal16` for 16-color terminals\u003cbr\u003e- `terminal256` for 256-color terminals\u003cbr\u003e- `terminal16m` for truecolor terminals\u003cbr\u003e- `html` for HTML output\u003cbr\u003e\u003cbr\u003e**_NOTE_**: please note that the terminal formatters will increase the size of the IRC event. Depending on the IRC server, this may or may not be a problem.              |\n| provider                      | Which LLM provider to use. The supported options are:\u003cbr\u003e\u003cbr\u003e- [ollama](https://github.com/ollama/ollama)\u003cbr\u003e- chatgpt\u003cbr\u003e- gemini\u003cbr\u003e- [openrouter](https://openrouter.ai/)\u003cbr\u003e                                                                                                                                                                                                                                                                                                                                                                                                |\n| apikey                        | The apikey to use for the LLM provider. Can also be passed as and environment variable                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| clientCertPath                | The path to the client certificate to use for client cert authentication                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |\n| serverPass                    | The password to use for the IRC server the bot is trying to connect to if the server has a password. Can also be passed as and environment variable                                                                                                                                                                                                                                                                                                                                                                                                                             |\n| bind                          | Which address to bind to for the IRC server                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |\n| requestTimeout                | The timeout for requests made to the LLM provider                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| millaReconnectDelay           | How much to wait before reconnecting to the IRC server                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| ircPort                       | Which port to connect to for the IRC server                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |\n| keepAlive                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |\n| memoryLimit                   | How many conversations to keep in memory for a model                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |\n| pingDelay                     | Ping delay for the IRC server                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| pingTimeout                   | Ping timeout for the IRC server                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |\n| skipTLSVerify                 | Skip verifying the IRC server's TLS certificate. This only makes sense if you are trying to connect to an IRC server with a self-signed certificate                                                                                                                                                                                                                                                                                                                                                                                                                             |\n| useTLS                        | Whether to use TLS to connect to the IRC server. This option is provided to support usage on overlay networks such as Tor, i2p and [yggdrassil](https://github.com/yggdrasil-network/yggdrasil-go)                                                                                                                                                                                                                                                                                                                                                                              |\n| disableSTSFallback            | Disables the \"fallback\" to a non-TLS connection if the strict transport policy expires and the first attempt to reconnect back to the TLS version fails                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| allowFlood                    | Disable [girc](https://github.com/lrstanley/girc)'s built-in flood protection                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| debug                         | Whether to enable debug logging. The logs are written to stdout                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |\n| out                           | Whether to write raw messages to stdout                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| admins                        | List of admins for the bot. Only admins can use commands.\u003cbr\u003e\u003cbr\u003e`admins = [\"admin1\", \"admin2\"]`\u003cbr\u003e                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |\n| ircChannels                   | List of channels for the bot to join when it connects to the server.\u003cbr\u003e`ircChannels = [[\"#channel1\",\"channel1password\"], [\"#channel2\",\"\"], [\"#channel3\"]]`\u003cbr\u003eIn the provided example, milla will attempt to join `#channel1` with the provided password while for the other two channels, it will try to join normally.\u003cbr\u003e\u003cbr\u003e**_NOTE 1_**: This behaviour is consistant across all places where a channel name is the input.\u003cbr\u003e\u003cbr\u003e**_NOTE 2_**: Please note that the bot does not have to join a channel to be usable. One can simply query the bot directly as well.\u003cbr\u003e |\n| databaseUser                  | Name of the database user                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n| databasePassword              | Password for the database user                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |\n| databaseAddress               | Address of the database                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| databaseName                  | Name of the database                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |\n| scrapeChannels                | List of channels that the bot will scrape into a database table. You can later on use these databases for the custom commands.\u003cbr\u003e\u003cbr\u003e`ircChannels = [[\"#channel1\",\"channel1password\"], [\"#channel2\",\"\"], [\"#channel3\"]]`                                                                                                                                                                                                                                                                                                                                                       |\n| ircProxy                      | Determines which proxy to use to connect to the IRC network:\u003cbr\u003e`ircProxy = \"socks5://127.0.0.1:9050\"`                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| llmProxy                      | Determines which proxy to use to connect to the LLM endpoint:\u003cbr\u003e`llmProxy = \"socks5://127.0.0.1:9050\"`                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| generalProxy                  | Determines which proxy to use for other things:\u003cbr\u003e`llmProxy = \"socks5://127.0.0.1:9050\"`\u003cbr\u003e\u003cbr\u003e**_NOTE_**: Lua scripts do not use the `generalProxy` option. They will use whatever proxy that the invidividual script has them use. The RSS functionaly lets you use a proxy for every single entry.                                                                                                                                                                                                                                                                         |\n| ircdName                      | Name of the milla instance, must be unique across all instances                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |\n| adminOnly                     | Milla will only answer if the nick is in the admin list                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| webIRCGateway                 | webirc gateway to use                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| webIRCHostname                | webirc hostname to use                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| webIRCPassword                | webirc password to use                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| webIRCAddress                 | webirc address to use                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| context                       | Artificially provide a history of messages for the bot.\u003cbr\u003e\u003cbr\u003e`tomlcontext = [\"you are a pirate. use the language and words a pirate would unless you are asked to do otherwise explicitly\", \"your name is caption blackbeard\"]`\u003cbr\u003e`tomlcontext = [\"please respond in french even if i use another language unless you are specifically asked to use any language other than french\", \"your name is terra\"]`                                                                                                                                                                  |\n| rssFile                       | The file that contains the rss feeeds                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| channel                       | The channel to send the rss feeds to                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |\n| plugins                       | A list of plugins to load:`plugins = [\"./plugins/rss.lua\", \"./plugins/test.lua\"]`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| systemPrompt                  | The system prompt for the AI chat bot                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| temperature                   | [ollama docs](https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| topP                          | [ollama docs](https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| topK                          | [ollama docs](https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| ollamaMirostat                | [ollama docs](https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| ollamaMirostatEta             | [ollama docs](https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| ollamaMirostatTau             | [ollama docs](https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| ollamaNumCtx                  | [ollama docs](https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| ollamaRepeatLastN             | [ollama docs](https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| ollamaRepeatPenalty           | [ollama docs](https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| ollamaSeed                    | [ollama docs](https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| ollamaNumPredict              | [ollama docs](https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| ollamaMinp                    | [ollama docs](https://github.com/ollama/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| ollamaThink                   | Sets the ollama think parameter for a thinking model.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| ircBackOffInitialInterval     | Initial backoff value for reconnects to IRC. The value is in milliseconds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |\n| ircBackOffRandomizationFactor | The randomization factor for the exponential backoff.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| ircBackOffMultiplier          | The multiplier for subsequent backoffs.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| ircBackOffMaxInterval         | The maximum value for the backoff interval. The value is in seconds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |\n| dbBackOffInitialInterval      | Initial backoff value for reconnects to the DB. The value is in milliseconds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| dbBackOffRandomizationFactor  | The randomization factor for the exponential backoff.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| dbBackOffMultiplier           | The multiplier for subsequent backoffs.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| dbBackOffMaxInterval          | The maximum value for the backoff interval. The value is in seconds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |\n\n## Custom Commands\n\nCustom commands let you define a command that does a SQL query to the database and performs the given task. Here's an example:\n\n```toml\n[ircd.devinet_terra.customCommands.digest]\nsql = \"select log from liberanet_milla_us_market_news order by log desc;\"\nlimit = 300\ncontext = [\"\",\"\"]\nsystemPrompt = [\"you are a sentiment analysis bot.\"]\nprompt= \"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.\"\n[ircd.devinet_terra.customCommands.summarize]\nsql= \"select log from liberanet_milla_us_market_news order by log desc;\"\nlimit= 300\nsystemPrompt = [\"you are a sentiment-analysis bot\"]\nprompt= \"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.\"\n[ircd.devinet_terra.customCommands.canada]\nsql= \"select log from liberanet_milla_us_market_news order by log desc;\"\nlimit= 300\nprompt= \"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.\"\n```\n\nIn the above example digest and summarize will be the names of the commands: `milla: /cmd summarize`.\n\nCurrently you should only ask for the log column in the query. Asking for the other column will result in the query not succeeding.\n\nThe `limit` parameter limits the number of SQL queries that are used to generate the response. Whether you hit the token limit of the provider you use and the cost is something you should be aware of.\n\nA `limit` value of 0 disables the limit on the amount of rows that are passed to milla.\n\n**_NOTE_**: since each milla instance can have its own database, all instances might not necessarily have access to all the data milla is gathering. If you use the same database for all the instances, all instances will have access to all the gathered data.\n\n## Watchlist\n\nWatchlists allow you to specify a list of channels to watch. The watched values are given in a list of files, each line of the file specifying a value to watch for. Finally a value is given for the alertchannel where the bot will mirror the message that triggered a match.\u003cbr/\u003e\n\n```toml\n[ircd.devinet_terra.watchlist.security]\nwatchList = [[\"#securityfeeds\"]]\nwatchFiles = [\"/watchfiles/voidbox.list\"]\nalertChannel = [\"#milla_alerts\"]\neventTypes = [\"PRIVMSG\"]\nfgColor = 0\nbgColor = 28\n```\n\nFor the watchList option, please remember to put the channels also in your scrape `scrapeChannels`.\u003cbr/\u003e\n\n## RSS\n\nThe rss file is self-explanatory. Here's an example:\n\n```json\n{\n  \"feeds\": [\n    {\n      \"name\": \"one\",\n      \"url\": \"http://feeds.feedburner.com/crunchyroll/rss\",\n      \"proxy\": \"socks5://172.17.0.1:9007\",\n      \"userAgent\": \"Mozilla/5.0 (X11; U; Linux i686; pl; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1 (Ubuntu-edgy)\",\n      \"timeout\": 10\n    },\n    {\n      \"name\": \"two\",\n      \"url\": \"http://feeds.feedburner.com/crunchyroll/rss/anime\",\n      \"proxy\": \"socks5://172.17.0.1:9007\",\n      \"userAgent\": \"Mozilla/5.0 (X11; U; Linux i686; pl; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1 (Ubuntu-edgy)\",\n      \"timeout\": 10\n    }\n  ],\n  \"period\": 3600\n}\n```\n\n### Example Config File\n\n```toml\n[ircd.devinet]\nircServer = \"irc.myawesomeircnet.com\"\nircPort = 6697\nircNick = \"milla\"\nenableSasl = true\nircSaslUser = \"milla\"\nircSaslPass = \"xxxxx\"\nircChannels = [[\"##chan1\"], [\"##chan2\"]]\ntemp = 0.2\nrequestTimeout = 10\nmillaReconnectDelay = 60\nmodel = \"gpt-3.5-turbo\"\nchromaStyle = \"rose-pine-moon\"\nchromaFormatter = \"terminal256\"\nprovider = \"chatgpt\"\napikey = \"xxxx\"\nmemoryLimit = 20\nadmins = [\"noone_has_this_nick\"]\ndebug = true\nout = true\ndatabaseAddress = \"postgres:5432\"\ndatabasePassword = \"changeme\"\ndatabaseUser = \"devi\"\ndatabaseName = \"milla\"\nscrapeChannels = [[\"#soulhack\"], [\"#warroom\"], [\"#securityfeeds\"]]\nircProxy = \"socks5://127.0.0.1:9050\"\nllmProxy = \"http://127.0.0.1:8180\"\nskipTLSVerify = false\nuseTLS = true\nadminOnly = false\nplugins = [\"/plugins/ip.lua\", \"/plugins/urban.lua\"]\nsystemPrompt = [\"please respond in french even if i use another language unless you are specifically asked to use any language other than french\"]\n[ircd.devinet.watchlist.security]\nwatchList = [[\"#securityfeeds\"]]\nwatchFiles = [\"/watchfiles/voidbox.list\"]\nalertChannel = [\"#milla_alerts\"]\neventTypes = [\"PRIVMSG\"]\nfgColor = 0\nbgColor = 28\n[ircd.devinet.rss.manga]\nrssFile = \"/rssfeeds/manga.json\"\nchannel = [\"#manga\"]\n[ircd.devinet.rss.anime]\nrssFile = \"/rssfeeds/anime.json\"\nchannel = [\"#anime\"]\n\n[ircd.liberanet]\nircServer = \"irc.libera.chat\"\nircNick = \"milla\"\nmodel = \"gpt-3.5-turbo\"\nircPort = 6697\nchromaStyle = \"rose-pine-moon\"\nchromaFormatter = \"terminal16m\"\nprovider = \"gemini\"\napikey = \"xxxx\"\ntemp = 0.5\nrequestTimeout = 10\nmillaReconnectDelay = 60\nkeepAlive = 20\nmemoryLimit = 20\npingDelay = 20\npingTimeout = 600\nskipTLSVerify = false\nuseTLS = true\ndisableSTSFallback = true\nallowFlood = false\nadmins = [\"noone_has_this_nick\"]\nircChannels = [[\"##milla1\"], [\"##milla2\"]]\ndebug = true\nout = true\nircProxy = \"socks5://127.0.0.1:9051\"\nllmProxy = \"http://127.0.0.1:8181\"\nadminOnly = true\n[ircd.liberanet.customCommands.digest]\nsql = \"select log from liberanet_milla_us_market_news order by log desc;\"\nlimit = 300\nsystemPrompt = [\"you are a sentiment-analysis bot\"]\nprompt= \"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.\"\n[ircd.liberanet.customCommands.summarize]\nsql= \"select log from liberanet_milla_us_market_news order by log desc;\"\nlimit= 300\nsystemPrompt = [\"you are a sentiment-analysis bot\"]\nprompt= \"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.\"\n```\n\n## Commands\n\n| Command  | Description                                                                                                                                                                                                     |\n| -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| help     | Prints the help message                                                                                                                                                                                         |\n| get      | Get the value of a config option. Use the same name as the config file but capitalized: `/get chromaFormatter`                                                                                                  |\n| getall   | Get the value of all config options                                                                                                                                                                             |\n| set      | Set a config option on the fly. Use the same name as the config file but capitalized: `/set chromaFormatter noop`                                                                                               |\n| memstats | Returns memory stats for milla                                                                                                                                                                                  |\n| join     | Joins a channel: `/join #channel [optional_password]`                                                                                                                                                           |\n| leave    | Leaves a channel: `/leave #channel`                                                                                                                                                                             |\n| load     | Load a plugin: `/load /plugins/rss.lua`                                                                                                                                                                         |\n| unload   | Unload a plugin: `/unload /plugins/rss.lua`                                                                                                                                                                     |\n| remind   | Pings the user after the given amount in seconds: `/remind 1200`                                                                                                                                                |\n| roll     | Rolls a number between 1 and 6 if no arguments are given. With one argument it rolls a number between 1 and the given number. With two arguments it rolls a number between the two numbers: `/roll 10000 66666` |\n| whois    | IANA whois endpoint query: `milla: /whois xyz`. This command uses the `generalProxy` option.                                                                                                                    |\n| ua       | runs a user agent: `milla: /ua web_search_tool`                                                                                                                                                                 |\n\n## UserAgents\n\nFor user agents, we are using the [OpenAI agents SDK](https://github.com/openai/openai-agents-python) for user agents.\u003cbr/\u003e\n\nYou can add your custom agents under `./useragents/src/custom_agents`. Use the `agentRegistry` decorator to register your Agent. The decorated function is expected to return an `Agent`. The name of the function is the `agent_name` you have configured in `config.toml`. You can pass the `query` parameter when asking milla to run the command in which case it will override the default query parameter provided in `config.toml`.\nFor imports, make sure not to use relative imports, i.e. `from ..current_time import fetch_date` and use absolute imports `from src.current_time import fetch_date`.\u003cbr/\u003e\n\n```python\nfrom agents import Agent, WebSearchTool\nfrom src.current_time import fetch_date\nfrom src.models import AgentRequest\nfrom src.registry import agentRegistry\n\n\n@agentRegistry\ndef web_search_tool(agent_request: AgentRequest) -\u003e Agent:\n    tools = [WebSearchTool(), fetch_date]\n\n    agent = Agent(\n        name=agent_request.agent_name,\n        instructions=agent_request.instructions,\n        tools=tools,\n    )\n\n    return agent\n```\n\nAnd then you can use the agent like this:\n\n```text\nmilla: /ua web_search_tool\n```\n\nor:\n\n```text\nmilla: /ua web_search_tool do something else\n```\n\nBelow is an example on how to configure a user agent:\n\n```toml\n[ircd.myircnet.userAgentActions.cyberSecurityDigest]\nagent_name = \"web_search_tool\"\ninstructions = \"you are a cybersecurity news digest bot\"\nquery = \"give me a news digest of the news related to to cybersecurity for today. mention your sources for each one.\"\n```\n\n## Alias\n\nAliases are a simple string swap for commands(this includes all the commands):\n\n```toml\n[ircd.myircnet.aliases.cyberSecurityDigest]\nalias = \"/ua web_search_tool\"\n```\n\nand then you can use it like so:\n\n```txt\nmilla: /cyberSecurityDigest\n```\n\n## Deploy\n\n### Docker\n\nImages are automatically pushed to dockerhub. So you can get it from [there](https://hub.docker.com/r/terminaldweller/milla).\nAn example docker compose file is provided in the repo under `docker-compose.yaml`.\nmilla can be used with [gvisor](https://gvisor.dev/)'s docker runtime, `runsc`.\n\n```yaml\nservices:\n  terra:\n    image: milla_distroless_vendored\n    build:\n      context: .\n      dockerfile: ./Dockerfile_distroless_vendored\n    deploy:\n      resources:\n        limits:\n          memory: 128M\n    logging:\n      driver: \"json-file\"\n      options:\n        max-size: \"100m\"\n    networks:\n      - terranet\n      - dbnet\n    user: 1000:1000\n    restart: unless-stopped\n    entrypoint: [\"/usr/bin/milla\"]\n    command: [\"--config\", \"/config.toml\"]\n    volumes:\n      - ./config-gpt.toml:/config.toml\n      - /etc/localtime:/etc/localtime:ro\n    cap_drop:\n      - ALL\n  postgres:\n    image: postgres:16-alpine3.19\n    deploy:\n      resources:\n        limits:\n          memory: 4096M\n    logging:\n      driver: \"json-file\"\n      options:\n        max-size: \"200m\"\n    restart: unless-stopped\n    ports:\n      - \"127.0.0.1:5455:5432/tcp\"\n    volumes:\n      - terra_postgres_vault:/var/lib/postgresql/data\n      - ./scripts/:/docker-entrypoint-initdb.d/:ro\n    environment:\n      - POSTGRES_PASSWORD_FILE=/run/secrets/pg_pass_secret\n      - POSTGRES_USER_FILE=/run/secrets/pg_user_secret\n      - POSTGRES_INITDB_ARGS_FILE=/run/secrets/pg_initdb_args_secret\n      - POSTGRES_DB_FILE=/run/secrets/pg_db_secret\n    networks:\n      - dbnet\n    secrets:\n      - pg_pass_secret\n      - pg_user_secret\n      - pg_initdb_args_secret\n      - pg_db_secret\n    runtime: runsc\n  useragents:\n    image: useragents\n    deploy:\n      resources:\n        limits:\n          memory: 512M\n    logging:\n      driver: \"json-file\"\n      options:\n        max-size: \"200m\"\n    build:\n      context: ./useragents/\n    ports:\n      - 127.0.0.1:9909:443/tcp\n    networks:\n      - terranet\n    environment:\n      - OPENAI_API_KEY=XXXXX\n    cap_drop:\n      - ALL\n    entrypoint: [\"/useragent/main.py\"]\nnetworks:\n  terranet:\n  dbnet:\nvolumes:\n  terra_postgres_vault:\nsecrets:\n  pg_pass_secret:\n    file: ./pg/pg_pass_secret\n  pg_user_secret:\n    file: ./pg/pg_user_secret\n  pg_initdb_args_secret:\n    file: ./pg/pg_initdb_args_secret\n  pg_db_secret:\n    file: ./pg/pg_db_secret\n```\n\nThe env vars `UID` and `GID` need to be defined or they can replaces by your host user's uid and gid.\u003cbr/\u003e\n\nAs a convenience, there is a [distroless](https://github.com/GoogleContainerTools/distroless) dockerfile, `Dockerfile_distroless` also provided.\u003cbr/\u003e\nA vendored build of milla is available by first running `go mod vendor` and then using the provided dockerfile, `Dockerfile_distroless_vendored`.\u003cbr/\u003e\n\n### Build\n\nFor a regular build:\n\n```sh\ngo mod download\ngo build\n```\n\nFor a vendored build:\n\n```sh\ngo mod vendor\ngo build\n```\n\n### Plugins and Scripting\n\nmilla can be extended with plugins. The plugins are written in lua and are loaded at runtime. The plugins are loaded after an IRC connection has been made.\u003cbr/\u003e\nmilla uses [gopher-lua](https://github.com/yuin/gopher-lua) which implements a lua 5.1 VM in Go.\u003cbr/\u003e\nThis means that lua libraries that are implemented in C will not be available to gopher-lua, only pure lua libraries will be available..\u003cbr/\u003e\nThere are a few libraries written in go specifically for gopher-lua that are available to milla. Below there is a list of the current ones.\u003cbr/\u003e\n\nAn example plugin is provided under `plugins/rss.lua`.\u003cbr/\u003e\n\n```yaml\nperiod: 3600\nchannel: \"#rssfeed\"\nrssfeeds:\n  - name: \"one\"\n    url: \"https://www.youtube.com/feeds/videos.xml?channel_id=UCaiL2GDNpLYH6Wokkk1VNcg\"\n  - name: \"two\"\n    url: \"https://www.youtube.com/feeds/videos.xml?channel_id=UCd26IHBHcbtxD7pUdnIgiCw\"\n  - name: \"three\"\n    url: \"https://www.youtube.com/feeds/videos.xml?channel_id=UCS4FAVeYW_IaZqAbqhlvxlA\"\n```\n\n```lua\nlocal milla = require(\"milla\")\nlocal yaml = require(\"yaml\")\nlocal http = require(\"http\")\nlocal xmlpath = require(\"xmlpath\")\n\nlocal function read_file(file)\n    local f = assert(io.open(file, \"rb\"))\n    local content = f:read(\"*all\")\n    f:close()\n    return content\nend\n\nlocal function sleep(n) os.execute(\"sleep \" .. tonumber(n)) end\n\nlocal function get_config()\n    local yaml_config = read_file(\"./plugins/rss.yaml\")\n    local config = yaml.parse(yaml_config)\n    return config\nend\n\nlocal function get_rss_feed(config)\n    local titles = {}\n    local author_names = {}\n    local uris = {}\n    local rss_feed_list = {}\n\n    for _, v in pairs(config.rssfeeds) do\n        local response, err = http.request(\"GET\", v.url)\n        if err ~= nil then\n            milla.send_message(err, \"\")\n            goto continue\n        end\n        local node, err = xmlpath.loadxml(response.body)\n        if err ~= nil then\n            milla.send_message(err, \"\")\n            goto continue\n        end\n\n        local path, err = xmlpath.compile(\"//entry/title\")\n        if err ~= nil then\n            milla.send_message(err, \"\")\n            goto continue\n        end\n        local iterator = path:iter(node)\n        for _, match in ipairs(iterator) do\n            table.insert(titles, match:string())\n        end\n\n        path, err = xmlpath.compile(\"//entry/author/name\")\n        -- local path, err = xmlpath.compile(\"//entry/title\")\n        if err ~= nil then\n            milla.send_message(err, \"\")\n            goto continue\n        end\n        iterator = path:iter(node)\n        for _, match in ipairs(iterator) do\n            table.insert(author_names, match:string())\n        end\n\n        path, err = xmlpath.compile(\"//entry/author/uri\")\n        -- local path, err = xmlpath.compile(\"//entry/title\")\n        if err ~= nil then\n            milla.send_message(err, \"\")\n            goto continue\n        end\n        iterator = path:iter(node)\n        for _, match in ipairs(iterator) do\n            table.insert(uris, match:string())\n        end\n        ::continue::\n    end\n\n    for i = 1, #titles do\n        table.insert(rss_feed_list,\n                     author_names[i] .. \": \" .. titles[i] .. \" -- \" .. uris[i])\n    end\n\n    return rss_feed_list\nend\n\nlocal function rss_feed()\n    local config = get_config()\n    while true do\n        for _, v in pairs(get_rss_feed(config)) do\n            milla.send_message(v, config.channel)\n            sleep(config.period)\n        end\n    end\nend\n\nrss_feed()\n```\n\nThe example rss plugin, accepts a yaml file as input, reeds the provided rss feeds once, extracts the title, author name and link to the resource, sends the feed over to the `#rssfeed` irc channel and exits.\u003cbr/\u003e\nAlso please note that this is just an example script. If you want milla to handle some rss feeds for you, you can use the builtin rss functionality.\u003cbr/\u003e\n\n### Plugins\n\n| Name         | Explanation                                                                                                                                                               |\n| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| ip.lua       | A geo-ip lookup for both ipv4 and ipv6. The API request is sent to http://ip-api.com. You can set the `http_proxy` env var for this script.                               |\n| urban.lua    | Asks urban dictionary for the meaning. it only has one switch, `-n`, e.g. `-n 3` which will give you 3 definitions instead of the default 1 answer that will be returned. |\n| repology.lua | Lists the problems for a distro using the [repology api](https://repology.org/api).                                                                                       |\n| robtex.lua   | `ipquery`,`asquery`,`pdns`,`pdns_reverse`                                                                                                                                 |\n\n### Milla's Lua Module\n\nHere's a list of the available function in milla's lua module:\n\n```lua\nmilla.send_message(msg, target)\n```\n\n```lua\nmilla.join_channel(channel,password)\n```\n\nPlease note that even if the channel doesn't have a password, it still will require the second argument and the second argument must be empty.\n\n```lua\nmilla.part_channel(channel)\n```\n\n```lua\nmilla.send_ollama_request(prompt, systemPrompt)\n```\n\n```lua\nmilla.send_gemini_request(prompt, systemPrompt)\n```\n\n```lua\nmilla.send_chatgpt_request(prompt, systemPrompt)\n```\n\n```lua\nmilla.send_or_request(prompt, systemPrompt)\n```\n\n```lua\nmilla.query_db(query)\n```\n\n```lua\nmilla.register_cmd(script_path, cmd_name, function_name)\n```\n\n```lua\nmilla.url_encode(str)\n```\n\n```lua\nmilla.reply_to(reply)\n```\n\nSince commands are messages sent to a bot, you can use the provided functions to run any milla commands, including user agents. Note that the said command will come from the milla instance that runs the lua script so make sure your `adminOnly` and `admins` options allow for that.\u003cbr/\u003e\n\n```lua\nmilla.send_message(\"terra2: /ua web_search_tool\", \"terra2\")\n```\n\nUsing `register_cmd` we can register a command that will be available to run like the built-in and customs commands.\u003cbr/\u003e\nHere's an example of how to use it:\u003cbr/\u003e\n\n```lua\nlocal milla = require(\"milla\")\nlocal os = require(\"os\")\nlocal json = require(\"json\")\n\n-- setting the proxy value before loading the http module\n-- this way, only this script will be using this proxy\nos.setenv(\"ALL_PROXY\", \"socks5://172.17.0.1:9057\")\n\nlocal http = require(\"http\")\n\n-- this function should be global\n-- one string arg that holds all args\n-- should only return one string value\nfunction milla_get_ip(arg)\n    local ip = arg\n    local response, err = http.request(\"GET\", \"http://ip-api.com/json/\" .. ip)\n    if err ~= nil then print(err) end\n\n    local json_response, err = json.decode(response.body)\n    if err ~= nil then print(err) end\n    for k, v in pairs(json_response) do print(k, v) end\n\n    local result = \"\"\n    for key, value in pairs(json_response) do\n        result = result .. key .. \": \" .. value .. \" -- \"\n    end\n\n    return result\nend\n\nmilla.register_cmd(\"/plugins/ip.lua\", \"ip\", \"milla_get_ip\")\n```\n\nThis will allow us to do:\u003cbr/\u003e\n\n```txt\nterra: /ip 1.1.1.1\n```\n\nAnd get this in response:\u003cbr/\u003e\n\n```txt\nisp: Cloudflare, Inc -- query: 1.1.1.1 -- status: success -- regionName: Queensland -- lat: -27.4766 -- timezone: Australia/Brisbane -- region: QLD -- lon: 153.0166 -- country: Australia -- countryCode: AU -- city: South Brisbane --ip: 4101 -- org: APNIC and Cloudflare DNS Resolver project -- as: AS13335 Cloudflare, Inc. --\n```\n\n### NOTES\n\n- Each lua plugin gets its own lua state and will run in a goroutine.\u003cbr/\u003e\n- Lua plugins will not go through a proxy if they are not instructed to do so. If you are using the provided http module, you can set the proxy value before loading the http module as provided in the examples under `plugins`. The module will read and set the following environment variables in the order given:\n\n  - `ALL_PROXY`\n  - `HTTPS_PROXY`\n  - `HTTP_PROXY`\n  - `https_proxy`\n  - `http_proxy`\n\n  `http` and `socks5` proxies are supported. unfortunately, the `socks5h` proxy is not supported.\u003cbr/\u003e\n\n```sh\nALL_PROXY=socks5://172.17.0.1:9050\n```\n\nMore of milla's functionality will be available through milla's lua module over time.\u003cbr/\u003e\n\nmilla loads the following libraries by default:\n\n- [gluaxmlpath](https://github.com/ailncode/gluaxmlpath)\n- [gluahttp](https://github.com/cjoudrey/gluahttp)\n- [gluayaml](https://github.com/kohkimakimoto/gluayaml)\n- [gluasocket](https://gitlab.com/megalithic-llc/gluasocket)\n- [gluare](https://github.com/yuin/gluare)\n- [gopher-json](https://github.com/layeh/gopher-json)\n\n## FAQ\n\n- I end up with color escape sequences getting printed at the end of a line/begging of the next line. What gives?\n  This is happening because you have reached the message limit on irc which 512 for the event. This practically leaves around 390-400 character left for the message itself. Certain ircds allow for bigger sizes and certain clients might do. But most ircds don't send `linelen` to the clients. In a closed-loop situation where you control everything, as in, the ircd and all the clients(i.e. A private irc network), you can try to increase the `linelen` for the ircd and the client. Please note that the client in this case is girc. You irc client can have its own set of limits too. The 512 limit is hardcoded in girc. You can vendor the build or use the vendored dockerfile, change the hard limit and run milla with an increased limit. Needless to say, you can try to use a `chromaFormatter` that produces less characters which is basically not using truecolor or `terminal16m`.\n\n## Resources\n\n- [OpenRSS](https://openrss.org/)\n- [Google Alerts](https://www.google.com/alerts)\n\n## Thanks\n\nMilla would not exist without the following projects:\n\n- [girc](https://github.com/lrstanley/girc)\n- [gopher-lua](https://github.com/yuin/gopher-lua)\n- [chroma](https://github.com/alecthomas/chroma)\n- [pgx](https://github.com/jackc/pgx)\n- [ollama](https://github.com/ollama/ollama)\n- [toml](https://github.com/BurntSushi/toml)\n- [gofeed](https://github.com/mmcdole/gofeed)\n\n## Similar Projects\n\n- [soulshack](https://github.com/pkdindustries/soulshack)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterminaldweller%2Fmilla","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterminaldweller%2Fmilla","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterminaldweller%2Fmilla/lists"}