Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/added-18393-betty-voice-web.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Meetings: Betty answers from the web through a self-hosted SearXNG (`meetings.persona.searxng_url`), speaks when asked aloud (a quick acknowledgement, then a two-sentence answer), digs into questions she cannot answer and reports back once, answers on Anthropic-only hives through the Messages API, ignores everyday uses of "hive", rewords Spek's questions without stalling the meeting, and the Inbox notes header names her (#18393).
27 changes: 25 additions & 2 deletions src/cmd/hive/meetings_inbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"
"time"

"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/inbox"
"github.com/hivecommons/hive/pkg/meetings"
"github.com/hivecommons/hive/pkg/meetings/live"
Expand All @@ -17,6 +18,9 @@ import (
type meetingsInbox struct {
mgr *meetings.Manager
store *meetings.Store
// name is the attendee in the notes header: the persona's name, or
// "hive" with the persona off.
name string
}

// meetingsInboxStates are the states whose meetings the inbox lists.
Expand Down Expand Up @@ -55,12 +59,31 @@ func (mi *meetingsInbox) build(m meetings.Meeting) (inbox.LiveMeeting, error) {
out.EndedAt = *m.EndedAt
}
if len(st.Notes) > 0 {
out.Notes = live.RenderNotes(m, st.Notes)
out.Notes = live.RenderNotesBy(mi.attendee(), m, st.Notes)
out.Summary = strings.Join(st.Notes[live.SectionSummary], "\n")
}
return out, nil
}

// attendee names the note taker in the notes header.
func (mi *meetingsInbox) attendee() string {
if n := strings.TrimSpace(mi.name); n != "" {
return n
}
return defaultNotesAttendee
}

// defaultNotesAttendee names the note taker with the persona off.
const defaultNotesAttendee = "hive"

// meetingsAttendeeName is the persona's name when it is on.
func meetingsAttendeeName(p config.ResolvedMeetingsPersona) string {
if p.Enabled && strings.TrimSpace(p.Name) != "" {
return p.Name
}
return defaultNotesAttendee
}

// EndedMeetings implements inbox.LiveMeetingReader.
func (mi *meetingsInbox) EndedMeetings(context.Context) ([]inbox.LiveMeeting, error) {
list, err := mi.mgr.List()
Expand Down Expand Up @@ -104,7 +127,7 @@ const hoursPerDay = 24
// wireMeetingsInbox adds ended meetings to the inbox and starts the
// retention sweeper.
func (b *boot) wireMeetingsInbox(mgr *meetings.Manager, store *meetings.Store) {
b.meetingsInboxSrc = &inbox.LiveMeetingSource{Reader: &meetingsInbox{mgr: mgr, store: store}}
b.meetingsInboxSrc = &inbox.LiveMeetingSource{Reader: &meetingsInbox{mgr: mgr, store: store, name: meetingsAttendeeName(b.cfg.Meetings.Persona.Resolve())}}
b.refreshInboxSources(b.cfg.Knowledge.Connectors, b.knowledgeConnectors)
retention := time.Duration(b.cfg.Meetings.RetentionDaysOrDefault()) * hoursPerDay * time.Hour
mgr.StartRetention(retention, 0, live.StateDoc)
Expand Down
19 changes: 19 additions & 0 deletions src/cmd/hive/meetings_inbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/inbox"
"github.com/hivecommons/hive/pkg/meetings"
"github.com/hivecommons/hive/pkg/meetings/live"
)
Expand Down Expand Up @@ -69,6 +70,14 @@ func TestMeetingsInboxReader(t *testing.T) {
if got.Summary != "short" || !strings.Contains(got.Notes, "## Decisions") || !got.StartedAt.Equal(now) || !got.EndedAt.Equal(ended) {
t.Fatalf("meeting %+v", got)
}
if !strings.HasPrefix(got.Notes, "Notes hive took in") {
t.Fatalf("header without a persona name: %q", got.Notes)
}
// The notes header names the persona (hivecommons/hive#18393).
named := &meetingsInbox{mgr: mgr, store: store, name: "Betty"}
if b, err := named.ReadMeeting(context.Background(), "mtg-done"); err != nil || !strings.HasPrefix(b.Notes, "Notes Betty took in") {
t.Fatalf("persona header %q, %v", b.Notes, err)
}
if _, err := mi.ReadMeeting(context.Background(), "mtg-none"); err == nil {
t.Fatal("want not found")
}
Expand Down Expand Up @@ -98,6 +107,16 @@ func TestWireMeetingsInbox(t *testing.T) {
if b.meetingsInboxSrc == nil {
t.Fatal("inbox source not set")
}
if src, ok := b.meetingsInboxSrc.(*inbox.LiveMeetingSource); !ok {
t.Fatalf("inbox source %T", b.meetingsInboxSrc)
} else if mi, ok := src.Reader.(*meetingsInbox); !ok || mi.name != "Betty" {
t.Fatalf("inbox reader %+v", src.Reader)
}
off := false
cfg := config.MeetingsPersonaConfig{Enabled: &off}
if meetingsAttendeeName(cfg.Resolve()) != "hive" || meetingsAttendeeName(config.MeetingsPersonaConfig{}.Resolve()) != "Betty" {
t.Fatal("meetingsAttendeeName")
}
srcs := b.inboxSources(t.TempDir(), nil, nil)
if len(srcs) != 1 || srcs[0].Type() != "meeting" {
t.Fatalf("sources %+v", srcs)
Expand Down
51 changes: 32 additions & 19 deletions src/cmd/hive/meetingswire.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ func wireMeetingsLive(cfg *config.Config, mgr *meetings.Manager, store *meetings
},
SpekMode: llm.Label(),
UsageFile: func(id string) string {
if llm.Backend != config.MeetingsLLMModeOpenAI {
// `hive meeting-llm` (OpenAI-compatible) and the persona's own
// calls (either backend) write the meeting's usage ledger.
if llm.Backend != config.MeetingsLLMModeOpenAI && llm.Backend != config.MeetingsLLMModeAnthropic {
return ""
}
return meetingUsageFile(store, id)
Expand All @@ -210,7 +212,7 @@ func wireMeetingsLive(cfg *config.Config, mgr *meetings.Manager, store *meetings
},
Ledger: live.NewLedger(m.Budget.MaxTokensPerHourOrDefault(), m.Budget.MaxTokensPerDayOrDefault()),
Logger: logger,
Persona: meetingPersonaFactory(cfg, persona, llm, store, kapi, beadStores, slotsDir, maxTokens, logger),
Persona: meetingPersonaFactory(cfg, persona, llm, store, kapi, beadStores, slotsDir, maxTokens, research != nil, logger),
PersonaName: personaName,
IsLeave: meetings.NewLeaveMatcher(persona.LeavePhrases).Match,
})
Expand All @@ -225,15 +227,18 @@ func wireMeetingsLive(cfg *config.Config, mgr *meetings.Manager, store *meetings
}

// meetingPersonaFactory builds the meeting attendee persona (Betty,
// hivecommons/hive#18392) for each live meeting, or returns nil when the
// persona is off. She retrieves from the in-memory knowledge vaults, code
// maps (when enabled) and bead stores, and answers through the meetings
// model (`meetllm`, charged to the meeting's usage file and budget). With no
// OpenAI-compatible meetings model she still introduces herself but does
// not answer questions.
// hivecommons/hive#18392, #18393) for each live meeting, or returns nil when
// the persona is off. She retrieves from the in-memory knowledge vaults,
// code maps (when enabled), bead stores and, with
// meetings.persona.searxng_url set, the web through SearXNG. She answers
// through the meetings model: the OpenAI-compatible endpoint, or the
// Anthropic Messages API on a hive with only an Anthropic key, both charged
// to the meeting's usage file and budget. With no model she still
// introduces herself but does not answer questions. canResearch lets an
// addressed question she cannot answer well become a deep dive.
func meetingPersonaFactory(cfg *config.Config, persona config.ResolvedMeetingsPersona, llm config.ResolvedMeetingsLLM,
store *meetings.Store, kapi *knowledge.KnowledgeAPI, beadStores func() map[string]*beads.Store,
slotsDir string, maxTokens int, logger *slog.Logger) func(meetings.Meeting) *betty.Engine {
slotsDir string, maxTokens int, canResearch bool, logger *slog.Logger) func(meetings.Meeting) *betty.Engine {
if !persona.Enabled {
return nil
}
Expand All @@ -249,19 +254,27 @@ func meetingPersonaFactory(cfg *config.Config, persona config.ResolvedMeetingsPe
retrievers = append(retrievers, betty.BeadRetriever{Stores: beadStores})
}
client := &http.Client{}
if persona.SearxngURL != "" {
retrievers = append(retrievers, betty.WebRetriever{BaseURL: persona.SearxngURL, Client: client})
}
return func(mt meetings.Meeting) *betty.Engine {
var model betty.LLM
if llm.Backend == config.MeetingsLLMModeOpenAI {
model = betty.MeetLLM{Client: client, Config: meetllm.Config{
Endpoint: llm.Endpoint, Model: llm.Model, APIKey: llm.APIKey,
// The engine bounds each call itself (2.5 s unprompted, 4 s
// addressed, 800 ms restyle); this is the outer cap.
Timeout: betty.DefaultAddressedTimeout,
UsageFile: meetingUsageFile(store, mt.ID), MaxTokens: maxTokens,
SlotsDir: slotsDir, MaxInFlight: llm.MaxInFlight,
}}
mc := meetllm.Config{
// The engine bounds each call itself (2.5 s unprompted, 4 s
// addressed, 800 ms restyle); this is the outer cap.
Timeout: betty.DefaultAddressedTimeout,
UsageFile: meetingUsageFile(store, mt.ID), MaxTokens: maxTokens,
SlotsDir: slotsDir, MaxInFlight: llm.MaxInFlight,
}
switch llm.Backend {
case config.MeetingsLLMModeOpenAI:
mc.Endpoint, mc.Model, mc.APIKey = llm.Endpoint, llm.Model, llm.APIKey
model = betty.MeetLLM{Client: client, Config: mc}
case config.MeetingsLLMModeAnthropic:
mc.Provider, mc.Model, mc.APIKey = meetllm.ProviderAnthropic, llm.Model, llm.AnthropicKey
model = betty.MeetLLM{Client: client, Config: mc}
}
return betty.New(betty.SettingsFrom(persona), betty.Deps{LLM: model, Retrievers: retrievers, Logger: logger})
return betty.New(betty.SettingsFrom(persona), betty.Deps{LLM: model, Retrievers: retrievers, Logger: logger, CanResearch: canResearch})
}
}

Expand Down
18 changes: 14 additions & 4 deletions src/cmd/hive/meetingswire_persona_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestMeetingPersonaFactory(t *testing.T) {
persona := cfg.Meetings.Persona.Resolve()
llm := config.ResolvedMeetingsLLM{Backend: config.MeetingsLLMModeOpenAI, Endpoint: "http://127.0.0.1:1", Model: "m", MaxInFlight: 1}
beadStores := func() map[string]*beads.Store { return nil }
fn := meetingPersonaFactory(cfg, persona, llm, store, &knowledge.KnowledgeAPI{}, beadStores, t.TempDir(), 100, slog.New(slog.DiscardHandler))
fn := meetingPersonaFactory(cfg, persona, llm, store, &knowledge.KnowledgeAPI{}, beadStores, t.TempDir(), 100, true, slog.New(slog.DiscardHandler))
if fn == nil {
t.Fatal("the persona is on by default")
}
Expand All @@ -30,13 +30,23 @@ func TestMeetingPersonaFactory(t *testing.T) {
t.Fatal("want Betty")
}
e.Close()
// Without an OpenAI-compatible model Betty still runs (intros only).
if e := meetingPersonaFactory(cfg, persona, config.ResolvedMeetingsLLM{Backend: config.MeetingsLLMModeNone}, store, nil, nil, "", 0, nil)(meetings.Meeting{ID: "m2"}); e == nil {
// With only an Anthropic key and a web search service she answers
// through the Messages API and searches the web.
web := cfg.Meetings.Persona
web.SearxngURL = "http://searxng.meetings.svc.cluster.local:8080"
anth := config.ResolvedMeetingsLLM{Backend: config.MeetingsLLMModeAnthropic, AnthropicKey: "ak", Model: config.DefaultMeetingsPersonaAnthropicModel, MaxInFlight: 1}
if e := meetingPersonaFactory(cfg, web.Resolve(), anth, store, nil, nil, "", 0, false, nil)(meetings.Meeting{ID: "m3"}); e == nil {
t.Fatal("want an engine on the Anthropic path")
} else {
e.Close()
}
// Without a model Betty still runs (intros only).
if e := meetingPersonaFactory(cfg, persona, config.ResolvedMeetingsLLM{Backend: config.MeetingsLLMModeNone}, store, nil, nil, "", 0, false, nil)(meetings.Meeting{ID: "m2"}); e == nil {
t.Fatal("want an engine without a model")
}
off := false
cfg.Meetings.Persona.Enabled = &off
if meetingPersonaFactory(cfg, cfg.Meetings.Persona.Resolve(), llm, store, nil, nil, "", 0, nil) != nil {
if meetingPersonaFactory(cfg, cfg.Meetings.Persona.Resolve(), llm, store, nil, nil, "", 0, false, nil) != nil {
t.Fatal("persona off means no factory")
}
r := wireMeetingsLive(cfg, mustManager(t, store), store, nil, nil, nil, nil)
Expand Down
6 changes: 3 additions & 3 deletions src/docs/env-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ Hive as a live meeting participant ([#18284](https://github.com/hivecommons/hive
| `HIVE_MEETINGS_PERSONA_INTRO_TEMPLATE` | No | the preset's intro | Intro posted when someone asks the persona to introduce itself. Placeholders `{name}`, `{display_name}`, `{pronouns}`, `{leave}`, `{accent}`, `{voice_type}`, `{language}`. |
| `HIVE_MEETINGS_PERSONA_LEAVE_PHRASES` | No | `betty leave,hive leave` | Comma-separated phrases that remove the persona from the meeting. |
| `HIVE_MEETINGS_PERSONA_HUMOR` | No | `light` | `light` (at most one light touch, never about a person) or `off`. |
| `HIVE_MEETINGS_PERSONA_SEARXNG_URL` | No | none | Web search service for the persona (not used yet). |
| `HIVE_MEETINGS_PERSONA_SEARXNG_URL` | No | none | SearXNG instance the persona searches the web with (`GET /search?format=json`, 1.2 s timeout, top 3 results as untrusted data). In-cluster on hive-oke: `http://searxng.meetings.svc.cluster.local:8080`. Empty means no web search. |
| `HIVE_MEETINGS_PERSONA_UNPROMPTED_PER_10M` | No | `2` | Unprompted (question-driven) answers per ten minutes. |
| `HIVE_MEETINGS_PERSONA_UNPROMPTED_MIN_GAP_S` | No | `90` | Minimum seconds between two unprompted answers. |
| `HIVE_MEETINGS_PERSONA_UNPROMPTED_PER_MEETING` | No | `12` | Unprompted answers per meeting. |
Expand All @@ -430,10 +430,10 @@ Hive as a live meeting participant ([#18284](https://github.com/hivecommons/hive
| `HIVE_MEETINGS_PERSONA_UNPROMPTED_STALE_S` | No | `60` | Seconds after which a waiting room question is dropped. |
| `HIVE_MEETINGS_LLM_MODE` | No | `auto` | Model Spektacular live mode reasons with: `auto` (an Anthropic key if set, else the OpenAI-compatible endpoint), `openai`, `anthropic` or `none` (rules only). |
| `HIVE_MEETINGS_LLM_ENDPOINT` | No | `governor.litellm` endpoint | OpenAI-compatible base URL `hive meeting-llm` calls for Spek. |
| `HIVE_MEETINGS_LLM_MODEL` | No | `governor.litellm.default_model` | Model name for that endpoint. Without an endpoint and model, Spek runs on rules only. |
| `HIVE_MEETINGS_LLM_MODEL` | No | `governor.litellm.default_model` | Model name for that endpoint. Without an endpoint and model, Spek runs on rules only. With only an Anthropic key it is the model the persona answers with through the Anthropic Messages API (default `claude-haiku-5-5`). |
| `HIVE_MEETINGS_LLM_API_KEY` | No | `governor.litellm` key | Key for that endpoint. Secret. Wins over the secret file. |
| `HIVE_MEETINGS_LLM_API_KEY_FILE` | No | `/data/secrets/meetings_llm_api_key` | Keystore-sealed key file for the meetings endpoint. |
| `HIVE_MEETINGS_ANTHROPIC_API_KEY` | No | none | Anthropic key; when set (mode `auto` or `anthropic`) Spek calls Anthropic directly. Secret; passed only into the Spek child's environment. |
| `HIVE_MEETINGS_ANTHROPIC_API_KEY` | No | none | Anthropic key; when set (mode `auto` or `anthropic`) Spek calls Anthropic directly and the persona answers through the Anthropic Messages API. Secret; passed only into the Spek child's environment and used in-process for the persona's calls. |
| `HIVE_MEETINGS_ANTHROPIC_API_KEY_FILE` | No | `/data/secrets/meetings_anthropic_api_key` | Keystore-sealed Anthropic key file. |
| `HIVE_MEETINGS_ANTHROPIC_MODEL` | No | Spektacular's default | Anthropic model override (`SPEK_MEETING_MODEL`). |
| `HIVE_MEETINGS_LLM_TIMEOUT_MS` | No | `2500` | Per-call model timeout. |
Expand Down
Loading
Loading