(transform func(string) string)
| 145 | } |
| 146 | |
| 147 | func createLocalAgent(transform func(string) string) (*agent.LocalAgent, error) { |
| 148 | processFunc := func(ctx context.Context, conversationID string, execID string, start *proto.AgentStart, e agent.Executor, handler agent.OutputHandler) error { |
| 149 | for _, msg := range start.Messages { |
| 150 | content := msg.GetContent() |
| 151 | if content == nil { |
| 152 | continue |
| 153 | } |
| 154 | textContent := content.GetText() |
| 155 | if textContent == nil { |
| 156 | continue |
| 157 | } |
| 158 | if err := handler(&proto.AgentOutputs{ |
| 159 | Messages: []*proto.Message{ |
| 160 | { |
| 161 | Role: "assistant", |
| 162 | Content: &proto.Content{ |
| 163 | Type: &proto.Content_Text{ |
| 164 | Text: &proto.TextContent{ |
| 165 | Text: transform(textContent.Text), |
| 166 | }, |
| 167 | }, |
| 168 | }, |
| 169 | }, |
| 170 | }, |
| 171 | }); err != nil { |
| 172 | return err |
| 173 | } |
| 174 | } |
| 175 | return nil |
| 176 | } |
| 177 | |
| 178 | return agent.NewLocalAgent(agent.LocalAgentConfig{ |
| 179 | ProcessFunc: processFunc, |
| 180 | }) |
| 181 | } |
| 182 | |
| 183 | type mockPlanner struct{} |
| 184 |
no test coverage detected