Add district to LLM context, be more aggressive about trimming agent:
This commit is contained in:
parent
9914274d42
commit
a42c5824af
2 changed files with 12 additions and 4 deletions
|
|
@ -6,7 +6,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/maruel/genai"
|
||||
//"github.com/rs/zerolog/log"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type Message struct {
|
||||
|
|
@ -45,6 +45,14 @@ func GenerateNextMessage(ctx context.Context, history []Message, _handle_report_
|
|||
if err != nil {
|
||||
return Message{}, fmt.Errorf("Failed to generate next message: %w", err)
|
||||
}
|
||||
trimmed, found := strings.CutPrefix(next.Content, "agent:")
|
||||
if !found {
|
||||
trimmed, found = strings.CutPrefix(next.Content, "Agent:")
|
||||
if !found {
|
||||
log.Warn().Str("content", next.Content).Msg("No 'agent:' prefix on next message")
|
||||
}
|
||||
}
|
||||
next.Content = trimmed
|
||||
|
||||
return next, nil
|
||||
}
|
||||
|
|
@ -63,9 +71,9 @@ func convertHistory(history []Message) genai.Message {
|
|||
)
|
||||
for _, h := range history {
|
||||
if h.IsFromCustomer {
|
||||
sb.WriteString(fmt.Sprintf("\n\ncustomer (%s): %s\n", h.Content))
|
||||
sb.WriteString(fmt.Sprintf("\n\ncustomer: %s\n", h.Content))
|
||||
} else {
|
||||
sb.WriteString(fmt.Sprintf("\n\nagent (%s): %s\n", h.Content))
|
||||
sb.WriteString(fmt.Sprintf("\n\nagent: %s\n", h.Content))
|
||||
}
|
||||
}
|
||||
return genai.NewTextMessage(sb.String())
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ func ensureInDB(ctx context.Context, destination string) (err error) {
|
|||
|
||||
func generateNextMessage(ctx context.Context, history []llm.Message, customer_phone string) (llm.Message, error) {
|
||||
_handle_report_status := func() (string, error) {
|
||||
return "Report: ABCD-1234-5678, Status: scheduled, Appointment: Wednesday 3:30pm", nil
|
||||
return "Report: ABCD-1234-5678, District: Delta MVCD, Status: scheduled, Appointment: Wednesday 3:30pm", nil
|
||||
}
|
||||
_handle_contact_district := func(reason string) {
|
||||
log.Warn().Str("reason", reason).Msg("Contacting district")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue