Skip to content

Commit 4a3ee02

Browse files
committed
chore: cleanup
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent d804ef6 commit 4a3ee02

3 files changed

Lines changed: 58 additions & 209 deletions

File tree

pkg/localoperator/client.go

Lines changed: 0 additions & 149 deletions
This file was deleted.

services/connectors/slack.go

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"sync"
1212

1313
"github.com/mudler/LocalAGI/pkg/config"
14-
"github.com/mudler/LocalAGI/pkg/localoperator"
1514
"github.com/mudler/LocalAGI/pkg/xstrings"
1615
"github.com/mudler/LocalAGI/services/actions"
1716
"github.com/mudler/xlog"
@@ -153,34 +152,34 @@ func replaceUserIDsWithNamesInMessage(api *slack.Client, message string) string
153152
func generateAttachmentsFromJobResponse(j *types.JobResult, api *slack.Client, channelID, ts string) (attachments []slack.Attachment) {
154153
for _, state := range j.State {
155154
// coming from the browser agent
156-
if history, exists := state.Metadata[actions.MetadataBrowserAgentHistory]; exists {
157-
if historyStruct, ok := history.(*localoperator.StateHistory); ok {
158-
state := historyStruct.States[len(historyStruct.States)-1]
159-
// Decode base64 screenshot and upload to Slack
160-
if state.Screenshot != "" {
161-
screenshotData, err := base64.StdEncoding.DecodeString(state.Screenshot)
162-
if err != nil {
163-
xlog.Error(fmt.Sprintf("Error decoding screenshot: %v", err))
164-
continue
165-
}
166-
167-
data := string(screenshotData)
168-
// Upload the file to Slack
169-
_, err = api.UploadFileV2(slack.UploadFileV2Parameters{
170-
Reader: bytes.NewReader(screenshotData),
171-
FileSize: len(data),
172-
ThreadTimestamp: ts,
173-
Channel: channelID,
174-
Filename: "screenshot.png",
175-
InitialComment: "Browser Agent Screenshot",
176-
})
177-
if err != nil {
178-
xlog.Error(fmt.Sprintf("Error uploading screenshot: %v", err))
179-
continue
180-
}
181-
}
182-
}
183-
}
155+
// if history, exists := state.Metadata[actions.MetadataBrowserAgentHistory]; exists {
156+
// if historyStruct, ok := history.(*localoperator.StateHistory); ok {
157+
// state := historyStruct.States[len(historyStruct.States)-1]
158+
// // Decode base64 screenshot and upload to Slack
159+
// if state.Screenshot != "" {
160+
// screenshotData, err := base64.StdEncoding.DecodeString(state.Screenshot)
161+
// if err != nil {
162+
// xlog.Error(fmt.Sprintf("Error decoding screenshot: %v", err))
163+
// continue
164+
// }
165+
166+
// data := string(screenshotData)
167+
// // Upload the file to Slack
168+
// _, err = api.UploadFileV2(slack.UploadFileV2Parameters{
169+
// Reader: bytes.NewReader(screenshotData),
170+
// FileSize: len(data),
171+
// ThreadTimestamp: ts,
172+
// Channel: channelID,
173+
// Filename: "screenshot.png",
174+
// InitialComment: "Browser Agent Screenshot",
175+
// })
176+
// if err != nil {
177+
// xlog.Error(fmt.Sprintf("Error uploading screenshot: %v", err))
178+
// continue
179+
// }
180+
// }
181+
// }
182+
// }
184183

185184
// coming from the search action
186185
if urls, exists := state.Metadata[actions.MetadataUrls]; exists {
@@ -219,11 +218,11 @@ func generateAttachmentsFromJobResponse(j *types.JobResult, api *slack.Client, c
219218
filename = "audio"
220219
}
221220
_, err = api.UploadFileV2(slack.UploadFileV2Parameters{
222-
Reader: bytes.NewReader(data),
223-
FileSize: len(data),
221+
Reader: bytes.NewReader(data),
222+
FileSize: len(data),
224223
ThreadTimestamp: ts,
225-
Channel: channelID,
226-
Filename: filename,
224+
Channel: channelID,
225+
Filename: filename,
227226
InitialComment: "Generated song",
228227
})
229228
if err != nil {

services/connectors/telegram.go

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"github.com/mudler/LocalAGI/core/agent"
2222
"github.com/mudler/LocalAGI/core/types"
2323
"github.com/mudler/LocalAGI/pkg/config"
24-
"github.com/mudler/LocalAGI/pkg/localoperator"
2524
"github.com/mudler/LocalAGI/pkg/xstrings"
2625
"github.com/mudler/LocalAGI/services/actions"
2726
"github.com/mudler/xlog"
@@ -591,32 +590,32 @@ func (t *Telegram) handleMultimediaContent(ctx context.Context, chatID int64, re
591590
}
592591

593592
// Handle browser agent screenshots
594-
if history, exists := state.Metadata[actions.MetadataBrowserAgentHistory]; exists {
595-
if historyStruct, ok := history.(*localoperator.StateHistory); ok {
596-
state := historyStruct.States[len(historyStruct.States)-1]
597-
if state.Screenshot != "" {
598-
// Decode base64 screenshot
599-
screenshotData, err := base64.StdEncoding.DecodeString(state.Screenshot)
600-
if err != nil {
601-
xlog.Error("Error decoding screenshot", "error", err)
602-
continue
603-
}
604-
605-
// Send screenshot with caption
606-
_, err = t.bot.SendPhoto(ctx, &bot.SendPhotoParams{
607-
ChatID: chatID,
608-
Photo: &models.InputFileUpload{
609-
Filename: "screenshot.png",
610-
Data: bytes.NewReader(screenshotData),
611-
},
612-
Caption: "Browser Agent Screenshot",
613-
})
614-
if err != nil {
615-
xlog.Error("Error sending screenshot", "error", err)
616-
}
617-
}
618-
}
619-
}
593+
// if history, exists := state.Metadata[actions.MetadataBrowserAgentHistory]; exists {
594+
// if historyStruct, ok := history.(*localoperator.StateHistory); ok {
595+
// state := historyStruct.States[len(historyStruct.States)-1]
596+
// if state.Screenshot != "" {
597+
// // Decode base64 screenshot
598+
// screenshotData, err := base64.StdEncoding.DecodeString(state.Screenshot)
599+
// if err != nil {
600+
// xlog.Error("Error decoding screenshot", "error", err)
601+
// continue
602+
// }
603+
604+
// // Send screenshot with caption
605+
// _, err = t.bot.SendPhoto(ctx, &bot.SendPhotoParams{
606+
// ChatID: chatID,
607+
// Photo: &models.InputFileUpload{
608+
// Filename: "screenshot.png",
609+
// Data: bytes.NewReader(screenshotData),
610+
// },
611+
// Caption: "Browser Agent Screenshot",
612+
// })
613+
// if err != nil {
614+
// xlog.Error("Error sending screenshot", "error", err)
615+
// }
616+
// }
617+
// }
618+
// }
620619
}
621620

622621
return urls, nil

0 commit comments

Comments
 (0)