she does not look herself up (V-555)
Two defects found probing the new source on the box. "кто ты" was answered from one of his notes. The self source sat below memory and notes, which match by proximity and have no idea the subject is her. It belongs above all three: a question about her has no answer in his data either. And PhraseQuery opens every answer with "вот что я нашла: ", which is deliberate — it marks the answer as a lookup. Her own description is the one subject she did not look up, so this is PhraseSelf instead, same read-only discipline and its own opener. The Stub reads the description out as it stands, which needs no fallback: it is already her voice.
This commit is contained in:
@@ -941,6 +941,36 @@ func (p *LLMPhraser) knowledgePrompt(utterance string) (sys, user string) {
|
||||
fmt.Sprintf("Пользователь спрашивает: \"%s\".", utterance)
|
||||
}
|
||||
|
||||
// PhraseSelf answers a question about her from her own description. Same
|
||||
// discipline as the evidence branch — say only what the text says — and a
|
||||
// different opener, because "вот что я нашла: я — твоя помощница" says she
|
||||
// looked herself up (Vikunja #555). She did not; this is the one subject she
|
||||
// does not have to read about.
|
||||
//
|
||||
// On any error it reads the description out rather than ship a fragment. That
|
||||
// is already a readable answer, which is why this needs no separate fallback.
|
||||
func (p *LLMPhraser) PhraseSelf(ctx context.Context, utterance, description string) (string, error) {
|
||||
sys := persona.Prepend(p.cfg.ContextBlock,
|
||||
"Он спрашивает о тебе. Отвечай ТОЛЬКО по описанию, которое тебе дали: всё, что ты говоришь о себе, должно быть в нём. "+
|
||||
"Не добавляй умений, которых там нет, и не догадывайся. Не начинай с \"вот что я нашла\" — ты говоришь о себе, а не о находке. "+
|
||||
"Отвечай по-русски, коротко и своими словами. О себе — в женском роде, глаголы в прошедшем времени с окончанием -ла. "+
|
||||
"Он мужчина, обращайся к нему на \"ты\". Отвечай ТОЛЬКО одним объектом JSON: {\"response\": \"...\", \"mood\": \"neutral\"}.")
|
||||
prompt := fmt.Sprintf("Он спрашивает: %q\n\nТвоё описание:\n%s\n\nОтветь ему на то, что он спросил.", utterance, description)
|
||||
resp, err := p.chatWithSystem(ctx, sys, prompt, 768)
|
||||
text, _, perr := parseResponseMood(resp)
|
||||
if err != nil || perr != nil {
|
||||
cause := err
|
||||
if cause == nil {
|
||||
cause = perr
|
||||
}
|
||||
return description, fmt.Errorf("phrase self: %w", cause)
|
||||
}
|
||||
if text != "" {
|
||||
return text, nil
|
||||
}
|
||||
return description, nil
|
||||
}
|
||||
|
||||
// evidencePrompt — the sources branch: read these, add nothing. Shared with
|
||||
// PhraseWorld for the same reason as knowledgePrompt.
|
||||
func (p *LLMPhraser) evidencePrompt(utterance string, notes []string) (sys, user string) {
|
||||
|
||||
@@ -49,6 +49,9 @@ type Phraser interface {
|
||||
PhraseNudge(ctx context.Context, c loop.Candidate) (delivery.PhrasedNudge, error)
|
||||
PhraseReminder(ctx context.Context, d loop.ReminderDecision) (delivery.PhrasedReminder, error)
|
||||
PhraseQuery(ctx context.Context, utterance string, notes []string) (string, error)
|
||||
// PhraseSelf answers a question about her from her own description, which
|
||||
// is not a source she read and must not be phrased as one (Vikunja #555).
|
||||
PhraseSelf(ctx context.Context, utterance, description string) (string, error)
|
||||
PhraseChat(ctx context.Context, utterance string, history []dialogue.Turn) (string, error)
|
||||
Close() error
|
||||
}
|
||||
@@ -81,6 +84,13 @@ func (s *Stub) PhraseQuery(_ context.Context, _ string, notes []string) (string,
|
||||
return SourcesFallback(strings.Join(notes, "; ")), nil
|
||||
}
|
||||
|
||||
// PhraseSelf reads the description out as it stands. There is nothing to fall
|
||||
// back to and nothing to shorten: the text is already written in her voice, and
|
||||
// that is the whole reason it is a constant rather than a prompt.
|
||||
func (s *Stub) PhraseSelf(_ context.Context, _, description string) (string, error) {
|
||||
return description, nil
|
||||
}
|
||||
|
||||
// Close implements Phraser.Close (no-op for the stub).
|
||||
func (s *Stub) Close() error { return nil }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user