feat(call_agents): merge metadata of results (#126)
* feat(call_agents): merge metadata of results Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * chore: correct env typo Signed-off-by: Ettore Di Giacinto <mudler@localai.io> * Update services/actions/callagents.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: add icon to thinking --------- Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
53d135bec9
commit
e90c192063
@@ -86,7 +86,7 @@ Access your agents at `http://localhost:3000`
|
||||
| `LOCALAGENT_MODEL` | Your go-to model |
|
||||
| `LOCALAGENT_MULTIMODAL_MODEL` | Optional model for multimodal capabilities |
|
||||
| `LOCALAGENT_LLM_API_URL` | OpenAI-compatible API server URL |
|
||||
| `LOCALAGENT_API_KEY` | API authentication |
|
||||
| `LOCALAGENT_LLM_API_KEY` | API authentication |
|
||||
| `LOCALAGENT_TIMEOUT` | Request timeout settings |
|
||||
| `LOCALAGENT_STATE_DIR` | Where state gets stored |
|
||||
| `LOCALAGENT_LOCALRAG_URL` | LocalRAG connection |
|
||||
|
||||
@@ -67,7 +67,7 @@ services:
|
||||
environment:
|
||||
- LOCALAGENT_MODEL=mlabonne_gemma-3-27b-it-abliterated
|
||||
- LOCALAGENT_LLM_API_URL=http://localai:8080
|
||||
- LOCALAGENT_API_KEY=sk-1234567890
|
||||
- LOCALAGENT_LLM_API_KEY=sk-1234567890
|
||||
- LOCALAGENT_LOCALRAG_URL=http://ragserver:8080
|
||||
- LOCALAGENT_STATE_DIR=/pool
|
||||
- LOCALAGENT_TIMEOUT=5m
|
||||
|
||||
@@ -65,7 +65,7 @@ services:
|
||||
environment:
|
||||
- LOCALAGENT_MODEL=arcee-agent
|
||||
- LOCALAGENT_LLM_API_URL=http://localai:8080
|
||||
- LOCALAGENT_API_KEY=sk-1234567890
|
||||
- LOCALAGENT_LLM_API_KEY=sk-1234567890
|
||||
- LOCALAGENT_LOCALRAG_URL=http://ragserver:8080
|
||||
- LOCALAGENT_STATE_DIR=/pool
|
||||
- LOCALAGENT_TIMEOUT=5m
|
||||
|
||||
2
main.go
2
main.go
@@ -14,7 +14,7 @@ import (
|
||||
var testModel = os.Getenv("LOCALAGENT_MODEL")
|
||||
var multimodalModel = os.Getenv("LOCALAGENT_MULTIMODAL_MODEL")
|
||||
var apiURL = os.Getenv("LOCALAGENT_LLM_API_URL")
|
||||
var apiKey = os.Getenv("LOCALAGENT_API_KEY")
|
||||
var apiKey = os.Getenv("LOCALAGENT_LLM_API_KEY")
|
||||
var timeout = os.Getenv("LOCALAGENT_TIMEOUT")
|
||||
var stateDir = os.Getenv("LOCALAGENT_STATE_DIR")
|
||||
var localRAG = os.Getenv("LOCALAGENT_LOCALRAG_URL")
|
||||
|
||||
@@ -53,7 +53,34 @@ func (a *CallAgentAction) Run(ctx context.Context, params types.ActionParams) (t
|
||||
return types.ActionResult{}, err
|
||||
}
|
||||
|
||||
return types.ActionResult{Result: resp.Response}, nil
|
||||
metadata := make(map[string]interface{})
|
||||
|
||||
for _, s := range resp.State {
|
||||
for k, v := range s.Metadata {
|
||||
if existingValue, ok := metadata[k]; ok {
|
||||
switch existingValue := existingValue.(type) {
|
||||
case []string:
|
||||
switch v := v.(type) {
|
||||
case []string:
|
||||
metadata[k] = append(existingValue, v...)
|
||||
case string:
|
||||
metadata[k] = append(existingValue, v)
|
||||
}
|
||||
case string:
|
||||
switch v := v.(type) {
|
||||
case []string:
|
||||
metadata[k] = append([]string{existingValue}, v...)
|
||||
case string:
|
||||
metadata[k] = []string{existingValue, v}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
metadata[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return types.ActionResult{Result: resp.Response, Metadata: metadata}, nil
|
||||
}
|
||||
|
||||
func (a *CallAgentAction) Definition() types.ActionDefinition {
|
||||
|
||||
@@ -45,7 +45,7 @@ type Slack struct {
|
||||
conversationTracker *ConversationTracker[string]
|
||||
}
|
||||
|
||||
const thinkingMessage = "thinking..."
|
||||
const thinkingMessage = ":hourglass: thinking..."
|
||||
|
||||
func NewSlack(config map[string]string) *Slack {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user