Commit Graph

41 Commits

Author SHA1 Message Date
f654a5cbb1 Deep caller personality: named people, memories, vehicles, opinions, arcs
- Named relationships (20M/20F): "my buddy Ray", "my wife Linda" — not generic
- Relationship status with detail: "married 15 years, second marriage"
- Vehicle they drive: rural southwest flavor (F-150s, Tacomas, old Broncos)
- What they were doing before calling: grounds call in a physical moment
- Specific memory/story to reference: flash floods, poker wins, desert nights
- Food/drink right now: Tecate on the porch, third cup of coffee
- Strong random opinions: speed limits, green chile, desert philosophy
- Contradictions/secrets: tough guy who cries at TV, reads physics at work
- Verbal fingerprints: 2 specific phrases per caller
- Emotional arcs: mood shifts during the call
- Show relationship: first-timer, regular, skeptic, reactive
- Late-night reasons: why they're awake
- Topic drift tendencies for some callers
- Regional speech patterns in prompt (over in, down the road, out here)
- Opening line variety based on personality
- Local town news enrichment via SearXNG
- Ad channel now configurable in settings UI

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 01:01:32 -07:00
79e6bc79be Add topic callers, town knowledge, dynamic response lengths
- 30% of callers now call about topics (prestige TV, science, poker,
  astrophotography, physics, tech, US news) instead of personal problems
- 86 curated interests weighted toward shows like Severance, Breaking Bad,
  The Wire, LOST, Westworld, etc. Removed reality TV/celebrity gossip
- 32-town knowledge base with real facts so callers don't invent landmarks
- Smart topic detection for news enrichment (keyword->search query mapping)
- Enrichment now summarizes articles naturally via LLM instead of quoting headlines
- Prompt rewrite for varied response lengths and no rehashing
- Extra weight for Animas and Lordsburg callers

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 00:14:38 -07:00
9452b07c5c Ads play once on channel 11, separate from music
- Add dedicated ad playback system (no loop, own channel)
- Ad channel defaults to 11, saved/loaded with audio settings
- Separate play_ad/stop_ad methods and API endpoints
- Frontend stop button now calls /api/ads/stop instead of stopMusic

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 22:35:07 -07:00
aa3899b1fc Harden LLM: model fallback chain, reuse client, remove fighting timeouts
- Primary model gets 15s, then auto-falls back through gemini-flash,
  gpt-4o-mini, llama-3.1-8b (10s each)
- Always returns a response — canned in-character line as last resort
- Reuse httpx client instead of creating new one per request
- Remove asyncio.timeout wrappers that were killing requests before
  the LLM service could try fallbacks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 22:07:39 -07:00
73129374f4 Bake news context into caller backgrounds at pickup time
Instead of injecting research into every LLM call (which bloated prompts
and caused timeouts), do one quick SearXNG search when a caller is picked
up and add a relevant headline to their background. 3s timeout — if search
is slow, caller just doesn't reference news. Zero impact on live conversation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 21:47:46 -07:00
164f8fbc6e Remove news/research from caller prompts — was causing timeouts
Research results were bloating the system prompt, making LLM calls
slower and hitting the 20s timeout. Callers don't need news awareness
to have good conversations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 21:44:22 -07:00
e45ba2617a Switch news service from Google News to local SearXNG
- Use local SearXNG at localhost:8888 instead of Google News RSS
- No more 302 redirects or blocked requests — local is fast and reliable
- 5s timeout on all SearXNG requests
- Removed async locks (no contention needed for local service)
- Re-enabled research and headlines

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 21:34:45 -07:00
c03f46ea96 Disable news research — was breaking calls
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 21:32:50 -07:00
69b7078142 Fix research hanging: add timeouts, fix keyword extraction, cache failures
- Google News RSS returns 302: add follow_redirects and User-Agent header
- Cache failed headline fetches for 5min so they don't retry every call
- Add 8s timeout on background research tasks
- Fix keyword extraction: skip short texts, require 2+ proper nouns (not names),
  increase min word length to 6, add radio show filler to stop words
- Stops garbage searches like "Megan welcome" and "sounds thats youre"

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 21:25:31 -07:00
b3fb3b1127 Fix AI caller hanging on 'thinking...' indefinitely
- Add 30s timeout to all frontend fetch calls (safeFetch)
- Add 20s asyncio.timeout around lock+LLM in chat, ai-respond, auto-respond
- Reduce OpenRouter timeout from 60s to 25s
- Reduce Inworld TTS timeout from 60s to 25s
- Return graceful fallback responses on timeout instead of hanging

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 21:16:15 -07:00
cac80a4b52 Localize callers to NM bootheel area
80% from Lordsburg/Animas/Portal/Playas/Deming/Silver City area,
20% out-of-staters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 20:46:51 -07:00
e30d4c8856 Add ads system, diversify callers, update website descriptions
- Add ads playback system with backend endpoints and frontend UI
- Diversify AI callers: randomize voices per session, expand jobs/problems/interests/quirks/locations
- Update website tagline and descriptions to "biologically questionable organisms"

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 20:38:25 -07:00
d5fd89fc9a Add on-air toggle for phone call routing
When off air, callers hear a message and get disconnected. When on
air, calls route normally. Toggle button added to frontend header
with pulsing red ON AIR indicator.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 14:03:38 -07:00
a94fc92647 Improve SignalWire streaming, randomize caller names, update frontend
- Add streamSid tracking and per-caller send locks for SignalWire
- Improve TTS streaming with real-time pacing and detailed logging
- Block host audio to caller during TTS playback
- Randomize caller names between sessions from name pools
- Update page title and show phone number in UI

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 01:56:05 -07:00
0412f4487f Enhance caller personality for depth and authenticity
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 00:39:49 -07:00
50e3d3af7d Include news and research context in caller prompts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 00:35:55 -07:00
a06d0a22e1 Wire up headline fetch and background research triggers
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 00:22:49 -07:00
e46337a05a Add session news/research fields and helper functions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 00:21:25 -07:00
9016f9734f Add SignalWire endpoints, update queue/hangup for phone callers
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 17:45:08 -07:00
a1c94a3682 Fix unnatural response cutoffs
- Replace aggressive sentence-count limiting with ensure_complete_thought()
  which only trims if the LLM was actually cut off mid-sentence
- Softer prompt guidance for natural brevity instead of rigid sentence count
- max_tokens at 100 as natural length cap

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 17:18:22 -07:00
9d4b8a0d22 Replace token-based truncation with sentence-count limiting
- max_tokens back to 150 so LLM can finish thoughts
- New limit_sentences() keeps only first 2 complete sentences
- Never cuts mid-sentence — always ends at punctuation
- Applied to both chat and auto-respond paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 17:15:04 -07:00
6a56967540 Enforce shorter AI responses and prevent cut-off sentences
- Reduce max_tokens from 100 to 75 for shorter output
- Add truncate_to_complete_sentence() to trim at last punctuation
- Applied to both chat and auto-respond paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 17:07:41 -07:00
0e65fa5084 Force shorter AI responses — max 1-2 sentences
- Much stronger prompt language: "no more than 2 sentences EVER"
- Added "DO NOT ramble" instruction
- Reduced max_tokens back to 100 as hard limit

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 17:05:51 -07:00
3192735615 Fix AI responses being cut off
- Increase max_tokens from 100 to 150 to avoid mid-sentence truncation
- Tighten prompt to 1-2 short sentences with emphasis on completing them

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 17:04:12 -07:00
d583b48af0 Fix choppy/distorted audio to live caller
- Mute host mic forwarding while TTS is streaming to prevent interleaving
  both audio sources into the same playback buffer
- Replace nearest-neighbor downsampling with box-filter averaging on both
  server (host mic) and browser (caller mic) for anti-aliased resampling

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 17:01:33 -07:00
d4e25ceb88 Stream TTS audio to caller in real-time chunks
TTS audio was sent as a single huge WebSocket frame that overflowed the
browser's 3s ring buffer. Now streams in 60ms chunks at real-time rate.
Also increased browser ring buffer from 3s to 10s as safety net.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 16:56:22 -07:00
97d37f3381 Send AI TTS audio to live caller during auto-respond
The auto-respond function played AI TTS to the local Loopback channel
but didn't send it over WebSocket to the live caller in the browser.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 16:53:41 -07:00
eaedc4214b Reduce live caller latency and improve reliability
- Replace per-callback async task spawning with persistent queue-based sender
- Buffer host mic to 60ms chunks (was 21ms) to reduce WebSocket frame rate
- Reduce server ring buffer prebuffer from 150ms to 80ms
- Reduce browser playback jitter buffer from 150ms to 100ms

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 16:47:17 -07:00
bcd0d96185 Fix slow hangup by moving LLM summarization and SFX to background
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 16:09:10 -07:00
cca8eaad84 Add live caller channel to audio settings
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 16:03:52 -07:00
82ad234480 Add browser call-in page and update host dashboard for browser callers
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 15:52:54 -07:00
863a81f87b Add continuous host mic streaming to real callers
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 15:51:17 -07:00
bf140a77b7 Add browser caller WebSocket handler with PCM audio streaming
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 15:49:49 -07:00
06f334359e Remove Twilio endpoints and dependencies
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 15:48:12 -07:00
3961cfc9d4 Rename TwilioService to CallerService, remove Twilio-specific audio encoding
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 15:45:08 -07:00
141f81232e Add AI follow-up system with call summarization and show history
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 13:42:35 -07:00
c82420ddad Add outbound audio streaming to real callers
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 13:39:02 -07:00
88d7fd3457 Add Twilio WebSocket media stream handler with real-time transcription
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 13:36:04 -07:00
28ff8c2d16 Add Twilio webhook and queue management endpoints
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 13:33:03 -07:00
00c2e8f018 Add Session multi-party call support and show history
- Add CallRecord dataclass for tracking call history
- Extend Session with call_history, active_real_caller, ai_respond_mode, auto_followup
- Add get_show_history() for AI caller context about earlier calls
- Update get_conversation_summary() to handle host/real_caller/ai_caller roles
- Update reset() to clear new fields
- Add tests for all new functionality

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 13:25:32 -07:00
029ce6d689 Initial commit: AI Radio Show web application
- FastAPI backend with multiple TTS providers (Inworld, ElevenLabs, Kokoro, F5-TTS, etc.)
- Web frontend with caller management, music, and soundboard
- Whisper transcription integration
- OpenRouter/Ollama LLM support
- Castopod podcast publishing script

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 23:11:20 -07:00