Multimodal API for integrating Obsidian, Tailscale, Cloudflare, Ollama, r2r, ElevenLabs, xtts_v2, whisper_cpp, ComfyUI, Instagram, Postgres, GPS/GIS, Courtlistener, IMAP emails, MS365 & Apple Calendars, Timing, in a way that may not make sense to many except sij himself. https://sij.ai
Find a file
2024-06-23 00:19:36 -07:00
sijapi Initial commit 2024-06-23 00:19:36 -07:00
tests Initial commit 2024-06-23 00:19:36 -07:00
.gitignore Initial commit 2024-06-23 00:19:36 -07:00
README.md Initial commit 2024-06-23 00:19:36 -07:00
requirements.txt Initial commit 2024-06-23 00:19:36 -07:00
setup.py Initial commit 2024-06-23 00:19:36 -07:00
sij.asc Initial commit 2024-06-23 00:19:36 -07:00

#──────────────────────────────────────────────────────────────────────────────────
#                     C O N F I G U R A T I O N     F I L E                        
#──────────────────────────────────────────────────────────────────────────────────
#                                                                                  
#  Hi friend! You've found my hidden .config.YAML-example file. Do you like 
#  old-school ASCII art? I bet you do. So listen, this'll be your method for 
#  configuring sijapi, and nothing works until you at least:
#                                                                                  
#    (1) fill in the ESSENTIALS category, and                                      
#                                                                                  
#    (2) rename this file `.config.yaml`                                          
#                                                                                  
#  ... and even then, certain features will not work until you set other          
#  relevant variables below.                                                      
#                                                                                 
#  So get yourself a beverage, put on some sick beats, and settle in for a vibe-y 
#  configuration sesh. Remember to read my detailed notes if you ever feel lost,   
#  and most important, remember:                                                   
#                                                                                  
#             you are NOT alone,                                                   
#             I love you SO much,                                                  
#             and you are SO worthy. <3                                            
#                                                                                  
#                    y o u r   b f & b f 4 e , †                                   
#          .x+=:.       .                                              .           
#         z`    ^%     @88>      ..                                  @88>          
#            .   <k    %8P      888>                 .d``            %8P           
#          .@8Ned8"     .       "8P          u       @8Ne.   .u       .            
#        .@^%8888"    .@88u      .        us888u.    %8888:u@88N    .@88u          
#       x88:  `)8b.  ''888E`   u888u.  .@88 "8888"    `888I  888.  ''888E`         
#   ~   8888N=*8888    888E   `'888E   9888  9888      888I  888I    888E          
#        %8"    R88    888E     888E   9888  9888      888I  888I    888E          
#         @8Wou 9%     888E     888E   9888  9888    uW888L  888'    888E          
#       .888888P`      888&     888E   9888  9888   '*88888Nu88P     888&          
#       `   ^"F        R888"    888E   "888*""888" ~  '88888F`       R888"         
#                       ""      888E    ^Y"   ^Y'      888 ^          ""           
#                               888E                   *8E                         
#                               888P                   '8>         † biggest fan   
#                             .J88" "                   "               and best   
#                                                              friend  4 e v e r   
#                                                                                  
#                         B U T   I   H E A R   Y O U :                            
#                L E T ' S   T A K E   I T   S  L  O  W   A N D                    
#         ──────────────   S T A R T   W I T H   T H E   ──────────────            
#                                                                                  
#  ███████╗███████╗███████╗███████╗███╗   ██╗████████╗██╗ █████╗ ██╗     ███████╗  
#  ██╔════╝██╔════╝██╔════╝██╔════╝████╗  ██║╚══██╔══╝██║██╔══██╗██║     ██╔════╝  
#  █████╗  ███████╗███████╗█████╗  ██╔██╗ ██║   ██║   ██║███████║██║     ███████╗  
#  ██╔══╝  ╚════██║╚════██║██╔══╝  ██║╚██╗██║   ██║   ██║██╔══██║██║     ╚════██║  
#  ███████╗███████║███████║███████╗██║ ╚████║   ██║   ██║██║  ██║███████╗███████║  
#   ╚══════╝╚══════╝╚══════╝╚══════╝╚═╝  ╚═══╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝ 
#        ─────────────────────────────────────────────────────────────────         
#                                                                                  
#─── first, bind an ip address and port : ──────────────────────────────────────────
HOST_NET=0.0.0.0 
HOST_PORT=4444
BASE_URL=https://api.sij.ai

#─── notes: ──────────────────────────────────────────────────────────────────────
#                                                                                   
#   HOST_NET† and HOST_PORT comprise HOST and determine the ip and port the server binds to.
#   BASE_URL is used to assemble URLs, e.g. in the MS authentication flow and for serving images generated on the sd router.
#   BASE_URL should match the base URL used to access sijapi sans endpoint, e.g. http://localhost:4444 or https://api.sij.ai 
#                            
#   † Take care here! Please ensure you understand the implications of setting HOST_NET to anything besides 127.0.0.1, and configure your firewall and router appropriately if you do. Setting HOST_NET to 0.0.0.0, for instance, opens sijapi to any device the server running it is accessible to — including potentially frightening internet randos (depending how your firewall, router, and NAT are configured). 
#                                                                                   
#  Here are a few options to consider to more securely enable access from 
#  other devices:      
#                                                                                 
#        (1) if all access can occur over Tailscale, either:
#                (a) leave HOST_NET set to 127.0.0.1, run `tailscale cert $(tailscale 
#                    whois $(tailscale ip | head -n 1)  | awk '/Name:/ {print $2}') 
#                    if you haven't already issued yourself a TLS certificate on 
#                    Tailscale, and then run  `tailscale serve --bg --https=4443 
#                    4444` to expose sijapi to your other tailscale-enabled devices 
#                    at `https://{device.magicdns-domain.net:4443`}; or
#                (b) set HOST_NET to  your server's Tailscale IP (this should work
#                    but for me doesn't reliably)
#                                                                                 
#        (2) if WAN access truly is required, leave HOST_NET set to 127.0.0.1 and 
#            configure either:
#                (a) a Cloudflare tunnel, or 
#                (b) a reverse proxy with HTTPS (Caddy is excellent for this). 
#                                                                                  
#  And please be sure to set a strong API key either way but especially for (2).
#                                 ──────────                                       
#                                                                                  
#──── configure API key authorization and select exemptions────────────────────────
GLOBAL_API_KEY=sk-NhrtQwCHNdK5sRZC
PUBLIC_SERVICES=/id,/ip,/health,/img/,/cl/dockets,/cl/search,/cd/alert
TRUSTED_SUBNETS=127.0.0.1/32,10.13.37.0/24,100.64.64.0/24
#─── notes: ──────────────────────────────────────────────────────────────────────
#                                                                                  
#   GLOBAL_API_KEY determines the API key that will be required to access all endpoints, except access to PUBLIC_SERVICES or from TRUSTED_SUBNETS. Authentication is made via an `Authorization: Bearer {GLOBAL_API_KEY}` header.
#   TRUSTED_SUBNETS might commonly include 127.0.0.1/32 (localhost), 100.x.x.0/24 (Tailscale tailnet), and/or 192.168.x.0/24 or 10.x.x.0/24 (local network).
#   When configuring a reverse proxy or Cloudflare tunnel, please verify traffic through it does not appear to sijapi (i.e. in ./logs) as though it were coming from any of the subnets specified here. For sij, using Caddy, it does not, but your setup may differ.
#                                 ──────────                                       
#                                                                                  
#─── router selection: ────────────────────────────────────────────────────────────
ROUTERS=asr,llm,health,hooks,locate,note,sd,serve,summarize,time,tts,weather
UNLOADED=auth,calendar,cf,email,ig
#─── notes: ──────────────────────────────────────────────────────────────────────
#                                                                                  
#   ROUTERS determines which routers are loaded.† 
#   UNLOADED is not used directly -- it's just there to help keep track which routers are disabled.
#                                                                                  
#   † ┓ ┏ orth bearing in mind: some routers inherently rely on other routers, 
#     ┃┃┃ 3rd party APIs, or other apps being installed locally. If a router is 
#     ┗┻┛ set to load (i.e. is included in ROUTERS) depends on another router, 
#     that other router will also load too irrespective of whether it's listed.      
#                                                                             
#               But let's get down to brass tacks, shall we?                        
#                                                                              
#         asr:  requires faster_whisper — $ pip install faster_whisper — and      
#               downloading the model file specified in ASR_DEFAULT_MODEL.        
#                                                                                
#        auth:  authenticates a Microsoft 365 account (for email & calendar).
#                                                                                  
#    calendar:  requires (1) a Microsoft 365 account with a properly configured   
#               Azure Active Directory app, and/or (2) Calendars on macOS. 
#                                                                                  
#          cf:  interfaces with the Cloudflare API and Caddy to register new   
#               [sub-]domains on Cloudflare and deploy them with Caddy as 
#               reverse proxy.           
#                                                                               
#        llm:  requires ollama — $ pip install ollama — and downloading the      
#              models set in LLM_DEFAULT_MODEL and LLM_VISION_MODEL.             
#                                                                               
#      email:  designed for accessing Protonmail via Protonmail Bridge and/or 
#              Microsoft 365, but should work with any IMAP/SMTP email account.
#                                                                               
#      hooks:  designed for two specific use cases: monitoring court dockets    
#              through CourtListener.org, and monitoring arbitrary web pages for 
#              changes in tandem with a self-hosted changedetection.io instance. 
#              Both require accounts; other functionality would require 
#              additional / modified code.
#                                                                                
#         ig:  requires an Instagram account, with credentials and other settings
#              configured separately in the ig_config.json file; relies heavily
#              on the llm and sd routers which have their own dependencies.   
#                                                                                  
#     locate:  some endpoints work as is, but the core location tracking 
#              functionality requires Postgresql + PostGIS extension and are
#              designed specifically to pair with a mobile device where 
#              Pythonista is installed and configured to run the
#             `gps_tracker.py` and `gps_upload.py` scripts periodically or per
#              repeating conditionwy (e.g. via automation under Apple Shortcuts).         
#                                                                                 
#       note:  designed for use with Obsidian plus the Daily Notes and Tasks 
#              core extensions; and the Admonitions, Banners, Icons (with the 
#              Lucide pack), and Make.md community extensions. Moreover `notes`
#              relies heavily on the calendar, llm, locate, sd, summarize, time, 
#              tts, and weather routers and accordingly on the external 
#              dependencies of each.
#                                                                                  
#         sd:  requires ComfyUI plus any modules and StableDiffusion models 
#              set in sd_config and individual workflow .json files.        
#                                                                                 
#  summarize:  relies on the llm router and thus requires ollama.
#  
#       time:  requires the subscription-based macOS app 'Timing' (one of many
#              apps that together make SetApp an incredible value for macOS users!)
#                                                                                  
#        tts:  designed for use with coqui — $ pip install coqui — and/or the 
#              ElevenLabs API.
#  
#    weather:  requires a VisualCrossing API key and is designed for (but doesn't
#              itself strictly require) Postgresql with the PostGIS extension; 
#              (... but it presently relies on the locate router, which does).
#                                                                                    
#                                                                                    
#     ... Whew! that was a lot, right? I'm so glad we're in this together...         
#                                   ──────────                                        
#                                                                                    
#───────────────────────  Y O U ' R E   G O N N A   L O V E  ────────────────────────
#                                                                                   
# ░        ░░      ░░        ░  ░░░░░░░░      ░░░      ░░░      ░░  ░░░░░░░        ░
# ▒▒▒▒  ▒▒▒▒  ▒▒▒▒  ▒▒▒▒  ▒▒▒▒  ▒▒▒▒▒▒▒  ▒▒▒▒▒▒▒  ▒▒▒▒  ▒  ▒▒▒▒  ▒  ▒▒▒▒▒▒▒  ▒▒▒▒▒▒▒
# ▓▓▓▓  ▓▓▓▓  ▓▓▓▓  ▓▓▓▓  ▓▓▓▓  ▓▓▓▓▓▓▓▓      ▓▓  ▓▓▓▓▓▓▓  ▓▓▓▓  ▓  ▓▓▓▓▓▓▓      ▓▓▓
# ████  ████        ████  ████  █████████████  █  ████  █        █  ███████  ███████
# ████  ████  ████  █        █        ██      ███      ██  ████  █        █        █
#                                                                                   
#                A N D   I ' M   N O T.   E V E N.   J E A L O U S.                 
#            Y O U   D E S E R V E   I T   A L L ,   B A B Y C A K E S.             
#                                                                                   
#─── use tailscale for secure remote access: ───────────────────────────────────────
TS_IP=100.64.64.20
TS_SUBNET=100.64.64.0/24
TS_ID=sij-mbp16
TS_TAILNET=starling-sailfin
TAILSCALE_API_KEY=tskey-api-kosR4MfJtF11CNTRL-zJu4odnpr4huLwAGsuy54hvkJi2ScVWQL
#─── notes: ──────────────────────────────────────────────────────────────────────
#
#   TS_IP should match the Tailscale IP of the device. But this is deprecated, and if the functionality becomes relevant again, it should be come back in the form of a dynamic check (`tailscale status` in a shell subprocess) in __init__.py or even the /id endpoint.
#   TS_SUBNET should match the IP/CIDR-format tailnet
#   TS_ID currently has two roles: it's used to assemble the complete MagicDNS of the server, and it determines what the /id endpoint on the health router returns. This is relevant where multiple servers run the script behind a load balancer (e.g. Caddy), as a means to check which server responds. Bear in mind that /id is NOT API key-protected by default here.
#   TS_TAILNET should match the tailnet's MagicDNS domain (omitting the `.net`, for reasons)
#                                   ──────────                                        
#                                                                                     
#────────────── U   &   M E ──  W E   C A N   G E T   T H R O U G H ──────────────────
#                                                                                     
#       ██▓███  ▒█████    ██████ ▄▄▄█████▓  ▄████  ██▀███  ▓█████   ██████            
#      ▓██░  ██▒██▒  ██▒▒██    ▒ ▓  ██▒ ▓▒ ██▒ ▀█▒▓██ ▒ ██▒▓█   ▀ ▒██    ▒            
#      ▓██░ ██▓▒██░  ██▒░ ▓██▄   ▒ ▓██░ ▒░▒██░▄▄▄░▓██ ░▄█ ▒▒███   ░ ▓██▄              
#      ▒██▄█▓▒ ▒██   ██░  ▒   ██▒░ ▓██▓ ░ ░▓█  ██▓▒██▀▀█▄  ▒▓█  ▄   ▒   ██▒           
#      ▒██▒ ░  ░ ████▓▒░▒██████▒▒  ▒██▒ ░ ░▒▓███▀▒░██▓ ▒██▒░▒████▒▒██████▒▒           
#      ▒██▒ ░  ░ ▒░▒░▒░ ▒ ▒▓▒ ▒ ░  ▒ ░░    ░▒   ▒ ░ ▒▓ ░▒▓░░░ ▒░ ░▒ ▒▓▒ ▒ ░           
#      ▒▓▒░      ░ ▒ ▒░ ░ ░▒  ░ ░    ░      ░   ░   ░▒ ░ ▒░ ░ ░  ░░ ░▒  ░ ░           
#      ░▒      ░ ░ ░ ▒  ░  ░  ░    ░      ░ ░   ░   ░░   ░    ░   ░  ░  ░             
#      ░░          ░ ░ T O G E T H ░ R .        ░    ░        ░  ░      ░             
#                                                                       ░             
#─── for weather and locate modules: ───────────── J U S T   H O L D   M Y   H A N D .
DB=sij                                                                              
#                                                 R E A L   T I G H T.               
DB_HOST=127.0.0.1                                                                   
DB_PORT=5432                                                                        
#                                                    U   G O T   T H I S ,   K ?    
DB_USER=sij                                                                         
DB_PASS='Synchr0!'                                                                  
#                                     Y E A H . . .                                 
DB_SSH=100.64.64.15                                                                 
#                                               * J U S T   L I K E   T H A T . *   
DB_SSH_USER=sij                                                                     
DB_SSH_PASS='Synchr0!'                                                              
#─── notes: ──────────────────────────────────────────────────  S E E ?   E Z - P Z
#                                                                                   
#   DB, DB_HOST, DB_PORT, DB_USER, and DB_PASS should specify those respective      
#   credentials for your Postgres database. DB_SSH and associated _USER and _PASS   
#   variables allow database access over an SSH tunnel.                             
#                                                                                   
#   In the current implementation, we rely on Postgres to hold:                     
#       i.  user-logged location data (locate module), and                          
#      ii.  results from past weather forecast checks (weather module).             
#                                                                                     
#   A future version will hopefully make use of PostGIS's geocoding capabilities,     
#   and add a vector database for the LLM module. Until then it's up to you if the    
#   locate and weather modules are worth the hassle of maintaining Postgres.          
#                                   ──────────                                        
#                                                                                     
#                                                                                     
#───── Y O U   C A N   S I T   T H I S   O N E)  O U T   B A B E , ────────<3─────────
#                         ( (                (     I F   Y O U ' D      )             
#                         ))\(             ( /((   L I K E . . .      ( (             
#            (           (()/((           /((_)\                    )\())),----,.     
#            )\((__     ))\( ())         |__))((_)-                 ))((,'   ,'       
#           ,'  , `.   /((_)\(_)        /   /     '.               |(_)|_ ,'   .'     
#        ,-+-,.' _ |  /  /    '.      / ../        ;     ,---.    ,----.'    .'       
#     ,-+-. ;   , || |  :  /`. /     \ ``\  .`-    '   /     \   |    |   .'          
#    ,--.'|'   |  ;|;  |  |--`        \___\/   \   :  /    / '   :    :  |--,         
#   |   |  ,', |  ':|  :  ;_               \   :   | .    ' /    :    |  ;.' \        
#   |   | /  | |  || \  \    `.            /  /   / '   /  ;     |    |      |        
#   '   | :  | :  |,  `----.   \       )   \  \   \ |   :  \     `----'.'\   ;        
#   ;   . |  ; |--'  )(__ \  \  |      ((__ /   :   |;   |   ``.    __  \  . |        
#   |   : |  | ,     /  /`--'  /      /)\(/\   /   :'   ;      \ /   /\/  /  :        
#   |   : '  |/     '--'.     /      / ,,/  ',-    .'   |  .\  |/ ,,/  ',-   .        
#   ;   | |`-'        `--'---'       \ ''\        ; |   :  ';  :\ ''\       ;         
#   |   ;/      O R ,   Y U P ,       \   \     .'   \   \    /  \   \    .'          
#   '---'B U R N   I T   A L L   D O W N.-`-,,-'      `---`--`    `--`-,-'            
#            Y O U   H A V E   A                                                      
#                    G O D D E S S   O F   D E S T R U C T I O N   W I T H I N ,      
#                                          A N D   T H A T   I S   S O   V A L I D  !!
#─── ms365 (calendars): ──────────────────────────────────────────────────────────────
MS365_TOGGLE=False
ICAL_TOGGLE=True
ICALENDARS=3CCC9C7B-BFF0-4850-9CE9-BC504859CBC6,E68FE085-2ECA-4097-AF0A-8D38C404D8DA,AB5A0473-16DD-4916-BD6D-6CB916726605∑∑
MS365_CLIENT_ID=ce8cbd24-f146-4dc7-8ee7-51d9b69dec59
MS365_TENANT_ID=bad78048-a6e0-47b1-a24b-403c444aa349
MS365_SECRET=gbw8Q~7U90GMdvneNnPnzAUt5nWVJPbOsagLPbMe
MS365_THUMBPRINT=4CD86699A8B675411EE9C971CB2783E11F9E52CB
MS365_SCOPE=basic,calendar_all
MS365_TOKEN_FILE=oauth_token.txt
#─── notes: ──────────────────────────────────────────────────────────────────────────────
#                                                                                         
#   # MS365_CLIENT_ID, _TENANT_ID, _SECRET, AND _SCOPES must be obtained from Microsoft 
#   via the Azure portal, by creating a new app registration and an accompanying secret.
#   MS365_THUMBPRINT is vestige of an earlier failed attempt to get this working, and
#   for now is deprecated. I recommend seeking out a well-reviewed tutorial for 
#   creating an app on Azure with a client_id and secret and necessary scopes for
#   individual calendar access, because I had one heck of a time trying various approaches.
#                               Do better, Microsoft.   
#                                     ──────────                                          
#                                                                                         
#────────────────────────────────   I   B E T   Y O U   ──────────────────────────────────
#          R E C E I V E   A   L O T   O F    L O V E   L E T T E R S   O V E R           
#                                                                                         
#       .----------------. .----------------. .----------------. .----------------.       
#     | .--------------. | .--------------. | .--------------. | .--------------. |       
#     | |     _____    | | | ____    ____ | | |      __      | | |   ______     | |       
#     | |    |_   _|   | | ||_   \  /   _|| | |     /  \     | | |  |_   __ \   | |       
#     | |      | |     | | |  |   \/   |  | | |    / /\ \    | | |    | |__) |  | |       
#     | |      | |     | | |  | |\  /| |  | | |   / ____ \   | | |    |  ___/   | |       
#     | |     _| |_    | | | _| |_\/_| |_ | | | _/ /    \ \_ | | |   _| |_      | |       
#     | |    |_____|   | | ||_____||_____|| | ||____|  |____|| | |  |_____|     | |       
#     | |              | | |              | | |              | | |              | |       
#     | '--------------' | '--------------' | '--------------' | '--------------' |       
#      '----------------' '----------------' '----------------' '----------------'        
#                                                                                         
#                                       E M A I L                                         
#                                                                                         
#─── imap & smtp: ────────────────────────────────────────────────────────────────────────
IMAP_HOST=127.0.0.1
EMAIL_ADDRESS='sij@sij.law'
EMAIL_PASSWORD='hesSw7Kum16z-_yxI4kfXQ'
IMAP_PORT=1143
IMAP_ENCRYPTION=STARTTLS
SMTP_PORT=1025
SMTP_ENCRYPTION=SSL
#─── notes: ───────────────────────────────────────────────────────────────────────────────
#                                                                                          
#   This is primarily for summarizing incoming emails. Any IMAP account should work, but   
#   I focused testing on a somewhat complex setup involving Protonmail Bridge.             
#                                      ──────────                                          
#                                                                                          
#────────────────────────────────  G E T   S I L L Y   ────────────────────────────────────
#                            T H E N   G O   B O N K E R S                                 
#                              W I T H   Y O U R   O W N                                   
#                                                                                          
#                  ░▒▓█▓▒░        ░▒▓█▓▒░         ░▒▓██████▒▓██████▒░                      
#                  ░▒▓█▓▒░        ░▒▓█▓▒░        ░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░                     
#                  ░▒▓█▓▒░        ░▒▓█▓▒░        ░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░                     
#                  ░▒▓█▓▒░        ░▒▓█▓▒░        ░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░                     
#                  ░▒▓█▓▒░        ░▒▓█▓▒░        ░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░                     
#                  ░▒▓█▓▒░        ░▒▓█▓▒░        ░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░                     
#                  ░▒▓████████▓▒  ░▒▓████████▓▒  ░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░                     
#                                                                                          
#                                              ( F O R   R E A L   T H O U G H — T H E S E 
#─── via comfyui (stable diffusion):              A R E  S O   H O T   R I G H T   N O W ) 
LLM_URL=http://localhost:11434
SYSTEM_MSG=You are a helpful AI assistant.
DEFAULT_LLM=dolphin-mistral
DEFAULT_VISION=llava-llama3
SUMMARY_MODEL=dolphin-mistral
SUMMARY_CHUNK_SIZE=4000
SUMMARY_CHUNK_OVERLAP=100
SUMMARY_TPW=1.3
SUMMARY_LENGTH_RATIO=4
SUMMARY_MIN_LENGTH=150
SUMMARY_TOKEN_LIMIT=4096
SUMMARY_INSTRUCT='You are an AI assistant that provides accurate summaries of text -- nothing more and nothing less. You must not include ANY extraneous text other than the sumary. Do not include comments apart from the summary, do not preface the summary, and do not provide any form of postscript. Do not add paragraph breaks. Do not add any kind of formatting. Your response should begin with, consist of, and end with an accurate plaintext summary.'
SUMMARY_INSTRUCT_TTS='You are an AI assistant that provides email summaries for Sanjay -- nothing more and nothing less. You must not include ANY extraneous text other than the sumary. Do not include comments apart from the summary, do not preface the summary, and do not provide any form of postscript. Do not add paragraph breaks. Do not add any kind of formatting. Your response should begin with, consist of, and end with an accurate plaintext summary. Your response will undergo Text-To-Speech conversion and added to Sanjays private podcast. Providing adequate context (Sanjay did not send this question to you, he will only hear your response) but aiming for conciseness and precision, and bearing in mind the Text-To-Speech conversion (avoiding acronyms and formalities), summarize the following.'
DEFAULT_VOICE=Luna
#─── notes: ──────────────────────────────────────────────────────────────────────────────
#                                                                                         
#   The exact values here will depend on what software you are using to inference an LLM,
#   and of course what models and capabilities are available through it. The script was 
#   designed for use with `ollama`, but most of the functionality should be equal with
#   LM Studio, LocalAI, ect...                                                            
#   
#   DEFAULT_LLM is self-explanatory; DEFAULT_VISION is used for image recognition within
#   a multimodal chat context, such as on the ig module for generating intelligible      
#   comments to Instagram posts, or more realistic captions for sd-generated images.     
#   
#   Note it's possible to specify a separate model for general purposes and for 
#   summarization tasks. The other SUMMARY_ variables call for some explanation, 
#   in particular six that are most relevant when summarizing very long documents:
#   
#      SUMMARY_CHUNK_SIZE:  determines the maximum length, in tokens, the pieces that are 
#                           split and sent individually to the model.
#
#   SUMMARY_CHUNK_OVERLAP:  determines how much of each chunk is overlapped with the prior
#                           and next chunks. Set too high causes repetition, set too low
#                           causes misunderstood confusion and poor summary results.
#                           The summarization algorithm is flawed but I've gotten the best
#                           results with this set around 100200.
#
#             SUMMARY_TPW:  used in estimating the token count of a prompt for purposes of
#                           complying with the maximum tokens a model can handle at once.
#                           Best you can do is estimate. I tend to use long words a fair
#                           excessively and found my average was 1.3 tokens per word. YMMV.
#                                                                                         
#    SUMMARY_LENGTH_RATIO:  this is the primary control over the length of generated 
#                           summaries, expressed as the ratio of original text length to 
#                           summary length. The default, 4, means the summaries will be
#                           around 1/4 the length of the original text you provide it.
#        
#      SUMMARY_MIN_LENGTH:  the default SUMMARY_LENGTH_RATIO of 4 isn't ideal for very
#                           short texts, but setting it any lower sacrifices conciseness
#                           in summaries of longer texts. In short one size doesn't fit
#                           all. The compromise I landed on was to set a "maximum minimum"
#                           summary length: under no circumstances will the script impose
#                           a smaller maximum length than this value.
#                                                                                         
#        SUMMARY_INSTRUCT:  sets the prompt used when summarizing text.
#
#    SUMMARY_INSTRUCT_TTS:  sets a separate prompt for use when summarizing text where
#                           tts output was requested; tends to yield "cleaner" audio 
#                           with less numbers (page numbers, citations) and other 
#                           information extraneous to spoken contexts.
#                           
#           DEFAULT_VOICE:  used for all tts tasks when a specific voice is not requested.
#                                      ──────────                                         
#                                                                                         
#────,-_/──────────   W E   C A N   E X P E R I M E N T   W I T H   ──────────.───────────
#   '  |  ,~-,-.  ,-.  ,-.  ,--.    |  --' ,--.   ,-.   ,--.  ,-.  ,-.  |--  .  ,-.   ,-. 
# .^  |  |  |  | ,--| |  | | --'   |  -,- | --'  |  |  | --' |    ,--|  |   |  |  |  |  | 
# `--'  '  '  '  `-^  `-|  `--'   `---|   `--'  '  '   `--'  '    `--^  `'  `  `-'  '  '  
#                  ,   |         ,-. |        ~ I N   T H E   N U D E . ~                 
#                  `~~'          `-+'                                                     
#                                   O R   F U L L Y   C L O T H E D  ──  U P   T O   Y O U
#                                                                                         
#─── via comfyui (stable diffusion): ───── ( B U T   L E T   M E   K N O W ,   Y E A H ? )
COMFYUI_URL=http://localhost:8188
COMFYUI_DIR=/Users/sij/workshop/sd/ComfyUI
PHOTOPRISM_USER=NOT_IMPLEMENTED
PHOTOPRISM_PASS=NOT_IMPLEMENTED
#─── notes: ──────────────────────────────────────────────────────────────────────────────
#                                                                                         
#   COMFY_URL, as you may expect, should point to the URL you use to access ComfyUI. If you 
#   don't know, watch for it in the server logs once ComfyUI is fully launched.           
#                                                                                         
#   COMFYUI_DIR, with similar self-evidence, should point to the base directory of your   
#   ComfyUI installation (i.e. the folder that contains `models`, `inputs`, and `outputs`)
#   
#   PhotoPrism integration is not yet implemented, so don't bother with that just yet.
#                                     ──────────                                          
#                                                                                         
#  D O N ' T   M I S S   O N E   ───────────────────────────────────────
#\  F I N A L   S M A T T E R I N G   O F   M I S C E L L A N Y         \
# \ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\                             
#  \ _ _ _/\\\\_ _ _ _ _ _ /\\\\ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\                
#   \ _ _ \/\\\\\\_ _ _ _ /\\\\\\ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\          
#    \ _ _ \/\\\//\\\_ _ /\\\//\\\ _ _/\\\ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\  
#     \ _ _ \/\\\\///\\\/\\\/ \/\\\ _ _///_ _ _/\\\\\\\\\\_ _ _ _/\\\\\\\\_ _\
#      \ _ _ \/\\\ _\///\\\/ _ \/\\\ _ _/\\\ _ \/\\\////// _ _ _/\\\////// _ _\  
#       \ _ _ \/\\\ _ _\/// _ _ \/\\\ _ _/\\\ _ \/\\\\\\\\\\_ _ /\\\_ _ _ _ _ _\ 
#        \ _ _ \/\\\ _ _ _ _ _ _ \/\\\ _ _/\\\ _ \////////\\\_ _\//\\\ _ _ _ _ _\ 
#         \ _ _ \/\\\ _ _ _ _ _ _ \/\\\ _ _/\\\ _ _/\\\\\\\\\\_ _ \///\\\\\\\\_ _\
#          \ _ _ \///_ _ _ _ _ _ _ \///_ _ _///_ _ \////////// _ _ _ \//////// _ _\  
#           \ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\  
#            ───────────────────  A N D   O T H E R   W H A T - H A V E - Y O U S  ──
#                                                                                        
#─── other needful API keys, mainly: ────────────────────────────────────────────────────
CF_TOKEN=ESjjVFHXfe6NrBo5TrN4_AfhHNezytCVlY-VS2HD
VISUALCROSSING_API_KEY=DAEJSKWJQ2CHM3J6B7C5FWQZV
ELEVENLABS_API_KEY=01eeafb6ce0f6d1fd70e4aa9e7262827
COURTLISTENER_BASE_URL=https://www.courtlistener.com
COURTLISTENER_API_KEY=your_courtlistener_api_key_here
TIMING_API_URL=https://web.timingapp.com/api/v1
TIMING_API_KEY=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIxIiwianRpIjoiODMyNTMwYTAxYjJhNzdlOTgzZWRlMjRiNDdkMmY0YWYzYWU3YTIzYjkxM2QyNTFmZjE1YTQ4YTkzYjI3YTQ4M2I0MzE5MzU2MzZlMjYyZWYiLCJpYXQiOjE2OTI0MjEyNjkuMDc4MzU4LCJuYmYiOjE2OTI0MjEyNjkuMDc4MzYsImV4cCI6MjAwODA0MDQ2OS4wNzMzMjcsInN1YiI6IjM2MTgxNzA4NDcyMTEwMzg5NzYiLCJzY29wZXMiOltdfQ.fVhhJtYb6wtHBQj7J9sxTsT3nb6_BLu4ynqNMC-SpJ2exj31wF7dHXfdGF-ZCg_H2TWh8Jsrak7ovwHsMPvkLRPgxkyjkyLgVbnzZICbP0xffrsguTnillXKCbEkwOVo4s7esf829VVagHCkpNwYbfKLJ9FLHIqs0hQMhh_S7jpbzmXUe7t6tUG43IgILBD0IwphJ2BGs5X2fhjW8FkCke85JxbQ4a29cqYtgFJ7tMP97noTFB4e_gxFpHUl-Ou_bwdpBKfarTyxhtwm1DJkQB_MrAX4py8tmFlFFJPd-7WG-LaswiI7bctN3Lux-If5oxAhm29PkS3ooxvJD86YDR0rJ94aGc8IBypnqYyGFW1ks5fsQ057UwC3XK62ezilWdamh7gtcInShSdHr7pPtIxntCe3x039NSVTBIQ54WHNaWrfI0i83Lm61ak7Ss3qotJhwtIv0aUOUKS3DOz7jfL4Z4GHUjXgBmubeC_vuLHUVCutBsiZ4Jv4QxmWKy2sPlp-r2OgJlAPkcULvTu1GvXavRTrXb7PXkEKO4ErdBTvu2RyA6XLR1MKs0V7mRNvBfuiMRvWRuv9NBLh6vpgRTVo5Tthh-ahSQ-Rd6QcmvVNf-rLnxWGY4nOdx6QLcYKPukQourR2o6QzxGcpb9pDc8X0p2SEtDrDijpy6usFxk
MAC_ID=sij-mbp16
MAC_UN=sij
MAC_PW="Synchr0!"
#─── notes: ──────────────────────────────────────────────────────────────────────────────
#                                                                                         
#                                                                                         
#                CF_TOKEN:  a Cloudflare token. This is used on the cf router for quick 
#                             deployment of new domains in tandem with Caddy and for ddns. 
#
#    VISUALCROSSING_API_KEY:  used for obtaining weather forecasts. It is a very data-rich
#                             yet affordable source of weather info, with a generous free 
#                             plan.
#
#        ELEVENLABS_API_KEY:  used when on the tts router if tts tasks are outsourced to 
#                             the state-of-the-art models at ElevenLabs.
#
#     COURTLISTENER_API_KEY:  used primarily on the hooks router, but likely relevant only 
#                             to legal professionals that will be aware what it is for.
# 
#            TIMING_API_URL:  are used on the time router for generating various tasks 
#                   &         related to timekeeping, as well as on the notes router for
#            TIMING_API_KEY:  generating markdown-formatted timeslips. It requires an
#                             active subscription to the Timing app (macOS or web), but 
#                             it's worth noting comes included in the SetApp subscribtion  
#                             bundle, for the same price, last I checked, as subscribing to 
#                             Timing alone. If you have a Mac and somehow don't know this 
#                             already, SetApp is an utterly insane value. I pay $15/mo for 
#                             apps that I would otherwise pay ~$100/mo for if subscribing 
#                             individually. I want to say I wasn't paid to say this, but 
#                             with those savings I almost feel like I was.
#
#                   MAC_ID:   These last three variables are for a specific use case where
#                   MAC_UN:   you want certain commands run, or alerts appearing, on a
#                   MAD_PW:   designated macaOS computer. The alerts router is designed to
#                             deliver OS-level notifications to the specified Mac when a
#                             webhook gets a hit on specified keywords within the payload.
#                             Setting the MAC_ID to the TS_ID of the target Mac, allows 
#                             the script to readily know whether it itself is the target
#                             (this is relevant in a load-balancing context), and how to
#                             reach the target if not — to wit, ssh using MagicDNS.