return metadatas and conversations in job results. Consume them in Slack connector to use attachments in responses
This commit is contained in:
@@ -9,6 +9,10 @@ import (
|
||||
"github.com/sashabaranov/go-openai/jsonschema"
|
||||
)
|
||||
|
||||
const (
|
||||
MetadataImages = "images_url"
|
||||
)
|
||||
|
||||
func NewGenImage(config map[string]string) *GenImageAction {
|
||||
defaultConfig := openai.DefaultConfig(config["apiKey"])
|
||||
defaultConfig.BaseURL = config["apiURL"]
|
||||
@@ -65,7 +69,7 @@ func (a *GenImageAction) Run(ctx context.Context, params action.ActionParams) (a
|
||||
|
||||
return action.ActionResult{
|
||||
Result: fmt.Sprintf("The image was generated and available at: %s", resp.Data[0].URL), Metadata: map[string]interface{}{
|
||||
"url": resp.Data[0].URL,
|
||||
MetadataImages: []string{resp.Data[0].URL},
|
||||
}}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,11 @@ import (
|
||||
"github.com/mudler/LocalAgent/core/action"
|
||||
"github.com/sashabaranov/go-openai/jsonschema"
|
||||
"github.com/tmc/langchaingo/tools/duckduckgo"
|
||||
"mvdan.cc/xurls/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
MetadataUrls = "urls"
|
||||
)
|
||||
|
||||
func NewSearch(config map[string]string) *SearchAction {
|
||||
@@ -50,7 +55,11 @@ func (a *SearchAction) Run(ctx context.Context, params action.ActionParams) (act
|
||||
|
||||
return action.ActionResult{}, err
|
||||
}
|
||||
return action.ActionResult{Result: res}, nil
|
||||
|
||||
rxStrict := xurls.Strict()
|
||||
urls := rxStrict.FindAllString(res, -1)
|
||||
|
||||
return action.ActionResult{Result: res, Metadata: map[string]interface{}{MetadataUrls: urls}}, nil
|
||||
}
|
||||
|
||||
func (a *SearchAction) Definition() action.ActionDefinition {
|
||||
|
||||
Reference in New Issue
Block a user