Chore: update readme
This commit is contained in:
@@ -7,9 +7,9 @@ made with use of [tview](https://github.com/rivo/tview)
|
|||||||
- llama.cpp api, deepseek, openrouter (other ones were not tested);
|
- llama.cpp api, deepseek, openrouter (other ones were not tested);
|
||||||
- showing images (not really, for now only if your char card is png it could show it);
|
- showing images (not really, for now only if your char card is png it could show it);
|
||||||
- tts/stt (if whisper.cpp server / fastapi tts server are provided);
|
- tts/stt (if whisper.cpp server / fastapi tts server are provided);
|
||||||
|
- image input;
|
||||||
|
|
||||||
#### does not have/support
|
#### does not have/support
|
||||||
- images; (ctrl+j will show an image of the card you use, but that is about it);
|
|
||||||
- RAG; (RAG was implemented, but I found it unusable and then sql extention broke, so no RAG);
|
- RAG; (RAG was implemented, but I found it unusable and then sql extention broke, so no RAG);
|
||||||
- MCP; (agentic is implemented, but as a raw and predefined functions for llm to use. see [tools.go](https://github.com/GrailFinder/gf-lt/blob/master/tools.go));
|
- MCP; (agentic is implemented, but as a raw and predefined functions for llm to use. see [tools.go](https://github.com/GrailFinder/gf-lt/blob/master/tools.go));
|
||||||
|
|
||||||
@@ -44,8 +44,9 @@ F12: show this help page
|
|||||||
Ctrl+w: resume generation on the last msg
|
Ctrl+w: resume generation on the last msg
|
||||||
Ctrl+s: load new char/agent
|
Ctrl+s: load new char/agent
|
||||||
Ctrl+e: export chat to json file
|
Ctrl+e: export chat to json file
|
||||||
Ctrl+n: start a new chat
|
|
||||||
Ctrl+c: close programm
|
Ctrl+c: close programm
|
||||||
|
Ctrl+n: start a new chat
|
||||||
|
Ctrl+o: open file picker for img input
|
||||||
Ctrl+p: props edit form (min-p, dry, etc.)
|
Ctrl+p: props edit form (min-p, dry, etc.)
|
||||||
Ctrl+v: switch between /completion and /chat api (if provided in config)
|
Ctrl+v: switch between /completion and /chat api (if provided in config)
|
||||||
Ctrl+r: start/stop recording from your microphone (needs stt server)
|
Ctrl+r: start/stop recording from your microphone (needs stt server)
|
||||||
@@ -55,6 +56,7 @@ Ctrl+k: switch tool use (recommend tool use to llm after user msg)
|
|||||||
Ctrl+j: if chat agent is char.png will show the image; then any key to return
|
Ctrl+j: if chat agent is char.png will show the image; then any key to return
|
||||||
Ctrl+a: interrupt tts (needs tts server)
|
Ctrl+a: interrupt tts (needs tts server)
|
||||||
Ctrl+q: cycle through mentioned chars in chat, to pick persona to send next msg as
|
Ctrl+q: cycle through mentioned chars in chat, to pick persona to send next msg as
|
||||||
|
Ctrl+x: cycle through mentioned chars in chat, to pick persona to send next msg as (for llm)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### setting up config
|
#### setting up config
|
||||||
|
|||||||
139
tables.go
139
tables.go
@@ -600,74 +600,29 @@ func makeFilePicker() *tview.Flex {
|
|||||||
listView := tview.NewList()
|
listView := tview.NewList()
|
||||||
listView.SetBorder(true).SetTitle("Files & Directories").SetTitleAlign(tview.AlignLeft)
|
listView.SetBorder(true).SetTitle("Files & Directories").SetTitleAlign(tview.AlignLeft)
|
||||||
|
|
||||||
// Path input field
|
// Status view for selected file information
|
||||||
pathInput := tview.NewInputField().
|
|
||||||
SetLabel("Path: ").
|
|
||||||
SetText(startDir).
|
|
||||||
SetFieldWidth(50)
|
|
||||||
pathInput.SetBorder(true).SetTitle("Enter Path").SetTitleAlign(tview.AlignLeft)
|
|
||||||
|
|
||||||
statusView := tview.NewTextView()
|
statusView := tview.NewTextView()
|
||||||
statusView.SetBorder(true).SetTitle("Selected File").SetTitleAlign(tview.AlignLeft)
|
statusView.SetBorder(true).SetTitle("Selected File").SetTitleAlign(tview.AlignLeft)
|
||||||
statusView.SetTextColor(tcell.ColorYellow)
|
statusView.SetTextColor(tcell.ColorYellow)
|
||||||
|
|
||||||
buttonBar := tview.NewFlex()
|
// Layout - only include list view and status view
|
||||||
|
|
||||||
// Button functions
|
|
||||||
loadButton := tview.NewButton("Load")
|
|
||||||
loadButton.SetSelectedFunc(func() {
|
|
||||||
if selectedFile != "" {
|
|
||||||
// Check if the selected file is an image
|
|
||||||
if isImageFile(selectedFile) {
|
|
||||||
// For image files, set it as an attachment for the next LLM message
|
|
||||||
SetImageAttachment(selectedFile)
|
|
||||||
statusView.SetText("Image attached: " + selectedFile + " (will be sent with next message)")
|
|
||||||
// Close the file picker but don't change the text area
|
|
||||||
pages.RemovePage(filePickerPage)
|
|
||||||
} else {
|
|
||||||
// For non-image files, update the text area with file path
|
|
||||||
textArea.SetText(selectedFile, true)
|
|
||||||
app.SetFocus(textArea)
|
|
||||||
pages.RemovePage(filePickerPage)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// If no file is selected, just close the picker
|
|
||||||
pages.RemovePage(filePickerPage)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
cancelButton := tview.NewButton("Cancel")
|
|
||||||
cancelButton.SetSelectedFunc(func() {
|
|
||||||
pages.RemovePage(filePickerPage)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Path input button - will be updated after refreshList is defined
|
|
||||||
goButton := tview.NewButton("Go")
|
|
||||||
|
|
||||||
buttonBar.AddItem(tview.NewBox().SetBackgroundColor(tcell.ColorDefault), 0, 1, false)
|
|
||||||
buttonBar.AddItem(goButton, 5, 1, true)
|
|
||||||
buttonBar.AddItem(tview.NewBox(), 1, 1, false)
|
|
||||||
buttonBar.AddItem(loadButton, 8, 1, true)
|
|
||||||
buttonBar.AddItem(tview.NewBox(), 1, 1, false)
|
|
||||||
buttonBar.AddItem(cancelButton, 8, 1, true)
|
|
||||||
buttonBar.AddItem(tview.NewBox().SetBackgroundColor(tcell.ColorDefault), 0, 1, false)
|
|
||||||
|
|
||||||
// Layout - add path input field at the top
|
|
||||||
flex := tview.NewFlex().SetDirection(tview.FlexRow)
|
flex := tview.NewFlex().SetDirection(tview.FlexRow)
|
||||||
flex.AddItem(pathInput, 3, 0, false)
|
|
||||||
flex.AddItem(listView, 0, 3, true)
|
flex.AddItem(listView, 0, 3, true)
|
||||||
flex.AddItem(statusView, 3, 0, false)
|
flex.AddItem(statusView, 3, 0, false)
|
||||||
flex.AddItem(buttonBar, 3, 0, false)
|
|
||||||
|
|
||||||
// Refresh the file list
|
// Refresh the file list
|
||||||
var refreshList func(string)
|
var refreshList func(string)
|
||||||
refreshList = func(dir string) {
|
refreshList = func(dir string) {
|
||||||
listView.Clear()
|
listView.Clear()
|
||||||
|
|
||||||
// Update the path input field and current display directory
|
// Update the current display directory
|
||||||
pathInput.SetText(dir)
|
|
||||||
currentDisplayDir = dir // Update the current display directory
|
currentDisplayDir = dir // Update the current display directory
|
||||||
|
|
||||||
|
// Add exit option at the top
|
||||||
|
listView.AddItem("Exit file picker [gray](Close without selecting)[-]", "", 'x', func() {
|
||||||
|
pages.RemovePage(filePickerPage)
|
||||||
|
})
|
||||||
|
|
||||||
// Add parent directory (..) if not at root
|
// Add parent directory (..) if not at root
|
||||||
if dir != "/" {
|
if dir != "/" {
|
||||||
parentDir := path.Dir(dir)
|
parentDir := path.Dir(dir)
|
||||||
@@ -676,7 +631,7 @@ func makeFilePicker() *tview.Flex {
|
|||||||
if parentDir == dir && dir == "/" {
|
if parentDir == dir && dir == "/" {
|
||||||
// We're at the root ("/") and trying to go up, just don't add the parent item
|
// We're at the root ("/") and trying to go up, just don't add the parent item
|
||||||
} else {
|
} else {
|
||||||
listView.AddItem("../", "(Parent Directory)", 'p', func() {
|
listView.AddItem("../ [gray](Parent Directory)[-]", "", 'p', func() {
|
||||||
refreshList(parentDir)
|
refreshList(parentDir)
|
||||||
dirStack = append(dirStack, parentDir)
|
dirStack = append(dirStack, parentDir)
|
||||||
currentStackPos = len(dirStack) - 1
|
currentStackPos = len(dirStack) - 1
|
||||||
@@ -703,7 +658,7 @@ func makeFilePicker() *tview.Flex {
|
|||||||
if file.IsDir() {
|
if file.IsDir() {
|
||||||
// Capture the directory name for the closure to avoid loop variable issues
|
// Capture the directory name for the closure to avoid loop variable issues
|
||||||
dirName := name
|
dirName := name
|
||||||
listView.AddItem(dirName+"/", "(Directory)", 0, func() {
|
listView.AddItem(dirName+"/ [gray](Directory)[-]", "", 0, func() {
|
||||||
newDir := path.Join(dir, dirName)
|
newDir := path.Join(dir, dirName)
|
||||||
refreshList(newDir)
|
refreshList(newDir)
|
||||||
dirStack = append(dirStack, newDir)
|
dirStack = append(dirStack, newDir)
|
||||||
@@ -716,14 +671,14 @@ func makeFilePicker() *tview.Flex {
|
|||||||
// Capture the file name for the closure to avoid loop variable issues
|
// Capture the file name for the closure to avoid loop variable issues
|
||||||
fileName := name
|
fileName := name
|
||||||
fullFilePath := path.Join(dir, fileName)
|
fullFilePath := path.Join(dir, fileName)
|
||||||
listView.AddItem(fileName, "(File)", 0, func() {
|
listView.AddItem(fileName+" [gray](File)[-]", "", 0, func() {
|
||||||
selectedFile = fullFilePath
|
selectedFile = fullFilePath
|
||||||
statusView.SetText("Selected: " + selectedFile)
|
statusView.SetText("Selected: " + selectedFile)
|
||||||
|
|
||||||
// Check if the file is an image
|
// Check if the file is an image
|
||||||
if isImageFile(fileName) {
|
if isImageFile(fileName) {
|
||||||
// For image files, offer to attach to the next LLM message
|
// For image files, offer to attach to the next LLM message
|
||||||
statusView.SetText("Selected image: " + selectedFile + " (Press Load to attach)")
|
statusView.SetText("Selected image: " + selectedFile)
|
||||||
} else {
|
} else {
|
||||||
// For non-image files, display as before
|
// For non-image files, display as before
|
||||||
statusView.SetText("Selected: " + selectedFile)
|
statusView.SetText("Selected: " + selectedFile)
|
||||||
@@ -739,40 +694,6 @@ func makeFilePicker() *tview.Flex {
|
|||||||
// Initialize the file list
|
// Initialize the file list
|
||||||
refreshList(startDir)
|
refreshList(startDir)
|
||||||
|
|
||||||
// Set up keyboard navigation for the path input
|
|
||||||
pathInput.SetDoneFunc(func(key tcell.Key) {
|
|
||||||
if key == tcell.KeyEnter {
|
|
||||||
// Trigger the Go functionality when Enter is pressed in the path input
|
|
||||||
newPath := pathInput.GetText()
|
|
||||||
if newPath != "" {
|
|
||||||
// Check if path exists and is a directory
|
|
||||||
if info, err := os.Stat(newPath); err == nil && info.IsDir() {
|
|
||||||
refreshList(newPath)
|
|
||||||
dirStack = append(dirStack, newPath)
|
|
||||||
currentStackPos = len(dirStack) - 1
|
|
||||||
statusView.SetText("Current: " + newPath)
|
|
||||||
} else {
|
|
||||||
statusView.SetText("Invalid directory: " + newPath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Now that refreshList is defined, set the Go button's functionality
|
|
||||||
goButton.SetSelectedFunc(func() {
|
|
||||||
newPath := pathInput.GetText()
|
|
||||||
if newPath != "" {
|
|
||||||
// Check if path exists and is a directory
|
|
||||||
if info, err := os.Stat(newPath); err == nil && info.IsDir() {
|
|
||||||
refreshList(newPath)
|
|
||||||
dirStack = append(dirStack, newPath)
|
|
||||||
currentStackPos = len(dirStack) - 1
|
|
||||||
statusView.SetText("Current: " + newPath)
|
|
||||||
} else {
|
|
||||||
statusView.SetText("Invalid directory: " + newPath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Set up keyboard navigation
|
// Set up keyboard navigation
|
||||||
flex.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
flex.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
||||||
@@ -799,12 +720,26 @@ func makeFilePicker() *tview.Flex {
|
|||||||
itemText, _ := listView.GetItemText(itemIndex)
|
itemText, _ := listView.GetItemText(itemIndex)
|
||||||
|
|
||||||
logger.Info("choosing dir", "itemText", itemText)
|
logger.Info("choosing dir", "itemText", itemText)
|
||||||
// Check if it's a directory (typically ends with /)
|
|
||||||
if strings.HasSuffix(itemText, "/") {
|
// Check for the exit option first (should be the first item)
|
||||||
|
if strings.HasPrefix(itemText, "Exit file picker") {
|
||||||
|
pages.RemovePage(filePickerPage)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract the actual filename/directory name by removing the type info in brackets
|
||||||
|
// Format is "name [gray](type)[-]"
|
||||||
|
actualItemName := itemText
|
||||||
|
if bracketPos := strings.Index(itemText, " ["); bracketPos != -1 {
|
||||||
|
actualItemName = itemText[:bracketPos]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if it's a directory (ends with /)
|
||||||
|
if strings.HasSuffix(actualItemName, "/") {
|
||||||
// This is a directory, we need to get the full path
|
// This is a directory, we need to get the full path
|
||||||
// Since the item text ends with "/" and represents a directory
|
// Since the item text ends with "/" and represents a directory
|
||||||
var targetDir string
|
var targetDir string
|
||||||
if strings.HasPrefix(itemText, "../") {
|
if strings.HasPrefix(actualItemName, "../") {
|
||||||
// Parent directory - need to go up from current directory
|
// Parent directory - need to go up from current directory
|
||||||
targetDir = path.Dir(currentDisplayDir)
|
targetDir = path.Dir(currentDisplayDir)
|
||||||
// Avoid going above root - if parent is same as current and it's system root
|
// Avoid going above root - if parent is same as current and it's system root
|
||||||
@@ -815,7 +750,7 @@ func makeFilePicker() *tview.Flex {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Regular subdirectory
|
// Regular subdirectory
|
||||||
dirName := strings.TrimSuffix(itemText, "/")
|
dirName := strings.TrimSuffix(actualItemName, "/")
|
||||||
targetDir = path.Join(currentDisplayDir, dirName)
|
targetDir = path.Join(currentDisplayDir, dirName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -827,23 +762,23 @@ func makeFilePicker() *tview.Flex {
|
|||||||
statusView.SetText("Current: " + targetDir)
|
statusView.SetText("Current: " + targetDir)
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
// It's a file - construct the full path from current directory and the item name
|
// It's a file - construct the full path from current directory and the actual item name
|
||||||
// We can't rely only on the selectedFile variable since Enter key might be pressed
|
// We can't rely only on the selectedFile variable since Enter key might be pressed
|
||||||
// without having clicked the file first
|
// without having clicked the file first
|
||||||
filePath := path.Join(currentDisplayDir, itemText)
|
filePath := path.Join(currentDisplayDir, actualItemName)
|
||||||
// Verify it's actually a file (not just lacking a directory suffix)
|
// Verify it's actually a file (not just lacking a directory suffix)
|
||||||
if info, err := os.Stat(filePath); err == nil && !info.IsDir() {
|
if info, err := os.Stat(filePath); err == nil && !info.IsDir() {
|
||||||
// Check if the file is an image
|
// Check if the file is an image
|
||||||
if isImageFile(itemText) {
|
if isImageFile(actualItemName) {
|
||||||
// For image files, set it as an attachment for the next LLM message
|
// For image files, set it as an attachment for the next LLM message
|
||||||
// Use the version without UI updates to avoid hangs in event handlers
|
// Use the version without UI updates to avoid hangs in event handlers
|
||||||
logger.Info("setting image", "file", itemText)
|
logger.Info("setting image", "file", actualItemName)
|
||||||
SetImageAttachment(filePath)
|
SetImageAttachment(filePath)
|
||||||
logger.Info("after setting image", "file", itemText)
|
logger.Info("after setting image", "file", actualItemName)
|
||||||
statusView.SetText("Image attached: " + filePath + " (will be sent with next message)")
|
statusView.SetText("Image attached: " + filePath + " (will be sent with next message)")
|
||||||
logger.Info("after setting text", "file", itemText)
|
logger.Info("after setting text", "file", actualItemName)
|
||||||
pages.RemovePage(filePickerPage)
|
pages.RemovePage(filePickerPage)
|
||||||
logger.Info("after update drawn", "file", itemText)
|
logger.Info("after update drawn", "file", actualItemName)
|
||||||
} else {
|
} else {
|
||||||
// For non-image files, update the text area with file path
|
// For non-image files, update the text area with file path
|
||||||
textArea.SetText(filePath, true)
|
textArea.SetText(filePath, true)
|
||||||
|
|||||||
Reference in New Issue
Block a user