feat(github): allow to customize action name

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto
2025-03-12 22:15:52 +01:00
parent c69ee9e5f7
commit 10f7c8ff13
4 changed files with 62 additions and 42 deletions

View File

@@ -11,20 +11,21 @@ import (
)
type GithubIssueSearch struct {
token, repository, owner string
context context.Context
client *github.Client
token, repository, owner, customActionName string
context context.Context
client *github.Client
}
func NewGithubIssueSearch(ctx context.Context, config map[string]string) *GithubIssueSearch {
client := github.NewClient(nil).WithAuthToken(config["token"])
return &GithubIssueSearch{
client: client,
token: config["token"],
repository: config["repository"],
owner: config["owner"],
context: ctx,
client: client,
token: config["token"],
repository: config["repository"],
owner: config["owner"],
customActionName: config["customActionName"],
context: ctx,
}
}
@@ -68,9 +69,13 @@ func (g *GithubIssueSearch) Run(ctx context.Context, params action.ActionParams)
}
func (g *GithubIssueSearch) Definition() action.ActionDefinition {
actionName := "search_github_issue"
if g.customActionName != "" {
actionName = g.customActionName
}
if g.repository != "" && g.owner != "" {
return action.ActionDefinition{
Name: "search_github_issue",
Name: action.ActionDefinitionName(actionName),
Description: "Search between github issues",
Properties: map[string]jsonschema.Definition{
"query": {
@@ -82,7 +87,7 @@ func (g *GithubIssueSearch) Definition() action.ActionDefinition {
}
}
return action.ActionDefinition{
Name: "search_github_issue",
Name: action.ActionDefinitionName(actionName),
Description: "Search between github issues",
Properties: map[string]jsonschema.Definition{
"query": {