fead: no idea
This commit is contained in:
1 parent
a65d39cea0
commit
57bcd549d1
3 files changed
+13
-4
No files matched your search
@@ -31,7 +31,7 @@ func newEmbedder(apiKey, model, baseURL string) *embedder {
|
|||||||
return &embedder{
|
return &embedder{
|
||||||
apiKey: apiKey,
|
apiKey: apiKey,
|
||||||
model: model,
|
model: model,
|
||||||
baseURL: strings.TrimRight(baseURL, "/"),
|
baseURL: strings.TrimSuffix(strings.TrimRight(baseURL, "/"), "/v1"),
|
||||||
httpClient: &http.Client{
|
httpClient: &http.Client{
|
||||||
Timeout: 30 * time.Second,
|
Timeout: 30 * time.Second,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -101,6 +101,12 @@
|
|||||||
description = "Username of the admin user created at bootstrap.";
|
description = "Username of the admin user created at bootstrap.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
searchEngine = lib.mkOption {
|
||||||
|
type = lib.types.enum [ "qdrant" "fts5" ];
|
||||||
|
default = "qdrant";
|
||||||
|
description = "Search engine backend. 'fts5' uses SQLite full-text search, 'qdrant' uses Qdrant vector search.";
|
||||||
|
};
|
||||||
|
|
||||||
sqlitePath = lib.mkOption {
|
sqlitePath = lib.mkOption {
|
||||||
type = lib.types.path;
|
type = lib.types.path;
|
||||||
default = "/var/lib/st-pierre/st-pierre.sqlite";
|
default = "/var/lib/st-pierre/st-pierre.sqlite";
|
||||||
@@ -152,6 +158,7 @@
|
|||||||
QDRANT_TLS = if cfg.qdrantTls then "true" else "false";
|
QDRANT_TLS = if cfg.qdrantTls then "true" else "false";
|
||||||
EMBEDDING_BASE_URL = cfg.embeddingBaseUrl;
|
EMBEDDING_BASE_URL = cfg.embeddingBaseUrl;
|
||||||
EMBEDDING_MODEL = cfg.embeddingModel;
|
EMBEDDING_MODEL = cfg.embeddingModel;
|
||||||
|
SEARCH_ENGINE = cfg.searchEngine;
|
||||||
SQLITE_PATH = builtins.toString cfg.sqlitePath;
|
SQLITE_PATH = builtins.toString cfg.sqlitePath;
|
||||||
GIT_COMMIT = gitHash;
|
GIT_COMMIT = gitHash;
|
||||||
BUILD_DATE = lastUpdated;
|
BUILD_DATE = lastUpdated;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer logger.Sync()
|
defer logger.Sync()
|
||||||
|
|
||||||
openAIKey := requireEnv(logger, "OPENAI_API_KEY")
|
openAIKey := os.Getenv("OPENAI_API_KEY")
|
||||||
port := envOrDefault("PORT", "8080")
|
port := envOrDefault("PORT", "8080")
|
||||||
|
|
||||||
sqlitePath := envOrDefault("SQLITE_PATH", "flashcard.db")
|
sqlitePath := envOrDefault("SQLITE_PATH", "flashcard.db")
|
||||||
@@ -164,8 +164,10 @@ func main() {
|
|||||||
|
|
||||||
func createSearchEngine(logger *zap.Logger, sqliteStore *sqliteStore, openAIKey string) SearchEngine {
|
func createSearchEngine(logger *zap.Logger, sqliteStore *sqliteStore, openAIKey string) SearchEngine {
|
||||||
qdrantURL := os.Getenv("QDRANT_URL")
|
qdrantURL := os.Getenv("QDRANT_URL")
|
||||||
if qdrantURL == "" {
|
searchEngine := os.Getenv("SEARCH_ENGINE")
|
||||||
logger.Warn("QDRANT_URL not set, using SQLite FTS5 for search")
|
|
||||||
|
if searchEngine == "fts5" || qdrantURL == "" {
|
||||||
|
logger.Info("using SQLite FTS5 for search", zap.String("engine", searchEngine))
|
||||||
return newFTS5Engine(sqliteStore)
|
return newFTS5Engine(sqliteStore)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user