Files
memoryweave/go/internal/api/server_storage_windows.go
T
xiaowei 2a350cf781 fix(distill): max_tokens 800→1200 — Agnes推理token预算不足
Agnes 2.0-flash是推理模型,推理token占大量预算。
800仍不够→JSON截断(parse error: unexpected end of JSON input)。
1200确保推理+正文都够用。
2026-08-20 01:13:06 +08:00

65 lines
2.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//go:build windows
// 织忆 MemoryWeave — 存储+图谱初始化(Windows,纯 Go 无 CGO)
package api
import (
"log"
"os"
"runtime"
"github.com/xiaoxue/memoryweave/internal/governance"
"github.com/xiaoxue/memoryweave/internal/storage"
)
// initStorageBackend 初始化存储后端(Windows:SQLiteMemClient 持久化 + 内存向量)
func initStorageBackend(backend string, emb *storage.Embedder) storage.LanceDB {
// Windows 默认:优先 SQLite 持久化
if backend == "" && runtime.GOOS == "windows" {
backend = "sqlite_persist"
}
switch backend {
case "sqlite", "sqlite_persist":
dbPath := os.Getenv("SQLITE_PATH")
if dbPath == "" {
dbPath = "C:\\Users\\Administrator\\.zhiyi\\zhiyi.db"
}
os.MkdirAll("C:\\Users\\Administrator\\.zhiyi", 0755)
sc, err := storage.NewSQLiteMemClient(dbPath, emb)
if err != nil {
log.Printf("[zhiyid] SQLiteMemClient 初始化失败 (%v),降级为内存", err)
return storage.NewMemLanceClient(emb)
}
log.Printf("[zhiyid] 存储后端: SQLiteMemClient (pure Go) — %s", dbPath)
return sc
case "lancedb":
sockPath := os.Getenv("LANCEDB_SOCKET")
if sockPath == "" {
sockPath = "/tmp/zhiyi-ipc.sock"
}
ldb := storage.NewRustLanceDBClient(sockPath, emb)
log.Printf("[zhiyid] 存储后端: LanceDB (Rust IPC) — %s", sockPath)
return ldb
default:
log.Printf("[zhiyid] 存储后端: SQLiteMemClient (pure Go, default) — C:\\Users\\Administrator\\.zhiyi\\zhiyi.db")
dbPath := "C:\\Users\\Administrator\\.zhiyi\\zhiyi.db"
os.MkdirAll("C:\\Users\\Administrator\\.zhiyi", 0755)
sc, err := storage.NewSQLiteMemClient(dbPath, emb)
if err != nil {
log.Printf("[zhiyid] SQLiteMemClient fallback 失败 (%v),降级为内存", err)
return storage.NewMemLanceClient(emb)
}
return sc
}
}
// initGraphStore 初始化图谱(Windows:仅内存图谱)
func initGraphStore() governance.GraphStore {
graphPath := os.Getenv("GRAPH_PATH")
if graphPath == "" {
graphPath = "C:\\Users\\Administrator\\.zhiyi\\graph.db"
}
log.Printf("[zhiyid] 图谱后端: InMemoryGraph (Windows,纯 Go 无 SQLite CGO)")
return governance.NewInMemoryGraph()
}