feat(github): allow to customize action name
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user