Chore: solving TODOs
This commit is contained in:
14
bot.go
14
bot.go
@@ -85,19 +85,17 @@ func createClient(connectTimeout time.Duration) *http.Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetchModelName() *models.LLMModels {
|
func fetchLCPModelName() *models.LLMModels {
|
||||||
// TODO: to config
|
|
||||||
api := "http://localhost:8080/v1/models"
|
|
||||||
//nolint
|
//nolint
|
||||||
resp, err := httpClient.Get(api)
|
resp, err := httpClient.Get(cfg.FetchModelNameAPI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warn("failed to get model", "link", api, "error", err)
|
logger.Warn("failed to get model", "link", cfg.FetchModelNameAPI, "error", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
llmModel := models.LLMModels{}
|
llmModel := models.LLMModels{}
|
||||||
if err := json.NewDecoder(resp.Body).Decode(&llmModel); err != nil {
|
if err := json.NewDecoder(resp.Body).Decode(&llmModel); err != nil {
|
||||||
logger.Warn("failed to decode resp", "link", api, "error", err)
|
logger.Warn("failed to decode resp", "link", cfg.FetchModelNameAPI, "error", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
@@ -272,7 +270,7 @@ func chatRagUse(qText string) (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
// TODO: this where llm should find the questions in text and ask them
|
// this where llm should find the questions in text and ask them
|
||||||
questionsS := tokenizer.Tokenize(qText)
|
questionsS := tokenizer.Tokenize(qText)
|
||||||
questions := make([]string, len(questionsS))
|
questions := make([]string, len(questionsS))
|
||||||
for i, q := range questionsS {
|
for i, q := range questionsS {
|
||||||
@@ -525,7 +523,7 @@ func applyCharCard(cc *models.CharCard) {
|
|||||||
}
|
}
|
||||||
history, err := loadAgentsLastChat(cfg.AssistantRole)
|
history, err := loadAgentsLastChat(cfg.AssistantRole)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: too much action for err != nil; loadAgentsLastChat needs to be split up
|
// too much action for err != nil; loadAgentsLastChat needs to be split up
|
||||||
logger.Warn("failed to load last agent chat;", "agent", cc.Role, "err", err)
|
logger.Warn("failed to load last agent chat;", "agent", cc.Role, "err", err)
|
||||||
history = []models.RoleMsg{
|
history = []models.RoleMsg{
|
||||||
{Role: "system", Content: cc.SysPrompt},
|
{Role: "system", Content: cc.SysPrompt},
|
||||||
|
|||||||
@@ -22,3 +22,4 @@ TTS_SPEED = 1.0
|
|||||||
STT_ENABLED = false
|
STT_ENABLED = false
|
||||||
STT_URL = "http://localhost:8081/inference"
|
STT_URL = "http://localhost:8081/inference"
|
||||||
DBPATH = "gflt.db"
|
DBPATH = "gflt.db"
|
||||||
|
FetchModelNameAPI = "http://localhost:8080/v1/models"
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
EnableCluedo bool `toml:"EnableCluedo"` // Cluedo game mode toggle
|
EnableCluedo bool `toml:"EnableCluedo"` // Cluedo game mode toggle
|
||||||
CluedoRole2 string `toml:"CluedoRole2"` // Secondary AI role name
|
CluedoRole2 string `toml:"CluedoRole2"` // Secondary AI role name
|
||||||
ChatAPI string `toml:"ChatAPI"`
|
ChatAPI string `toml:"ChatAPI"`
|
||||||
CompletionAPI string `toml:"CompletionAPI"`
|
CompletionAPI string `toml:"CompletionAPI"`
|
||||||
CurrentAPI string
|
CurrentAPI string
|
||||||
CurrentProvider string
|
CurrentProvider string
|
||||||
APIMap map[string]string
|
APIMap map[string]string
|
||||||
|
FetchModelNameAPI string `toml:"FetchModelNameAPI"`
|
||||||
//
|
//
|
||||||
ShowSys bool `toml:"ShowSys"`
|
ShowSys bool `toml:"ShowSys"`
|
||||||
LogFile string `toml:"LogFile"`
|
LogFile string `toml:"LogFile"`
|
||||||
@@ -88,6 +89,7 @@ func LoadConfigOrDefault(fn string) *Config {
|
|||||||
// tts
|
// tts
|
||||||
config.TTS_ENABLED = false
|
config.TTS_ENABLED = false
|
||||||
config.TTS_URL = "http://localhost:8880/v1/audio/speech"
|
config.TTS_URL = "http://localhost:8880/v1/audio/speech"
|
||||||
|
config.FetchModelNameAPI = "http://localhost:8080/v1/models"
|
||||||
}
|
}
|
||||||
config.CurrentAPI = config.ChatAPI
|
config.CurrentAPI = config.ChatAPI
|
||||||
config.APIMap = map[string]string{
|
config.APIMap = map[string]string{
|
||||||
|
|||||||
7
llm.go
7
llm.go
@@ -104,12 +104,7 @@ func (lcp LlamaCPPeer) FormMsg(msg, role string, resume bool) (io.Reader, error)
|
|||||||
}
|
}
|
||||||
logger.Debug("checking prompt for /completion", "tool_use", cfg.ToolUse,
|
logger.Debug("checking prompt for /completion", "tool_use", cfg.ToolUse,
|
||||||
"msg", msg, "resume", resume, "prompt", prompt)
|
"msg", msg, "resume", resume, "prompt", prompt)
|
||||||
var payload any
|
payload := models.NewLCPReq(prompt, defaultLCPProps, chatBody.MakeStopSlice())
|
||||||
payload = models.NewLCPReq(prompt, defaultLCPProps, chatBody.MakeStopSlice())
|
|
||||||
if strings.Contains(chatBody.Model, "deepseek") { // TODO: why?
|
|
||||||
payload = models.NewDSCompletionReq(prompt, chatBody.Model,
|
|
||||||
defaultLCPProps["temp"], chatBody.MakeStopSlice())
|
|
||||||
}
|
|
||||||
data, err := json.Marshal(payload)
|
data, err := json.Marshal(payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("failed to form a msg", "error", err)
|
logger.Error("failed to form a msg", "error", err)
|
||||||
|
|||||||
@@ -5,11 +5,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// type FuncCall struct {
|
|
||||||
// Name string `json:"name"`
|
|
||||||
// Args []string `json:"args"`
|
|
||||||
// }
|
|
||||||
|
|
||||||
type FuncCall struct {
|
type FuncCall struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Args map[string]string `json:"args"`
|
Args map[string]string `json:"args"`
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gf-lt/config"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"gf-lt/config"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -61,7 +61,7 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func modelHandler(w http.ResponseWriter, req *http.Request) {
|
func modelHandler(w http.ResponseWriter, req *http.Request) {
|
||||||
llmModel := fetchModelName()
|
llmModel := fetchLCPModelName()
|
||||||
payload, err := json.Marshal(llmModel)
|
payload, err := json.Marshal(llmModel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("model handler", "error", err)
|
logger.Error("model handler", "error", err)
|
||||||
|
|||||||
8
tui.go
8
tui.go
@@ -735,7 +735,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
if event.Key() == tcell.KeyCtrlL {
|
if event.Key() == tcell.KeyCtrlL {
|
||||||
go func() {
|
go func() {
|
||||||
fetchModelName() // blocks
|
fetchLCPModelName() // blocks
|
||||||
updateStatusLine()
|
updateStatusLine()
|
||||||
}()
|
}()
|
||||||
return nil
|
return nil
|
||||||
@@ -756,10 +756,6 @@ func init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
cfg.CurrentAPI = newAPI
|
cfg.CurrentAPI = newAPI
|
||||||
// // TODO: implement model pick
|
|
||||||
// if strings.Contains(cfg.CurrentAPI, "deepseek") {
|
|
||||||
// chatBody.Model = "deepseek-chat"
|
|
||||||
// }
|
|
||||||
choseChunkParser()
|
choseChunkParser()
|
||||||
updateStatusLine()
|
updateStatusLine()
|
||||||
return nil
|
return nil
|
||||||
@@ -793,7 +789,7 @@ func init() {
|
|||||||
pages.AddPage(imgPage, imgView, true, true)
|
pages.AddPage(imgPage, imgView, true, true)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// TODO: move to menu or table
|
// DEPRECATED: rag is deprecated until I change my mind
|
||||||
// if event.Key() == tcell.KeyCtrlR && cfg.HFToken != "" {
|
// if event.Key() == tcell.KeyCtrlR && cfg.HFToken != "" {
|
||||||
// // rag load
|
// // rag load
|
||||||
// // menu of the text files from defined rag directory
|
// // menu of the text files from defined rag directory
|
||||||
|
|||||||
Reference in New Issue
Block a user