1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-09-09 01:09:54 +00:00

github tool

This commit is contained in:
Laura
2025-08-25 18:37:30 +02:00
parent b44da19987
commit 908fdb2e93
9 changed files with 307 additions and 7 deletions

View File

@@ -19,6 +19,11 @@ type FetchContentsArguments struct {
URLs []string `json:"urls"`
}
type GitHubRepositoryArguments struct {
Owner string `json:"owner"`
Repo string `json:"repo"`
}
func GetSearchTools() []openrouter.Tool {
return []openrouter.Tool{
{
@@ -66,6 +71,29 @@ func GetSearchTools() []openrouter.Tool {
Strict: true,
},
},
{
Type: openrouter.ToolTypeFunction,
Function: &openrouter.FunctionDefinition{
Name: "github_repository",
Description: "Get a quick overview of a GitHub repository without cloning: repo info, up to 20 branches (popular first), top-level files/dirs, and the README.",
Parameters: map[string]any{
"type": "object",
"required": []string{"owner", "repo"},
"properties": map[string]any{
"owner": map[string]any{
"type": "string",
"description": "GitHub username or organization (e.g., 'torvalds').",
},
"repo": map[string]any{
"type": "string",
"description": "Repository name (e.g., 'linux').",
},
},
"additionalProperties": false,
},
Strict: true,
},
},
}
}
@@ -128,3 +156,23 @@ func HandleFetchContentsTool(ctx context.Context, tool *ToolCall) error {
return nil
}
func HandleGitHubRepositoryTool(ctx context.Context, tool *ToolCall) error {
var arguments GitHubRepositoryArguments
err := json.Unmarshal([]byte(tool.Args), &arguments)
if err != nil {
return err
}
result, err := RepoOverview(ctx, arguments)
if err != nil {
tool.Result = fmt.Sprintf("error: %v", err)
return nil
}
tool.Result = result
return nil
}