From 8f5901e8db2de662915994df0a98c6cd72ee4774 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sun, 8 Sep 2024 12:15:59 -0400 Subject: [PATCH] move more static websites to k8s Signed-off-by: Xe Iaso --- Earthfile | 4 +- cmd/azurda/README.md | 2 - cmd/geminitest/main.go | 6 +- cmd/la-baujmi/.gitignore | 2 - cmd/la-baujmi/README.md | 66 ----- cmd/la-baujmi/const.go | 5 - cmd/la-baujmi/corpus.txt | 23 -- cmd/la-baujmi/fact.go | 210 ------------- cmd/la-baujmi/fact_test.go | 278 ------------------ cmd/la-baujmi/main.go | 88 ------ cmd/vest-pit-near/main.go | 41 +-- kube/alrest/core/cert-manager-1pass.yaml | 7 + kube/alrest/core/external-dns/1password.yaml | 8 - kube/alrest/core/kustomization.yaml | 3 +- kube/alrest/staticsites/caddy1/Dockerfile | 13 - kube/alrest/staticsites/caddy1/Earthfile | 32 ++ kube/alrest/staticsites/caddy1/caddy.yaml | 79 ++++- kube/alrest/staticsites/caddy1/graphviz.yaml | 36 +++ .../staticsites/caddy1/kustomization.yaml | 3 + .../staticsites/caddy1/tulpanomicon.yaml | 36 +++ .../staticsites/caddy1/when-then-zen.yaml | 36 +++ web/ollama/ollama.go | 17 +- 22 files changed, 252 insertions(+), 743 deletions(-) delete mode 100644 cmd/la-baujmi/.gitignore delete mode 100644 cmd/la-baujmi/README.md delete mode 100644 cmd/la-baujmi/const.go delete mode 100644 cmd/la-baujmi/corpus.txt delete mode 100644 cmd/la-baujmi/fact.go delete mode 100644 cmd/la-baujmi/fact_test.go delete mode 100644 cmd/la-baujmi/main.go create mode 100644 kube/alrest/core/cert-manager-1pass.yaml delete mode 100644 kube/alrest/staticsites/caddy1/Dockerfile create mode 100644 kube/alrest/staticsites/caddy1/Earthfile create mode 100644 kube/alrest/staticsites/caddy1/graphviz.yaml create mode 100644 kube/alrest/staticsites/caddy1/tulpanomicon.yaml create mode 100644 kube/alrest/staticsites/caddy1/when-then-zen.yaml diff --git a/Earthfile b/Earthfile index 639024d4..8cf38947 100644 --- a/Earthfile +++ b/Earthfile @@ -231,4 +231,6 @@ all: BUILD --platform=linux/amd64 +sapientwindex BUILD --platform=linux/amd64 +todayinmarch2020 BUILD --platform=linux/amd64 +within-website - BUILD --platform=linux/amd64 +xedn \ No newline at end of file + BUILD --platform=linux/amd64 +xedn + + BUILD ./kube/alrest/staticsites/caddy1+all \ No newline at end of file diff --git a/cmd/azurda/README.md b/cmd/azurda/README.md index b780f4ef..6a89a28d 100644 --- a/cmd/azurda/README.md +++ b/cmd/azurda/README.md @@ -12,8 +12,6 @@ The heinous crime that we're doing here is implementing this using Tigris' shado However this realistically supports anything that support that can implement the S3 GetObject API call. It doesn't even have to be a storage service. You can just make your own server implement this call and then you get everything cached in tigris for you. -[Live demo](https://azurda.fly.dev) - ![A screenshot of the demo](./static/img/azurda-screenshot.png) This works because we're treating Stable Diffusion as a key-value store, where the key is the fabricated prompt based on the MD5 checksum passed in the URL and the value is the generated image from Stable Diffusion. diff --git a/cmd/geminitest/main.go b/cmd/geminitest/main.go index 8de8e40f..e06c8728 100644 --- a/cmd/geminitest/main.go +++ b/cmd/geminitest/main.go @@ -5,7 +5,6 @@ import ( "flag" "fmt" "log" - "os" "github.com/google/generative-ai-go/genai" "google.golang.org/api/iterator" @@ -14,13 +13,14 @@ import ( ) var ( - geminiModel = flag.String("gemini-model", "gemini-1.5-flash", "The model to use for generating text") + geminiApiKey = flag.String("gemini-api-key", "", "The Gemini API key") + geminiModel = flag.String("gemini-model", "gemini-1.5-flash", "The model to use for generating text") ) func main() { internal.HandleStartup() ctx := context.Background() - client, err := genai.NewClient(ctx, option.WithAPIKey(os.Getenv("GEMINI_API_KEY"))) + client, err := genai.NewClient(ctx, option.WithAPIKey(*geminiApiKey)) if err != nil { log.Fatal(err) } diff --git a/cmd/la-baujmi/.gitignore b/cmd/la-baujmi/.gitignore deleted file mode 100644 index 07b6fbfb..00000000 --- a/cmd/la-baujmi/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.env -la-baujmi \ No newline at end of file diff --git a/cmd/la-baujmi/README.md b/cmd/la-baujmi/README.md deleted file mode 100644 index 10aa48df..00000000 --- a/cmd/la-baujmi/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# la baujmi - -Combination of: - -> bangu -> -> x1 is a/the language/dialect used by x2 to express/communicate x3 (si'o/du'u, not quote). - -> jimpe -> -> x1 understands/comprehends fact/truth x2 (du'u) about subject x3; x1 understands (fi) x3. - -This is an attempt to create a tool that can understand language. - -At first, [Toki Pona](http://tokipona.net) will be used. At a high level a toki pona sentence consists of four main parts: - -- context phrase -- subject + descriptors -- verb + descriptors -- object + descriptors - -You can describe a sentence as a form of predicate relation between those four parts. If you are told "Stacy purchased a tool for strange-plant", you can later then ask the program who purchased a tool for strange-plant. - -Because a Toki Pona sentence always matches the following form: - -``` -[ o,] [context la] [li [e ]] -``` - -And the particle `seme` fills in the part of a question that you don't know. So from this we can fill in the blanks with prolog. - -Consider the following: - -``` -jan Kesi li toki. -Cadey is speaking -toki(jan_Kesi). - -jan Kesi en jan Pola li toki. -Cadey and Pola are speaking. -toki(jan_Kesi). -toki(jan_Pola). - -jan Kesi li toki e jan Pola. -Cadey is talking about Pola -toki(jan_Kesi, jan_Pola). - -jan Kesi li toki e toki pona. -Cadey is talking about toki pona. -toki(jan_Kesi, toki_pona). - -ilo Kesi o, toki e jan Kesi. -Robo-Cadey: talk about Cadey. -command(ilo_Kesi, toki(ziho, jan_Kesi)). % ziho -> nothing in lojban (zi'o) -``` - -And then we can ask prolog questions about this sentence: - -``` -seme li toki? -> toki(X). -toki(jan_Kesi). -jan Kesi li toki. -toki(jan_Pola). -jan Pola li toki. -``` diff --git a/cmd/la-baujmi/const.go b/cmd/la-baujmi/const.go deleted file mode 100644 index 2b70d194..00000000 --- a/cmd/la-baujmi/const.go +++ /dev/null @@ -1,5 +0,0 @@ -package main - -const ( - tokiPonaAPIURL = "https://us-central1-golden-cove-408.cloudfunctions.net/toki-pona-verb-marker" -) diff --git a/cmd/la-baujmi/corpus.txt b/cmd/la-baujmi/corpus.txt deleted file mode 100644 index 53133178..00000000 --- a/cmd/la-baujmi/corpus.txt +++ /dev/null @@ -1,23 +0,0 @@ -sina li lukin e ni la sina pilin pona. sina li lukin e ni la pilin pona ni li suli suwi. sina li lukin e ni la sina li pona ale. sina li lukin e ni la sina li pali e ijo mute mute. - -sina li pona ale la sina pali ijo mute mute. - -sina li jan pi pali ijo mute mute. sina ken pali ijo mute mute. - -sina li wile pali e ilo suli la sina wile jo lukin wawa e tawa ala pi tenpo ni. lukin wawa e tawa ala pi tenpo ni li ilo sina kama e pali ijo pi tenpo pini. nasin ni li pilin sina ala. sina li kama pi toki lawa insa ala e pali ijo pi tenpo pini. - -tenpo ni li ni tenpo. - -tenpo pini li tenpo ni ala. tenpo ni la tenpo pini li suli ala. - -tenpo kama li tenpo ni ala. tenpo ni la tenpo kama li suli ala. - -tenpo ni li tawa ale. sina ken tawa ale e tawa ala pi tenpo ni. - -sina wile jo tawa ala pi tenpo ni la sina wile tawa ni: - -tenpo mute anu sina pilin ni la sijelo sina suli. -tenpo mute anu sina pilin ni la sijelo sina lili. -sina lukin e ijo mute la sina lukin wawa e nena insa. - -sina ken tawa ijo mute la sina kepeken tawa ala pi tenpo ni e sina. sina jo e ni la sina jo lukin wawa pona. sina jo lukin wawa mute en tawa ala pi tenpo ni ale li pali pona e ilo suli. diff --git a/cmd/la-baujmi/fact.go b/cmd/la-baujmi/fact.go deleted file mode 100644 index 86563a48..00000000 --- a/cmd/la-baujmi/fact.go +++ /dev/null @@ -1,210 +0,0 @@ -package main - -import ( - "errors" - "strings" - - "within.website/x/web/tokiponatokens" -) - -// Bridi is a predicate relationship between its arguments. The name comes from -// the lojban term selbri: http://jbovlaste.lojban.org/dict/selbri. -type Bridi struct { - Predicate string - Arguments []string -} - -// Fact converts a selbri into a prolog fact. -func (s Bridi) Fact() string { - var sb strings.Builder - - var varCount byte - - sb.WriteString("bridi(verb(") - - if s.Predicate == "seme" { - sb.WriteByte(byte('A') + varCount) - varCount++ - } else { - sb.WriteString(s.Predicate) - } - sb.WriteString("), ") - - for i, arg := range s.Arguments { - if i != 0 { - sb.WriteString(", ") - } - - switch arg { - case "subject(seme)", "object(seme)": - if strings.HasPrefix(arg, "subject") { - sb.WriteString("subject(") - } else { - sb.WriteString("object(") - } - sb.WriteByte(byte('A') + varCount) - varCount++ - sb.WriteByte(')') - continue - } - sb.WriteString(arg) - } - - sb.WriteString(").") - return sb.String() -} - -var ( - // ErrNoPredicate is raised when the given sentence does not have a verb. - // This is a side effect of the way we are potentially misusing prolog - // here. - ErrNoPredicate = errors.New("la-baujmi: sentence must have a verb to function as the logical predicate") -) - -// SentenceToBridis creates logical facts derived from toki pona sentences. -// This is intended to be the first step in loading them into prolog. -func SentenceToBridis(s tokiponatokens.Sentence) ([]Bridi, error) { - var ( - subjects []string - verbs []string - objects []string - context string - ) - - for _, pt := range s { - switch pt.Type { - case tokiponatokens.PartSubject: - if strings.Contains(pt.Braces(), " en ") { - temp := strings.Split(strings.Join(pt.Tokens, " "), " en ") - - for _, t := range temp { - subjects = append(subjects, "subject("+t+")") - } - - continue - } - - if len(pt.Parts) != 0 { - var sb strings.Builder - sb.WriteString("subject(") - - for i, sp := range pt.Parts { - if i != 0 { - sb.WriteString(", ") - } - if sp.Sep != nil && *sp.Sep == "pi" { - sb.WriteString("pi(") - for j, tk := range sp.Tokens { - if j != 0 { - sb.WriteString(", ") - } - - sb.WriteString(tk) - } - sb.WriteString(")") - } else { - sb.WriteString(strings.Join(sp.Tokens, "_")) - } - } - - sb.WriteString(")") - - subjects = append(objects, sb.String()) - continue - } - - subjects = append(subjects, "subject("+strings.Join(pt.Tokens, "_")+")") - - case tokiponatokens.PartVerbMarker: - verbs = append(verbs, strings.Join(pt.Tokens, "_")) - - case tokiponatokens.PartObjectMarker: - if len(pt.Parts) != 0 { - var sb strings.Builder - sb.WriteString("object(") - - for i, sp := range pt.Parts { - if i != 0 { - sb.WriteString(", ") - } - if sp.Sep != nil && *sp.Sep == "pi" { - sb.WriteString("pi(") - for j, tk := range sp.Tokens { - if j != 0 { - sb.WriteString(", ") - } - - sb.WriteString(tk) - } - sb.WriteString(")") - } else { - sb.WriteString(strings.Join(sp.Tokens, "_")) - } - } - - sb.WriteString(")") - - objects = append(objects, sb.String()) - continue - } - objects = append(objects, "object("+strings.Join(pt.Tokens, "_")+")") - - case tokiponatokens.PartPunctuation: - if len(pt.Tokens) == 1 { - switch pt.Tokens[0] { - case "la": - context = "context(" + subjects[len(subjects)-1] + ")" - subjects = subjects[:len(subjects)-1] - - case tokiponatokens.PunctComma: - return nil, errors.New("please avoid commas in this function") - } - } - } - } - - if len(verbs) == 0 { - return nil, ErrNoPredicate - } - - var result []Bridi - - for _, v := range verbs { - for _, s := range subjects { - if len(objects) == 0 { - // sumti: x1 is a/the argument of predicate function x2 filling place x3 (kind/number) - var sumti []string - if context != "" { - sumti = append([]string{}, context) - } - sumti = append(sumti, s) - - r := Bridi{ - Predicate: v, - Arguments: sumti, - } - - result = append(result, r) - } - - for _, o := range objects { - // sumti: x1 is a/the argument of predicate function x2 filling place x3 (kind/number) - var sumti []string - if context != "" { - sumti = append([]string{}, context) - } - sumti = append(sumti, s) - sumti = append(sumti, o) - - r := Bridi{ - Predicate: v, - Arguments: sumti, - } - - result = append(result, r) - } - } - } - - return result, nil -} diff --git a/cmd/la-baujmi/fact_test.go b/cmd/la-baujmi/fact_test.go deleted file mode 100644 index 32065a51..00000000 --- a/cmd/la-baujmi/fact_test.go +++ /dev/null @@ -1,278 +0,0 @@ -package main - -import ( - "encoding/json" - "log" - "testing" - - "github.com/kr/pretty" - "within.website/x/web/tokiponatokens" -) - -// equal tells whether a and b contain the same elements. -// A nil argument is equivalent to an empty slice. -func equal(a, b []string) bool { - if len(a) != len(b) { - return false - } - for _, v := range a { - var has bool - for _, vv := range b { - if v == vv { - has = true - } - } - if !has { - return false - } - } - return true -} - -func bridisEqual(a, b []Bridi) bool { - if len(a) != len(b) { - return false - } - for _, v := range a { - var has bool - for _, vv := range b { - if v.Eq(vv) { - has = true - } - } - - if !has { - return false - } - } - return true -} - -// Eq checks two Bridi instances for equality. -func (lhs Bridi) Eq(rhs Bridi) bool { - switch { - case lhs.Predicate != rhs.Predicate: - return false - case len(lhs.Arguments) != len(rhs.Arguments): - return false - case len(lhs.Arguments) == len(rhs.Arguments): - return equal(lhs.Arguments, rhs.Arguments) - } - - return true -} - -func TestSentenceToBridis(t *testing.T) { - cases := []struct { - name string - json []byte - want []Bridi - wantFacts []string - }{ - { - name: "basic", - json: []byte(`[{"part":"subject","tokens":["ona"]},{"part":"verbMarker","sep":"li","tokens":["sona"]},{"part":"objectMarker","sep":"e","tokens":["mute"]},{"part":"punctuation","tokens":["period"]}]`), - want: []Bridi{ - { - Predicate: "sona", - Arguments: []string{"subject(ona)", "object(mute)"}, - }, - }, - wantFacts: []string{"bridi(verb(sona), subject(ona), object(mute))."}, - }, - { - name: "zen", - json: []byte(`[{"part":"subject","tokens":["tenpo","ni"]},{"part":"punctuation","tokens":["la"]},{"part":"subject","tokens":["seme"]},{"part":"verbMarker","sep":"li","tokens":["ala"]}]`), - want: []Bridi{ - { - Predicate: "ala", - Arguments: []string{"context(subject(tenpo_ni))", "subject(seme)"}, - }, - }, - wantFacts: []string{"bridi(verb(ala), context(subject(tenpo_ni)), subject(A))."}, - }, - { - name: "pi_subject", - json: []byte(`[{"part":"subject","parts":[{"part":"subject","tokens":["ilo","mi"]},{"part":"subject","sep":"pi","tokens":["kasi","nasa"]}]},{"part":"verbMarker","sep":"li","tokens":["pona","ale"]}]`), - want: []Bridi{ - { - Predicate: "pona_ale", - Arguments: []string{"subject(ilo_mi, pi(kasi, nasa))"}, - }, - }, - wantFacts: []string{"bridi(verb(pona_ale), subject(ilo_mi, pi(kasi, nasa)))."}, - }, - { - name: "pi_object", - json: []byte(`[{"part":"subject","tokens":["mi"]},{"part":"verbMarker","sep":"li","tokens":["esun"]},{"part":"objectMarker","sep":"e","parts":[{"part":"objectMarker","tokens":["ilo"]},{"part":"objectMarker","sep":"pi","tokens":["kalama","musi"]}]},{"part":"punctuation","tokens":["period"]}]`), - want: []Bridi{ - { - Predicate: "esun", - Arguments: []string{"subject(mi)", "object(ilo, pi(kalama, musi))"}, - }, - }, - wantFacts: []string{"bridi(verb(esun), subject(mi), object(ilo, pi(kalama, musi)))."}, - }, - { - name: "multiple verbs", - json: []byte(`[{"part":"subject","tokens":["ona"]},{"part":"verbMarker","sep":"li","tokens":["sona"]},{"part":"verbMarker","sep":"li","tokens":["pona"]},{"part":"objectMarker","sep":"e","tokens":["mute"]},{"part":"punctuation","tokens":["period"]}]`), - want: []Bridi{ - { - Predicate: "sona", - Arguments: []string{"subject(ona)", "object(mute)"}, - }, - { - Predicate: "pona", - Arguments: []string{"subject(ona)", "object(mute)"}, - }, - }, - wantFacts: []string{ - "bridi(verb(sona), subject(ona), object(mute)).", - "bridi(verb(pona), subject(ona), object(mute)).", - }, - }, - { - name: "multiple subjects and verbs", - json: []byte(`[{"part":"subject","tokens":["ona","en","sina","en","mi"]},{"part":"verbMarker","sep":"li","tokens":["sona"]},{"part":"verbMarker","sep":"li","tokens":["pona"]},{"part":"objectMarker","sep":"e","tokens":["mute"]},{"part":"punctuation","tokens":["period"]}]`), - want: []Bridi{ - { - Predicate: "sona", - Arguments: []string{"subject(ona)", "object(mute)"}, - }, - { - Predicate: "pona", - Arguments: []string{"subject(ona)", "object(mute)"}, - }, - { - Predicate: "sona", - Arguments: []string{"subject(sina)", "object(mute)"}, - }, - { - Predicate: "pona", - Arguments: []string{"subject(sina)", "object(mute)"}, - }, - { - Predicate: "sona", - Arguments: []string{"subject(mi)", "object(mute)"}, - }, - { - Predicate: "pona", - Arguments: []string{"subject(mi)", "object(mute)"}, - }, - }, - wantFacts: []string{ - "bridi(verb(sona), subject(ona), object(mute)).", - "bridi(verb(sona), subject(sina), object(mute)).", - "bridi(verb(sona), subject(mi), object(mute)).", - "bridi(verb(pona), subject(ona), object(mute)).", - "bridi(verb(pona), subject(sina), object(mute)).", - "bridi(verb(pona), subject(mi), object(mute)).", - }, - }, - { - name: "multiple subjects and verbs and objects", - json: []byte(`[{"part":"subject","tokens":["ona","en","sina","en","mi"]},{"part":"verbMarker","sep":"li","tokens":["sona"]},{"part":"verbMarker","sep":"li","tokens":["pona"]},{"part":"objectMarker","sep":"e","tokens":["ijo","mute"]},{"part":"objectMarker","sep":"e","tokens":["ilo","mute"]},{"part":"punctuation","tokens":["period"]}]`), - want: []Bridi{ - { - Predicate: "sona", - Arguments: []string{"subject(ona)", "object(ijo_mute)"}, - }, - { - Predicate: "sona", - Arguments: []string{"subject(ona)", "object(ilo_mute)"}, - }, - { - Predicate: "pona", - Arguments: []string{"subject(ona)", "object(ijo_mute)"}, - }, - { - Predicate: "pona", - Arguments: []string{"subject(ona)", "object(ilo_mute)"}, - }, - { - Predicate: "sona", - Arguments: []string{"subject(sina)", "object(ijo_mute)"}, - }, - { - Predicate: "sona", - Arguments: []string{"subject(sina)", "object(ilo_mute)"}, - }, - { - Predicate: "pona", - Arguments: []string{"subject(sina)", "object(ijo_mute)"}, - }, - { - Predicate: "pona", - Arguments: []string{"subject(sina)", "object(ilo_mute)"}, - }, - { - Predicate: "sona", - Arguments: []string{"subject(mi)", "object(ijo_mute)"}, - }, - { - Predicate: "sona", - Arguments: []string{"subject(mi)", "object(ilo_mute)"}, - }, - { - Predicate: "pona", - Arguments: []string{"subject(mi)", "object(ijo_mute)"}, - }, - { - Predicate: "pona", - Arguments: []string{"subject(mi)", "object(ilo_mute)"}, - }, - }, - wantFacts: []string{ - "bridi(verb(sona), subject(ona), object(ijo_mute)).", - "bridi(verb(sona), subject(ona), object(ilo_mute)).", - "bridi(verb(sona), subject(sina), object(ijo_mute)).", - "bridi(verb(sona), subject(sina), object(ilo_mute)).", - "bridi(verb(sona), subject(mi), object(ijo_mute)).", - "bridi(verb(sona), subject(mi), object(ilo_mute)).", - "bridi(verb(pona), subject(ona), object(ijo_mute)).", - "bridi(verb(pona), subject(ona), object(ilo_mute)).", - "bridi(verb(pona), subject(sina), object(ijo_mute)).", - "bridi(verb(pona), subject(sina), object(ilo_mute)).", - "bridi(verb(pona), subject(mi), object(ijo_mute)).", - "bridi(verb(pona), subject(mi), object(ilo_mute)).", - }, - }, - } - - for _, cs := range cases { - t.Run(cs.name, func(t *testing.T) { - var s tokiponatokens.Sentence - err := json.Unmarshal(cs.json, &s) - if err != nil { - t.Fatal(err) - } - - sb, err := SentenceToBridis(s) - if err != nil { - t.Fatal(err) - } - - if !bridisEqual(cs.want, sb) { - log.Println("want:") - pretty.Println(cs.want) - log.Println("got:") - pretty.Println(sb) - - t.Error("see logs") - } - - var facts []string - for _, s := range sb { - facts = append(facts, s.Fact()) - } - - t.Run("facts", func(t *testing.T) { - if !equal(cs.wantFacts, facts) { - t.Logf("wanted: %v", cs.wantFacts) - t.Logf("got: %v", facts) - t.Error("see -v") - } - }) - }) - } -} diff --git a/cmd/la-baujmi/main.go b/cmd/la-baujmi/main.go deleted file mode 100644 index edc4bff4..00000000 --- a/cmd/la-baujmi/main.go +++ /dev/null @@ -1,88 +0,0 @@ -// Command la-baujmi is a simple language understander for Toki Pona. -package main - -import ( - "flag" - "log" - "os" - "path/filepath" - "strings" - - "github.com/mndrix/golog" - line "github.com/peterh/liner" - "within.website/x/internal" - _ "within.website/x/internal/tokipona" - "within.website/x/web/tokiponatokens" -) - -var ( - historyFname = flag.String("history-file", filepath.Join(os.Getenv("HOME"), ".la-baujmi-history"), "location of history file") -) - -func main() { - internal.HandleStartup() - var m golog.Machine - m = golog.NewMachine() - l := line.NewLiner() - - fin, err := os.Open(*historyFname) - if err == nil { - l.ReadHistory(fin) - fin.Close() - } - - for { - if inp, err := l.Prompt("|toki: "); err == nil { - if inp == "" { - return - } - - l.AppendHistory(inp) - - parts, err := tokiponatokens.Tokenize(tokiPonaAPIURL, inp) - if err != nil { - log.Printf("error: %v", err) - continue - } - - for _, sentence := range parts { - sbs, err := SentenceToBridis(sentence) - if err != nil { - log.Printf("can't derive facts: %v", err) - continue - } - - for _, sb := range sbs { - f := sb.Fact() - - if strings.Contains(inp, "?") { - log.Printf("Query: %s", f) - - solutions := m.ProveAll(f) - for _, solution := range solutions { - log.Println("found", strings.Replace(f, "A", solution.ByName_("A").String(), -1)) - } - - continue - } - - log.Printf("registering fact: %s", f) - m = m.Consult(f) - } - } - } else if err == line.ErrPromptAborted { - log.Print("Aborted") - break - } else { - log.Print("Error reading line: ", err) - break - } - } - - fout, err := os.Create(*historyFname) - if err != nil { - panic(err) - } - l.WriteHistory(fout) - fout.Close() -} diff --git a/cmd/vest-pit-near/main.go b/cmd/vest-pit-near/main.go index 7e1e672f..13ec607b 100644 --- a/cmd/vest-pit-near/main.go +++ b/cmd/vest-pit-near/main.go @@ -7,29 +7,20 @@ import ( "expvar" "flag" "fmt" - "io" - "log" "log/slog" "net/http" - "os" - "path/filepath" "time" - "tailscale.com/hostinfo" - "tailscale.com/tsnet" - "tailscale.com/tsweb" "within.website/x/internal" "within.website/x/internal/yeet" "within.website/x/web/discordwebhook" ) var ( - checkURL = flag.String("check-url", "https://am.i.mullvad.net/json", "connection endpoint to check") - containerNet = flag.String("container", "wireguard", "container to assume the network stack of") - dockerImage = flag.String("docker-image", "ghcr.io/xe/alpine:3.18.2", "docker image to use") - stateDir = flag.String("state-dir", "", "where to store state data") - tsnetHostname = flag.String("tsnet-hostname", "vest-pit-near", "hostname for tsnet") - webhook = flag.String("webhook", "", "Discord webhook URL") + checkURL = flag.String("check-url", "https://am.i.mullvad.net/json", "connection endpoint to check") + containerNet = flag.String("container", "wireguard", "container to assume the network stack of") + dockerImage = flag.String("docker-image", "ghcr.io/xe/alpine:3.18.2", "docker image to use") + webhook = flag.String("webhook", "", "Discord webhook URL") failureCount = expvar.NewInt("vest-pit-near_failure") ) @@ -37,29 +28,7 @@ var ( func main() { internal.HandleStartup() - hostinfo.SetApp("within.website/x/cmd/vest-pit-near") - - os.MkdirAll(filepath.Join(*stateDir, "tsnet"), 0700) - - srv := &tsnet.Server{ - Hostname: *tsnetHostname, - Logf: log.New(io.Discard, "", 0).Printf, - AuthKey: os.Getenv("TS_AUTHKEY"), - Dir: filepath.Join(*stateDir, "tsnet"), - } - - go cron() - - lis, err := srv.Listen("tcp", ":80") - if err != nil { - log.Fatalf("can't listen over tsnet: %v", err) - } - - http.DefaultServeMux.HandleFunc("/metrics", tsweb.VarzHandler) - - defer srv.Close() - defer lis.Close() - log.Fatal(http.Serve(lis, http.DefaultServeMux)) + cron() } func cron() { diff --git a/kube/alrest/core/cert-manager-1pass.yaml b/kube/alrest/core/cert-manager-1pass.yaml new file mode 100644 index 00000000..d1ef67c3 --- /dev/null +++ b/kube/alrest/core/cert-manager-1pass.yaml @@ -0,0 +1,7 @@ +apiVersion: onepassword.com/v1 +kind: OnePasswordItem +metadata: + name: aws-creds + namespace: cert-manager +spec: + itemPath: "vaults/lc5zo4zjz3if3mkeuhufjmgmui/items/3xn7uf73xnzholrfk6tla5rhpa" \ No newline at end of file diff --git a/kube/alrest/core/external-dns/1password.yaml b/kube/alrest/core/external-dns/1password.yaml index edf8e0e3..ead83ea2 100644 --- a/kube/alrest/core/external-dns/1password.yaml +++ b/kube/alrest/core/external-dns/1password.yaml @@ -3,13 +3,5 @@ kind: OnePasswordItem metadata: name: aws-creds namespace: external-dns -spec: - itemPath: "vaults/lc5zo4zjz3if3mkeuhufjmgmui/items/3xn7uf73xnzholrfk6tla5rhpa" ---- -apiVersion: onepassword.com/v1 -kind: OnePasswordItem -metadata: - name: aws-creds - namespace: cert-manager spec: itemPath: "vaults/lc5zo4zjz3if3mkeuhufjmgmui/items/3xn7uf73xnzholrfk6tla5rhpa" \ No newline at end of file diff --git a/kube/alrest/core/kustomization.yaml b/kube/alrest/core/kustomization.yaml index 34d0ca37..94db53f6 100644 --- a/kube/alrest/core/kustomization.yaml +++ b/kube/alrest/core/kustomization.yaml @@ -1,3 +1,4 @@ resources: - external-dns - - nfs-provisioner \ No newline at end of file + - nfs-provisioner + - cert-manager-1pass.yaml \ No newline at end of file diff --git a/kube/alrest/staticsites/caddy1/Dockerfile b/kube/alrest/staticsites/caddy1/Dockerfile deleted file mode 100644 index 92f94432..00000000 --- a/kube/alrest/staticsites/caddy1/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM debian:bookworm AS build - -WORKDIR /app -RUN mkdir -p /app -ADD https://github.com/caddyserver/caddy/releases/download/v1.0.4/caddy_v1.0.4_linux_amd64.tar.gz /app/caddy1.tgz -RUN tar xf /app/caddy1.tgz - -FROM debian:bookworm -LABEL org.opencontainers.image.source="https://github.com/Xe/x" -WORKDIR /app -RUN mkdir -p /app/bin -COPY --from=build /app/caddy /app/bin/caddy -CMD ["/app/bin/caddy", "-port", "8080", "-agree", "-conf", "/app/etc/Caddyfile"] \ No newline at end of file diff --git a/kube/alrest/staticsites/caddy1/Earthfile b/kube/alrest/staticsites/caddy1/Earthfile new file mode 100644 index 00000000..6f961929 --- /dev/null +++ b/kube/alrest/staticsites/caddy1/Earthfile @@ -0,0 +1,32 @@ +VERSION 0.8 +FROM debian:bookworm + +caddy-build: + FROM debian:bookworm + WORKDIR /app + RUN mkdir -p /app + ADD https://github.com/caddyserver/caddy/releases/download/v1.0.4/caddy_v1.0.4_linux_amd64.tar.gz /app/caddy1.tgz + RUN tar xf /app/caddy1.tgz + SAVE ARTIFACT caddy + +caddy: + FROM debian:bookworm + LABEL org.opencontainers.image.source="https://github.com/Xe/x" + WORKDIR /app + RUN mkdir -p /app/bin + COPY +caddy-build/caddy /app/bin/caddy + CMD ["/app/bin/caddy", "-port", "8080", "-agree", "-conf", "/app/etc/Caddyfile"] + + SAVE IMAGE --push ghcr.io/xe/x/caddy1:latest + +git: + FROM debian:bookworm + LABEL org.opencontainers.image.source="https://github.com/Xe/x" + + RUN apt-get update && apt-get install -y git ca-certificates + + SAVE IMAGE --push ghcr.io/xe/x/git:latest + +all: + BUILD --platform=linux/amd64 +caddy + BUILD --platform=linux/amd64 +git \ No newline at end of file diff --git a/kube/alrest/staticsites/caddy1/caddy.yaml b/kube/alrest/staticsites/caddy1/caddy.yaml index 58c25d0e..44a1f23e 100644 --- a/kube/alrest/staticsites/caddy1/caddy.yaml +++ b/kube/alrest/staticsites/caddy1/caddy.yaml @@ -11,6 +11,20 @@ data: root /srv/http/lewa } + graphviz.christine.website:8080 { + tls off + errors stdout + + root /srv/http/graphviz + } + + tulpanomicon.guide:8080 { + tls off + errors stdout + + root /srv/http/tulpanomicon + } + xena.greedo.xeserv.us:8080 { tls off errors stdout @@ -40,6 +54,28 @@ data: template page templates/page.html } } + + when-then-zen.christine.website:8080 { + tls off + errors stdout + + root /srv/http/when-then-zen.christine.website + + internal /README.md + internal /templates + internal /LICENSE + internal /Caddyfile + + ext .md + + browse /bonus + browse /meditation /srv/http/when-then-zen.christine.website/templates/index.html + browse /skills /srv/http/when-then-zen.christine.website/templates/index.html + + markdown / { + #template templates/page.html + } + } --- apiVersion: apps/v1 kind: Deployment @@ -63,12 +99,46 @@ spec: - name: lewa persistentVolumeClaim: claimName: lewa + - name: graphviz + persistentVolumeClaim: + claimName: graphviz - name: greedo persistentVolumeClaim: claimName: xena-greedo-xeserv-us + - name: tulpanomicon + persistentVolumeClaim: + claimName: tulpanomicon - name: xn--u7hz981o persistentVolumeClaim: claimName: xn--u7hz981o + - name: when-then-zen + persistentVolumeClaim: + claimName: when-then-zen + initContainers: + - name: "graphviz" + image: ghcr.io/xe/x/git + volumeMounts: + - mountPath: "/srv/http/graphviz" + name: graphviz + command: + - sh + - "-c" + - | + cd /srv/http/graphviz + git clone https://github.com/dreampuf/GraphvizOnline site ||: + cd site && git pull + - name: "when-then-zen" + image: ghcr.io/xe/x/git + volumeMounts: + - mountPath: "/srv/http/when-then-zen.christine.website" + name: when-then-zen + command: + - sh + - "-c" + - | + cd /srv/http/when-then-zen.christine.website + git clone https://github.com/Xe/when-then-zen site ||: + cd site && git pull containers: - name: caddy image: ghcr.io/xe/x/caddy1 @@ -97,6 +167,14 @@ spec: name: xn--u7hz981o - mountPath: "/srv/http/xena.greedo.xeserv.us" name: greedo + - mountPath: "/srv/http/tulpanomicon" + name: tulpanomicon + - mountPath: "/srv/http/when-then-zen.christine.website" + name: when-then-zen + subPath: site + - mountPath: "/srv/http/graphviz" + name: graphviz + subPath: site --- apiVersion: v1 kind: Service @@ -109,4 +187,3 @@ spec: - port: 80 targetPort: 8080 name: http ---- diff --git a/kube/alrest/staticsites/caddy1/graphviz.yaml b/kube/alrest/staticsites/caddy1/graphviz.yaml new file mode 100644 index 00000000..2c96e2fa --- /dev/null +++ b/kube/alrest/staticsites/caddy1/graphviz.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: graphviz +spec: + storageClassName: "longhorn" + resources: + requests: + storage: 512Mi + volumeMode: Filesystem + accessModes: + - ReadWriteMany +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: graphviz + annotations: + cert-manager.io/cluster-issuer: "letsencrypt-prod" +spec: + ingressClassName: nginx + tls: + - hosts: + - graphviz.christine.website + secretName: graphviz-public-tls + rules: + - host: graphviz.christine.website + http: + paths: + - pathType: Prefix + path: "/" + backend: + service: + name: caddy + port: + name: http \ No newline at end of file diff --git a/kube/alrest/staticsites/caddy1/kustomization.yaml b/kube/alrest/staticsites/caddy1/kustomization.yaml index 8c6c4a8b..67032401 100644 --- a/kube/alrest/staticsites/caddy1/kustomization.yaml +++ b/kube/alrest/staticsites/caddy1/kustomization.yaml @@ -1,5 +1,8 @@ resources: - caddy.yaml + - graphviz.yaml - lewa.yaml + - tulpanomicon.yaml + - when-then-zen.yaml - xena-greedo.yaml - xn--u7hz981o.yaml \ No newline at end of file diff --git a/kube/alrest/staticsites/caddy1/tulpanomicon.yaml b/kube/alrest/staticsites/caddy1/tulpanomicon.yaml new file mode 100644 index 00000000..add8c57e --- /dev/null +++ b/kube/alrest/staticsites/caddy1/tulpanomicon.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: tulpanomicon +spec: + storageClassName: "longhorn" + resources: + requests: + storage: 512Mi + volumeMode: Filesystem + accessModes: + - ReadWriteMany +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: tulpanomicon + annotations: + cert-manager.io/cluster-issuer: "letsencrypt-prod" +spec: + ingressClassName: nginx + tls: + - hosts: + - tulpanomicon.guide + secretName: tulpanomicon-public-tls + rules: + - host: tulpanomicon.guide + http: + paths: + - pathType: Prefix + path: "/" + backend: + service: + name: caddy + port: + name: http \ No newline at end of file diff --git a/kube/alrest/staticsites/caddy1/when-then-zen.yaml b/kube/alrest/staticsites/caddy1/when-then-zen.yaml new file mode 100644 index 00000000..d691beab --- /dev/null +++ b/kube/alrest/staticsites/caddy1/when-then-zen.yaml @@ -0,0 +1,36 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: when-then-zen +spec: + storageClassName: "longhorn" + resources: + requests: + storage: 512Mi + volumeMode: Filesystem + accessModes: + - ReadWriteMany +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: when-then-zen + annotations: + cert-manager.io/cluster-issuer: "letsencrypt-prod" +spec: + ingressClassName: nginx + tls: + - hosts: + - when-then-zen.christine.website + secretName: when-then-zen-public-tls + rules: + - host: when-then-zen.christine.website + http: + paths: + - pathType: Prefix + path: "/" + backend: + service: + name: caddy + port: + name: http \ No newline at end of file diff --git a/web/ollama/ollama.go b/web/ollama/ollama.go index a5c71c3c..8859715f 100644 --- a/web/ollama/ollama.go +++ b/web/ollama/ollama.go @@ -240,23 +240,28 @@ func Hallucinate[T valid.Interface](ctx context.Context, c *Client, opts Halluci } type EmbedRequest struct { - Model string `json:"model"` - Prompt string `json:"prompt"` - - Options map[string]any `json:"options"` + Model string `json:"model"` + Input []string `json:"input"` + Truncate bool `json:"truncate"` + Options map[string]any `json:"options"` + KeepAlive string `json:"keep_alive"` } type EmbedResponse struct { - Embedding []float64 `json:"embedding"` + Embeddings [][]float64 `json:"embedding"` } func (c *Client) Embeddings(ctx context.Context, er *EmbedRequest) (*EmbedResponse, error) { + if er.KeepAlive == "" { + er.KeepAlive = (9999 * time.Minute).String() + } + buf := &bytes.Buffer{} if err := json.NewEncoder(buf).Encode(er); err != nil { return nil, fmt.Errorf("ollama: error encoding request: %w", err) } - req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.baseURL+"/api/embeddings", buf) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.baseURL+"/api/embed", buf) if err != nil { return nil, fmt.Errorf("ollama: error creating request: %w", err) }