mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-24 03:04:21 +01:00
rework llm
This commit is contained in:
49
internal/llm/tools/tools.go
Normal file
49
internal/llm/tools/tools.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package tools
|
||||
|
||||
import "context"
|
||||
|
||||
type ToolInfo struct {
|
||||
Name string
|
||||
Description string
|
||||
Parameters map[string]any
|
||||
Required []string
|
||||
}
|
||||
|
||||
type toolResponseType string
|
||||
|
||||
const (
|
||||
ToolResponseTypeText toolResponseType = "text"
|
||||
ToolResponseTypeImage toolResponseType = "image"
|
||||
)
|
||||
|
||||
type ToolResponse struct {
|
||||
Type toolResponseType `json:"type"`
|
||||
Content string `json:"content"`
|
||||
IsError bool `json:"is_error"`
|
||||
}
|
||||
|
||||
func NewTextResponse(content string) ToolResponse {
|
||||
return ToolResponse{
|
||||
Type: ToolResponseTypeText,
|
||||
Content: content,
|
||||
}
|
||||
}
|
||||
|
||||
func NewTextErrorResponse(content string) ToolResponse {
|
||||
return ToolResponse{
|
||||
Type: ToolResponseTypeText,
|
||||
Content: content,
|
||||
IsError: true,
|
||||
}
|
||||
}
|
||||
|
||||
type ToolCall struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Input string `json:"input"`
|
||||
}
|
||||
|
||||
type BaseTool interface {
|
||||
Info() ToolInfo
|
||||
Run(ctx context.Context, params ToolCall) (ToolResponse, error)
|
||||
}
|
||||
Reference in New Issue
Block a user