Enhance logging
This commit is contained in:
@@ -82,10 +82,13 @@ func New(opts ...Option) (*Agent, error) {
|
|||||||
// xlog = xlog.New(h)
|
// xlog = xlog.New(h)
|
||||||
//programLevel.Set(a.options.logLevel)
|
//programLevel.Set(a.options.logLevel)
|
||||||
|
|
||||||
xlog.Info("Agent in Debug mode", "agent", a.Character.Name)
|
xlog.Info(
|
||||||
xlog.Info("Character", "agent", a.Character.Name, "character", a.Character.String())
|
"Agent created",
|
||||||
xlog.Info("State", "agent", a.Character.Name, "state", a.State().String())
|
"agent", a.Character.Name,
|
||||||
xlog.Info("Permanent goal", "agent", a.Character.Name, "goal", a.options.permanentGoal)
|
"character", a.Character.String(),
|
||||||
|
"state", a.State().String(),
|
||||||
|
"goal", a.options.permanentGoal,
|
||||||
|
)
|
||||||
|
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,14 +37,11 @@ func (a *AgentConfig) availableActions(ctx context.Context) []Action {
|
|||||||
actions := []Action{}
|
actions := []Action{}
|
||||||
|
|
||||||
for _, action := range a.Actions {
|
for _, action := range a.Actions {
|
||||||
xlog.Info("Set Action", action)
|
|
||||||
|
|
||||||
var config map[string]string
|
var config map[string]string
|
||||||
if err := json.Unmarshal([]byte(action.Config), &config); err != nil {
|
if err := json.Unmarshal([]byte(action.Config), &config); err != nil {
|
||||||
xlog.Info("Error unmarshalling action config", err)
|
xlog.Info("Error unmarshalling action config", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
xlog.Info("Config", config)
|
|
||||||
|
|
||||||
switch action.Name {
|
switch action.Name {
|
||||||
case ActionSearch:
|
case ActionSearch:
|
||||||
|
|||||||
@@ -141,15 +141,28 @@ func (a *AgentPool) startAgentWithConfig(name string, config *AgentConfig) error
|
|||||||
|
|
||||||
connectors := config.availableConnectors()
|
connectors := config.availableConnectors()
|
||||||
|
|
||||||
xlog.Info("Creating agent", name)
|
|
||||||
xlog.Info("Model", model)
|
|
||||||
xlog.Info("API URL", a.apiURL)
|
|
||||||
|
|
||||||
actions := config.availableActions(ctx)
|
actions := config.availableActions(ctx)
|
||||||
|
|
||||||
stateFile, characterFile := a.stateFiles(name)
|
stateFile, characterFile := a.stateFiles(name)
|
||||||
|
|
||||||
xlog.Info("Actions", actions)
|
actionsLog := []string{}
|
||||||
|
for _, action := range actions {
|
||||||
|
actionsLog = append(actionsLog, action.Definition().Name.String())
|
||||||
|
}
|
||||||
|
connectorLog := []string{}
|
||||||
|
for _, connector := range connectors {
|
||||||
|
connectorLog = append(connectorLog, fmt.Sprintf("%+v", connector))
|
||||||
|
}
|
||||||
|
|
||||||
|
xlog.Info(
|
||||||
|
"Creating agent",
|
||||||
|
"name", name,
|
||||||
|
"model", model,
|
||||||
|
"api_url", a.apiURL,
|
||||||
|
"actions", actionsLog,
|
||||||
|
"connectors", connectorLog,
|
||||||
|
)
|
||||||
|
|
||||||
opts := []Option{
|
opts := []Option{
|
||||||
WithModel(model),
|
WithModel(model),
|
||||||
WithLLMAPIURL(a.apiURL),
|
WithLLMAPIURL(a.apiURL),
|
||||||
|
|||||||
@@ -35,15 +35,11 @@ func (a *AgentConfig) availableConnectors() []Connector {
|
|||||||
connectors := []Connector{}
|
connectors := []Connector{}
|
||||||
|
|
||||||
for _, c := range a.Connector {
|
for _, c := range a.Connector {
|
||||||
xlog.Info("Set Connector", c)
|
|
||||||
|
|
||||||
var config map[string]string
|
var config map[string]string
|
||||||
if err := json.Unmarshal([]byte(c.Config), &config); err != nil {
|
if err := json.Unmarshal([]byte(c.Config), &config); err != nil {
|
||||||
xlog.Info("Error unmarshalling connector config", err)
|
xlog.Info("Error unmarshalling connector config", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
xlog.Info("Config", config)
|
|
||||||
|
|
||||||
switch c.Type {
|
switch c.Type {
|
||||||
case ConnectorTelegram:
|
case ConnectorTelegram:
|
||||||
cc, err := connector.NewTelegramConnector(config)
|
cc, err := connector.NewTelegramConnector(config)
|
||||||
|
|||||||
Reference in New Issue
Block a user