* Fix fmt
This commit is contained in:
parent
2b9e74007f
commit
cadf39c9ef
7 changed files with 33 additions and 23 deletions
|
|
@ -137,7 +137,9 @@ func (t *CronTool) addJob(args map[string]any) *common.ToolResult {
|
||||||
t.mu.RUnlock()
|
t.mu.RUnlock()
|
||||||
|
|
||||||
if channel == "" || chatID == "" {
|
if channel == "" || chatID == "" {
|
||||||
return common.ErrorResult("no session context (channel/chat_id not set). Use this tool in an active conversation.")
|
return common.ErrorResult(
|
||||||
|
"no session context (channel/chat_id not set). Use this tool in an active conversation.",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
message, ok := args["message"].(string)
|
message, ok := args["message"].(string)
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,9 @@ func (t *I2CTool) scan(args map[string]any) *common.ToolResult {
|
||||||
devPath := fmt.Sprintf("/dev/i2c-%s", bus)
|
devPath := fmt.Sprintf("/dev/i2c-%s", bus)
|
||||||
fd, err := syscall.Open(devPath, syscall.O_RDWR, 0)
|
fd, err := syscall.Open(devPath, syscall.O_RDWR, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.ErrorResult(fmt.Sprintf("failed to open %s: %v (check permissions and i2c-dev module)", devPath, err))
|
return common.ErrorResult(
|
||||||
|
fmt.Sprintf("failed to open %s: %v (check permissions and i2c-dev module)", devPath, err),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
defer syscall.Close(fd)
|
defer syscall.Close(fd)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,9 @@ type spiTransfer struct {
|
||||||
func configureSPI(devPath string, mode uint8, bits uint8, speed uint32) (int, *common.ToolResult) {
|
func configureSPI(devPath string, mode uint8, bits uint8, speed uint32) (int, *common.ToolResult) {
|
||||||
fd, err := syscall.Open(devPath, syscall.O_RDWR, 0)
|
fd, err := syscall.Open(devPath, syscall.O_RDWR, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, common.ErrorResult(fmt.Sprintf("failed to open %s: %v (check permissions and spidev module)", devPath, err))
|
return -1, common.ErrorResult(
|
||||||
|
fmt.Sprintf("failed to open %s: %v (check permissions and spidev module)", devPath, err),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set SPI mode
|
// Set SPI mode
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,16 @@ import (
|
||||||
"github.com/sipeed/picoclaw/pkg/tools/common"
|
"github.com/sipeed/picoclaw/pkg/tools/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Tool = common.Tool
|
type (
|
||||||
type ToolResult = common.ToolResult
|
Tool = common.Tool
|
||||||
type ContextualTool = common.ContextualTool
|
ToolResult = common.ToolResult
|
||||||
type AsyncTool = common.AsyncTool
|
ContextualTool = common.ContextualTool
|
||||||
type AsyncCallback = common.AsyncCallback
|
AsyncTool = common.AsyncTool
|
||||||
type FileSystem = common.FileSystem
|
AsyncCallback = common.AsyncCallback
|
||||||
type HostFs = common.HostFs
|
FileSystem = common.FileSystem
|
||||||
type SandboxFs = common.SandboxFs
|
HostFs = common.HostFs
|
||||||
|
SandboxFs = common.SandboxFs
|
||||||
|
)
|
||||||
|
|
||||||
func NewToolResult(forLLM string) *ToolResult {
|
func NewToolResult(forLLM string) *ToolResult {
|
||||||
return common.NewToolResult(forLLM)
|
return common.NewToolResult(forLLM)
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,13 @@ package web_fetch
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/sipeed/picoclaw/pkg/tools/common"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/sipeed/picoclaw/pkg/tools/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestWebTool_WebFetch_Success verifies successful URL fetching
|
// TestWebTool_WebFetch_Success verifies successful URL fetching
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,16 @@ package write_file
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"github.com/sipeed/picoclaw/pkg/tools/list_dir"
|
|
||||||
"github.com/sipeed/picoclaw/pkg/tools/read_file"
|
|
||||||
"github.com/sipeed/picoclaw/pkg/tools/common"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
|
"github.com/sipeed/picoclaw/pkg/tools/common"
|
||||||
|
"github.com/sipeed/picoclaw/pkg/tools/list_dir"
|
||||||
|
"github.com/sipeed/picoclaw/pkg/tools/read_file"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestFilesystemTool_ReadFile_Success verifies successful file reading
|
// TestFilesystemTool_ReadFile_Success verifies successful file reading
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue