Enha: update config; create ragdir if does not exist
This commit is contained in:
@@ -1,7 +1,15 @@
|
|||||||
ChatAPI = "http://localhost:8080/v1/chat/completions"
|
ChatAPI = "http://localhost:8080/v1/chat/completions"
|
||||||
CompletionAPI = "http://localhost:8080/completion"
|
CompletionAPI = "http://localhost:8080/completion"
|
||||||
|
FetchModelNameAPI = "http://localhost:8080/v1/models"
|
||||||
|
# in case you have deepseek token
|
||||||
|
DeepSeekCompletionAPI = "https://api.deepseek.com/beta/completions"
|
||||||
|
DeepSeekChatAPI = "https://api.deepseek.com/chat/completions"
|
||||||
|
DeepSeekModel = "deepseek-reasoner"
|
||||||
|
# DeepSeekToken = ""
|
||||||
|
# in case you have opentouter token
|
||||||
OpenRouterCompletionAPI = "https://openrouter.ai/api/v1/completions"
|
OpenRouterCompletionAPI = "https://openrouter.ai/api/v1/completions"
|
||||||
OpenRouterChatAPI = "https://openrouter.ai/api/v1/chat/completions"
|
OpenRouterChatAPI = "https://openrouter.ai/api/v1/chat/completions"
|
||||||
|
# OpenRouterToken = ""
|
||||||
EmbedURL = "http://localhost:8080/v1/embeddings"
|
EmbedURL = "http://localhost:8080/v1/embeddings"
|
||||||
ShowSys = true
|
ShowSys = true
|
||||||
LogFile = "log.txt"
|
LogFile = "log.txt"
|
||||||
@@ -11,9 +19,9 @@ AssistantRole = "assistant"
|
|||||||
SysDir = "sysprompts"
|
SysDir = "sysprompts"
|
||||||
ChunkLimit = 100000
|
ChunkLimit = 100000
|
||||||
# rag settings
|
# rag settings
|
||||||
RAGBatchSize = 100
|
RAGBatchSize = 10
|
||||||
RAGWordLimit = 80
|
RAGWordLimit = 80
|
||||||
RAGWorkers = 5
|
RAGWorkers = 2
|
||||||
RAGDir = "ragimport"
|
RAGDir = "ragimport"
|
||||||
# extra tts
|
# extra tts
|
||||||
TTS_ENABLED = false
|
TTS_ENABLED = false
|
||||||
@@ -30,8 +38,3 @@ STT_SR = 16000 # Sample rate for audio recording
|
|||||||
DBPATH = "gflt.db"
|
DBPATH = "gflt.db"
|
||||||
FilePickerDir = "." # Directory where file picker should start
|
FilePickerDir = "." # Directory where file picker should start
|
||||||
FilePickerExts = "png,jpg,jpeg,gif,webp" # Comma-separated list of allowed file extensions for file picker
|
FilePickerExts = "png,jpg,jpeg,gif,webp" # Comma-separated list of allowed file extensions for file picker
|
||||||
#
|
|
||||||
FetchModelNameAPI = "http://localhost:8080/v1/models"
|
|
||||||
# external search tool
|
|
||||||
SearchAPI = "" # url to call the tool by
|
|
||||||
SearchDescribe = "" # link that returns models.Tool
|
|
||||||
|
|||||||
22
tui.go
22
tui.go
@@ -926,12 +926,34 @@ func init() {
|
|||||||
// menu of the text files from defined rag directory
|
// menu of the text files from defined rag directory
|
||||||
files, err := os.ReadDir(cfg.RAGDir)
|
files, err := os.ReadDir(cfg.RAGDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// Check if the error is because the directory doesn't exist
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
// Create the RAG directory if it doesn't exist
|
||||||
|
if mkdirErr := os.MkdirAll(cfg.RAGDir, 0755); mkdirErr != nil {
|
||||||
|
logger.Error("failed to create RAG directory", "dir", cfg.RAGDir, "error", mkdirErr)
|
||||||
|
if notifyerr := notifyUser("failed to create RAG directory", mkdirErr.Error()); notifyerr != nil {
|
||||||
|
logger.Error("failed to send notification", "error", notifyerr)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// Now try to read the directory again after creating it
|
||||||
|
files, err = os.ReadDir(cfg.RAGDir)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("failed to read dir after creating it", "dir", cfg.RAGDir, "error", err)
|
||||||
|
if notifyerr := notifyUser("failed to read RAG directory", err.Error()); notifyerr != nil {
|
||||||
|
logger.Error("failed to send notification", "error", notifyerr)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Other error (permissions, etc.)
|
||||||
logger.Error("failed to read dir", "dir", cfg.RAGDir, "error", err)
|
logger.Error("failed to read dir", "dir", cfg.RAGDir, "error", err)
|
||||||
if notifyerr := notifyUser("failed to open RAG files dir", err.Error()); notifyerr != nil {
|
if notifyerr := notifyUser("failed to open RAG files dir", err.Error()); notifyerr != nil {
|
||||||
logger.Error("failed to send notification", "error", notifyerr)
|
logger.Error("failed to send notification", "error", notifyerr)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fileList := []string{}
|
fileList := []string{}
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
if f.IsDir() {
|
if f.IsDir() {
|
||||||
|
|||||||
Reference in New Issue
Block a user