1
0
mirror of https://github.com/fumiama/yamaih.git synced 2026-06-05 00:10:28 +08:00
Files
yamaih/gemini.go
2025-03-30 20:37:25 +09:00

38 lines
659 B
Go

package yamaih
import (
"net/http"
"sync"
sql "github.com/FloatTech/sqlite"
)
const api = "https://generativelanguage.googleapis.com"
type Gemini struct {
dbmu sync.Mutex
endpoint string
apiver string // apiver usually v1beta
logdb sql.Sqlite
mux *http.ServeMux
}
func NewGemini(endpoint, logfile, apiver string) *Gemini {
g := &Gemini{
endpoint: endpoint,
apiver: apiver,
logdb: sql.New(logfile),
mux: http.NewServeMux(),
}
err := g.initdb()
if err != nil {
panic(err)
}
g.mux.HandleFunc("/", g.handler)
return g
}
func (g *Gemini) RunBlocking() error {
return http.ListenAndServe(g.endpoint, g.mux)
}