Revert "Generate connector form based on meta-data (#62)" (#65)

This reverts commit d7cfa7f0b2.
This commit is contained in:
Ettore Di Giacinto
2025-03-20 18:21:19 +01:00
committed by GitHub
parent 1e5b3f501f
commit d54abc3ed0
15 changed files with 77 additions and 629 deletions

View File

@@ -5,7 +5,6 @@ import (
"github.com/bwmarrin/discordgo"
"github.com/mudler/LocalAgent/core/agent"
"github.com/mudler/LocalAgent/pkg/metaform"
"github.com/mudler/LocalAgent/pkg/xlog"
)
@@ -38,27 +37,6 @@ func (d *Discord) AgentReasoningCallback() func(state agent.ActionCurrentState)
}
}
func (d *Discord) ConfigForm() metaform.Form {
return metaform.Form{
Fields: []metaform.Field{
{
Kind: metaform.FieldString,
Name: "token",
Label: "Bot Token",
Required: true,
Placeholder: "Your Discord bot token",
},
{
Kind: metaform.FieldString,
Name: "defaultChannel",
Label: "Default Channel",
Required: true,
Placeholder: "The default channel for the bot to join",
},
},
}
}
func (d *Discord) Start(a *agent.Agent) {
Token := d.token

View File

@@ -7,7 +7,6 @@ import (
"github.com/google/go-github/v69/github"
"github.com/mudler/LocalAgent/core/agent"
"github.com/mudler/LocalAgent/pkg/metaform"
"github.com/mudler/LocalAgent/pkg/xlog"
"github.com/sashabaranov/go-openai"
@@ -64,51 +63,6 @@ func (g *GithubIssues) AgentReasoningCallback() func(state agent.ActionCurrentSt
}
}
func (g *GithubIssues) ConfigForm() metaform.Form {
return metaform.Form{
Fields: []metaform.Field{
{
Kind: metaform.FieldString,
Name: "token",
Label: "GitHub Token",
Required: true,
Placeholder: "Your GitHub personal access token",
},
{
Kind: metaform.FieldString,
Name: "owner",
Label: "Repository Owner",
Required: true,
Placeholder: "username or organization",
},
{
Kind: metaform.FieldString,
Name: "repository",
Label: "Repository Name",
Required: true,
Placeholder: "repo-name",
},
{
Kind: metaform.FieldOptions,
Name: "replyIfNoReplies",
Label: "Reply Behavior",
Required: true,
Options: []metaform.Option{
{Value: "true", Label: "Reply only to issues with no comments"},
{Value: "false", Label: "Reply to all issues"},
},
},
{
Kind: metaform.FieldString,
Name: "pollInterval",
Label: "Poll Interval",
Required: false,
Placeholder: "10m",
},
},
}
}
func (g *GithubIssues) Start(a *agent.Agent) {
// Start the connector
g.agent = a

View File

@@ -7,7 +7,6 @@ import (
"github.com/google/go-github/v69/github"
"github.com/mudler/LocalAgent/core/agent"
"github.com/mudler/LocalAgent/pkg/metaform"
"github.com/mudler/LocalAgent/pkg/xlog"
"github.com/sashabaranov/go-openai"
@@ -64,51 +63,6 @@ func (g *GithubPRs) AgentReasoningCallback() func(state agent.ActionCurrentState
}
}
func (g *GithubPRs) ConfigForm() metaform.Form {
return metaform.Form{
Fields: []metaform.Field{
{
Kind: metaform.FieldString,
Name: "token",
Label: "GitHub Token",
Required: true,
Placeholder: "Your GitHub personal access token",
},
{
Kind: metaform.FieldString,
Name: "owner",
Label: "Repository Owner",
Required: true,
Placeholder: "username or organization",
},
{
Kind: metaform.FieldString,
Name: "repository",
Label: "Repository Name",
Required: true,
Placeholder: "repo-name",
},
{
Kind: metaform.FieldOptions,
Name: "replyIfNoReplies",
Label: "Reply Behavior",
Required: true,
Options: []metaform.Option{
{Value: "true", Label: "Reply only to PRs with no comments"},
{Value: "false", Label: "Reply to all PRs"},
},
},
{
Kind: metaform.FieldString,
Name: "pollInterval",
Label: "Poll Interval",
Required: true,
Placeholder: "10m",
},
},
}
}
func (g *GithubPRs) Start(a *agent.Agent) {
// Start the connector
g.agent = a

View File

@@ -6,7 +6,6 @@ import (
"time"
"github.com/mudler/LocalAgent/core/agent"
"github.com/mudler/LocalAgent/pkg/metaform"
"github.com/mudler/LocalAgent/pkg/xlog"
"github.com/mudler/LocalAgent/services/actions"
irc "github.com/thoj/go-ircevent"
@@ -44,51 +43,6 @@ func (i *IRC) AgentReasoningCallback() func(state agent.ActionCurrentState) bool
}
}
func (i *IRC) ConfigForm() metaform.Form {
return metaform.Form{
Fields: []metaform.Field{
{
Kind: metaform.FieldString,
Name: "server",
Label: "Server",
Required: true,
Placeholder: "chat.freenode.net",
},
{
Kind: metaform.FieldString,
Name: "port",
Label: "Port",
Required: true,
Placeholder: "6667",
},
{
Kind: metaform.FieldString,
Name: "nickname",
Label: "Nickname",
Required: true,
Placeholder: "LocalAgentBot",
},
{
Kind: metaform.FieldString,
Name: "channel",
Label: "Channel",
Required: true,
Placeholder: "#general",
},
{
Kind: metaform.FieldOptions,
Name: "alwaysReply",
Label: "Always Reply",
Required: true,
Options: []metaform.Option{
{Value: "false", Label: "Only when mentioned"},
{Value: "true", Label: "Reply to all messages"},
},
},
},
}
}
// cleanUpUsernameFromMessage removes the bot's nickname from the message
func cleanUpMessage(message string, nickname string) string {
cleaned := strings.ReplaceAll(message, nickname+":", "")

View File

@@ -9,7 +9,6 @@ import (
"os"
"strings"
"github.com/mudler/LocalAgent/pkg/metaform"
"github.com/mudler/LocalAgent/pkg/xlog"
"github.com/mudler/LocalAgent/services/actions"
"github.com/sashabaranov/go-openai"
@@ -53,44 +52,6 @@ func (t *Slack) AgentReasoningCallback() func(state agent.ActionCurrentState) bo
}
}
func (t *Slack) ConfigForm() metaform.Form {
return metaform.Form{
Fields: []metaform.Field{
{
Kind: metaform.FieldString,
Name: "appToken",
Label: "App Token",
Required: true,
Placeholder: "xapp-...",
},
{
Kind: metaform.FieldString,
Name: "botToken",
Label: "Bot Token",
Required: true,
Placeholder: "xoxb-...",
},
{
Kind: metaform.FieldString,
Name: "channelID",
Label: "Channel ID",
Required: false,
Placeholder: "C12345678",
},
{
Kind: metaform.FieldOptions,
Name: "alwaysReply",
Label: "Always Reply",
Required: false,
Options: []metaform.Option{
{Value: "false", Label: "Only when mentioned"},
{Value: "true", Label: "Reply to all messages"},
},
},
},
}
}
func cleanUpUsernameFromMessage(message string, b *slack.AuthTestResponse) string {
cleaned := strings.ReplaceAll(message, "<@"+b.UserID+">", "")
cleaned = strings.ReplaceAll(cleaned, "<@"+b.BotID+">", "")

View File

@@ -9,7 +9,6 @@ import (
"github.com/go-telegram/bot"
"github.com/go-telegram/bot/models"
"github.com/mudler/LocalAgent/core/agent"
"github.com/mudler/LocalAgent/pkg/metaform"
)
type Telegram struct {
@@ -38,20 +37,6 @@ func (t *Telegram) AgentReasoningCallback() func(state agent.ActionCurrentState)
}
}
func (t *Telegram) ConfigForm() metaform.Form {
return metaform.Form{
Fields: []metaform.Field{
{
Kind: metaform.FieldString,
Name: "token",
Label: "Bot Token",
Required: true,
Placeholder: "Your Telegram bot token from @BotFather",
},
},
}
}
func (t *Telegram) Start(a *agent.Agent) {
ctx, cancel := signal.NotifyContext(a.Context(), os.Interrupt)
defer cancel()

View File

@@ -7,7 +7,6 @@ import (
"os/signal"
"github.com/mudler/LocalAgent/core/agent"
"github.com/mudler/LocalAgent/pkg/metaform"
"github.com/mudler/LocalAgent/pkg/xlog"
"github.com/mudler/LocalAgent/services/connectors/twitter"
"github.com/sashabaranov/go-openai"
@@ -33,37 +32,6 @@ func (t *Twitter) AgentReasoningCallback() func(state agent.ActionCurrentState)
}
}
func (t *Twitter) ConfigForm() metaform.Form {
return metaform.Form{
Fields: []metaform.Field{
{
Kind: metaform.FieldString,
Name: "token",
Label: "Token",
Required: true,
Placeholder: "elmo-...",
},
{
Kind: metaform.FieldString,
Name: "botUsername",
Label: "Bot Username",
Required: true,
Placeholder: "Chocolate Pineapple",
},
{
Kind: metaform.FieldOptions,
Name: "noCharacterLimit",
Label: "No Character Limit",
Required: false,
Options: []metaform.Option{
{Value: "false", Label: ""},
{Value: "true", Label: ""},
},
},
},
}
}
func NewTwitterConnector(config map[string]string) (*Twitter, error) {
return &Twitter{
token: config["token"],