Begin process of getting text responses from an LLM.

This commit is contained in:
Eli Ribble 2026-01-26 20:29:04 +00:00
parent c276cbac0b
commit 6070d50a58
No known key found for this signature in database
18 changed files with 639 additions and 22 deletions

View file

@ -68,12 +68,13 @@ func ensureInDB(ctx context.Context, destination string) (err error) {
return nil
}
func insertTextLog(ctx context.Context, content string, destination string, source string, origin enums.CommsTextorigin) (err error) {
func insertTextLog(ctx context.Context, content string, destination string, source string, origin enums.CommsTextorigin, is_welcome bool) (err error) {
_, err = models.CommsTextLogs.Insert(&models.CommsTextLogSetter{
//ID:
Content: omit.From(content),
Created: omit.From(time.Now()),
Destination: omit.From(destination),
IsWelcome: omit.From(is_welcome),
Origin: omit.From(origin),
Source: omit.From(source),
}).One(ctx, db.PGInstance.BobDB)

View file

@ -23,9 +23,15 @@ func ensureInitialText(ctx context.Context, src string, dst string) error {
return nil
}
content := "Welcome to Report Mosquitoes Online. We received your request and want to confirm text updates. Reply YES to continue. Reply STOP at any time to unsubscribe"
err = sendText(ctx, src, dst, content, origin)
err = sendText(ctx, src, dst, content, origin, true)
if err != nil {
return fmt.Errorf("Failed to send initial confirmation: %w", err)
}
return nil
}
func SendInitialReprompt(ctx context.Context, src string, dst string) error {
content := "I have to start with either 'YES' or 'STOP' first, Which do you want?"
err := sendText(ctx, src, dst, content, enums.CommsTextoriginLLM, false)
return err
}

9
comms/text/llm.go Normal file
View file

@ -0,0 +1,9 @@
package text
import (
"github.com/rs/zerolog/log"
)
func SendTextFromLLM(content string) {
log.Info().Str("content", content).Msg("Pretend I sent a message")
}

View file

@ -53,7 +53,7 @@ func sendReportSubscription(ctx context.Context, job Job) error {
return fmt.Errorf("Failed to check if subscribed: %w", err)
}
if !sub {
err = sendText(ctx, j.source(), j.destination(), j.content(), enums.CommsTextoriginWebsiteAction)
err = sendText(ctx, j.source(), j.destination(), j.content(), enums.CommsTextoriginWebsiteAction, false)
if err != nil {
return fmt.Errorf("Failed to send report subscription confirmation: %w", err)
}

View file

@ -19,12 +19,12 @@ func ParsePhoneNumber(input string) (*E164, error) {
return phonenumbers.Parse(input, "US")
}
func sendText(ctx context.Context, source string, destination string, message string, origin enums.CommsTextorigin) error {
func sendText(ctx context.Context, source string, destination string, message string, origin enums.CommsTextorigin, is_welcome bool) error {
err := ensureInDB(ctx, destination)
if err != nil {
return fmt.Errorf("Failed to ensure text message destination is in the DB: %w", err)
}
err = insertTextLog(ctx, message, destination, source, origin)
err = insertTextLog(ctx, message, destination, source, origin, is_welcome)
if err != nil {
return fmt.Errorf("Failed to insert text message in the DB: %w", err)
}