Chore: config update
This commit is contained in:
8
bot.go
8
bot.go
@@ -545,7 +545,13 @@ func charToStart(agentName string) bool {
|
||||
}
|
||||
|
||||
func init() {
|
||||
cfg = config.LoadConfigOrDefault("config.toml")
|
||||
var err error
|
||||
cfg, err = config.LoadConfig("config.toml")
|
||||
if err != nil {
|
||||
fmt.Println("failed to load config.toml")
|
||||
os.Exit(1)
|
||||
return
|
||||
}
|
||||
defaultStarter = []models.RoleMsg{
|
||||
{Role: "system", Content: basicSysMsg},
|
||||
{Role: cfg.AssistantRole, Content: defaultFirstMsg},
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
@@ -68,41 +66,14 @@ type Config struct {
|
||||
FilePickerExts string `toml:"FilePickerExts"`
|
||||
}
|
||||
|
||||
func LoadConfigOrDefault(fn string) *Config {
|
||||
func LoadConfig(fn string) (*Config, error) {
|
||||
if fn == "" {
|
||||
fn = "config.toml"
|
||||
}
|
||||
config := &Config{}
|
||||
_, err := toml.DecodeFile(fn, &config)
|
||||
if err != nil {
|
||||
fmt.Println("failed to read config from file, loading default", "error", err)
|
||||
config.ChatAPI = "http://localhost:8080/v1/chat/completions"
|
||||
config.CompletionAPI = "http://localhost:8080/completion"
|
||||
config.DeepSeekCompletionAPI = "https://api.deepseek.com/beta/completions"
|
||||
config.DeepSeekChatAPI = "https://api.deepseek.com/chat/completions"
|
||||
config.OpenRouterCompletionAPI = "https://openrouter.ai/api/v1/completions"
|
||||
config.OpenRouterChatAPI = "https://openrouter.ai/api/v1/chat/completions"
|
||||
config.RAGEnabled = false
|
||||
config.EmbedURL = "http://localhost:8080/v1/embiddings"
|
||||
config.ShowSys = true
|
||||
config.LogFile = "log.txt"
|
||||
config.UserRole = "user"
|
||||
config.ToolRole = "tool"
|
||||
config.AssistantRole = "assistant"
|
||||
config.SysDir = "sysprompts"
|
||||
config.ChunkLimit = 8192
|
||||
config.DBPATH = "gflt.db"
|
||||
//
|
||||
config.RAGBatchSize = 100
|
||||
config.RAGWordLimit = 80
|
||||
config.RAGWorkers = 5
|
||||
// tts
|
||||
config.TTS_ENABLED = false
|
||||
config.TTS_URL = "http://localhost:8880/v1/audio/speech"
|
||||
config.FetchModelNameAPI = "http://localhost:8080/v1/models"
|
||||
config.STT_SR = 16000
|
||||
config.FilePickerDir = "." // Default to current directory
|
||||
config.FilePickerExts = "png,jpg,jpeg,gif,webp" // Default allowed extensions
|
||||
return nil, err
|
||||
}
|
||||
config.CurrentAPI = config.ChatAPI
|
||||
config.APIMap = map[string]string{
|
||||
@@ -119,5 +90,5 @@ func LoadConfigOrDefault(fn string) *Config {
|
||||
}
|
||||
}
|
||||
// if any value is empty fill with default
|
||||
return config
|
||||
return config, nil
|
||||
}
|
||||
|
||||
54
tools.go
54
tools.go
@@ -81,32 +81,6 @@ After that you are free to respond to the user.
|
||||
sysLabels = []string{"basic_sys", "tool_sys"}
|
||||
)
|
||||
|
||||
// func populateTools(cfg config.Config) {
|
||||
// // if we have access to some server with funcs we can populate funcs (tools|toolbelt?) with it
|
||||
// // there must be a better way
|
||||
// if cfg.SearchAPI == "" || cfg.SearchDescribe == "" {
|
||||
// return
|
||||
// }
|
||||
// resp, err := httpClient.Get(cfg.SearchDescribe)
|
||||
// if err != nil {
|
||||
// logger.Error("failed to get websearch tool description",
|
||||
// "link", cfg.SearchDescribe, "error", err)
|
||||
// return
|
||||
// }
|
||||
// defer resp.Body.Close()
|
||||
// descResp := models.Tool{}
|
||||
// if err := json.NewDecoder(resp.Body).Decode(&descResp); err != nil {
|
||||
// logger.Error("failed to unmarshal websearch tool description",
|
||||
// "link", cfg.SearchDescribe, "error", err)
|
||||
// return
|
||||
// }
|
||||
// fnMap["web_search"] = websearch
|
||||
// baseTools = append(baseTools, descResp)
|
||||
// logger.Info("added web_search tool", "tool", descResp)
|
||||
// }
|
||||
|
||||
// {"type":"function","function":{"name":"web_search","description":"Perform a web search to find information on varioust topics","parameters":{"type":"object","properties":{"num_results":{"type":"integer","description":"Maximum number of results to return (default: 10)"},"query":{"type":"string","description":"The search query to find information about"},"search_type":{"type":"string","description":"Type of search to perform: 'api' for SearXNG API search or 'scraper' for web scraping (default: 'scraper')"}},"required":["query"]}}}
|
||||
|
||||
// web search (depends on extra server)
|
||||
func websearch(args map[string]string) []byte {
|
||||
// make http request return bytes
|
||||
@@ -126,32 +100,6 @@ func websearch(args map[string]string) []byte {
|
||||
"limit_arg", limitS, "error", err)
|
||||
limit = 3
|
||||
}
|
||||
// // external
|
||||
// payload, err := json.Marshal(args)
|
||||
// if err != nil {
|
||||
// logger.Error("failed to marshal web_search arguments", "error", err)
|
||||
// msg := fmt.Sprintf("failed to marshal web_search arguments; error: %s\n", err)
|
||||
// return []byte(msg)
|
||||
// }
|
||||
// req, err := http.NewRequest("POST", cfg.SearchAPI, bytes.NewReader(payload))
|
||||
// if err != nil {
|
||||
// logger.Error("failed to build an http request", "error", err)
|
||||
// msg := fmt.Sprintf("failed to build an http request; error: %s\n", err)
|
||||
// return []byte(msg)
|
||||
// }
|
||||
// resp, err := httpClient.Do(req)
|
||||
// if err != nil {
|
||||
// logger.Error("failed to execute http request", "error", err)
|
||||
// msg := fmt.Sprintf("failed to execute http request; error: %s\n", err)
|
||||
// return []byte(msg)
|
||||
// }
|
||||
// defer resp.Body.Close()
|
||||
// data, err := io.ReadAll(resp.Body)
|
||||
// if err != nil {
|
||||
// logger.Error("failed to read response body", "error", err)
|
||||
// msg := fmt.Sprintf("failed to read response body; error: %s\n", err)
|
||||
// return []byte(msg)
|
||||
// }
|
||||
resp, err := extra.WebSearcher.Search(context.Background(), query, limit)
|
||||
if err != nil {
|
||||
msg := "search tool failed; error: " + err.Error()
|
||||
@@ -223,8 +171,6 @@ func recallTopics(args map[string]string) []byte {
|
||||
return []byte(joinedS)
|
||||
}
|
||||
|
||||
// func fullMemoryLoad() {}
|
||||
|
||||
type fnSig func(map[string]string) []byte
|
||||
|
||||
var fnMap = map[string]fnSig{
|
||||
|
||||
Reference in New Issue
Block a user