import os, requests, time, json
MV = os.environ["MAVERA_API_KEY"]
MV_BASE = "https://app.mavera.io/api/v1"
MV_H = {"Authorization": f"Bearer {MV}", "Content-Type": "application/json"}
TRANSCRIPTS = [
{"event": "Weekly Community Call — Mar 10", "text": """
Host: So the new dashboard dropped yesterday — what do y'all think?
User1: Honestly? It's fire. The load time is like, instantly. Before it was like waiting for a microwave.
User2: I have some issues with the filter panel. Like, it's not obvious you can multi-select. I was clicking one at a time for like twenty minutes.
User3: Same. But once you figure it out it's actually way better. The old one was, no cap, terrible.
Host: Any feature requests while we're here?
User1: Please, PLEASE add keyboard shortcuts. I use this thing 8 hours a day. My mouse hand is dying.
User4: Can we get a mobile version that doesn't crash? I know you're working on it but it's been like three months.
User2: Also dark mode. I know everyone says it but my eyes are literally burning at 2am.
"""},
{"event": "Product Feedback Session — Mar 7", "text": """
Moderator: What made you choose us over competitors?
User5: Pricing, honestly. [Competitor X] was like $50/seat and for a 20-person team that's insane.
User6: For me it was the API. I'm a developer and I could actually build integrations without wanting to throw my laptop.
User7: Community. I asked a question in Discord and got an answer in like 5 minutes. From an actual human. That sealed it.
Moderator: What's your biggest frustration?
User5: Onboarding. We had to figure everything out from YouTube videos. No in-app guidance.
User6: Rate limits on the API. 100 req/min is not enough for production. I'm building hacky caches everywhere.
User7: The mobile app. It's giving 2019 energy. Like, it works, but barely.
"""},
{"event": "Gaming Community Meetup — Mar 3", "text": """
User8: I switched our whole guild management to this and it's been a game changer. Literally.
User9: The automations are chef's kiss. Set up welcome messages, role assignments, the whole nine.
User10: Only complaint — can't customize the embed colors. Minor thing but aesthetics matter when you're running a community of 5000 people.
User8: Facts. Also the analytics dashboard shows me who's active and who's ghosting. Love that.
"""},
]
# 1. Concatenate transcripts
full_text = "\n\n---\n\n".join(
f"EVENT: {t['event']}\n{t['text'].strip()}"
for t in TRANSCRIPTS
)
print(f"Transcript corpus: {len(TRANSCRIPTS)} events, {len(full_text):,} chars")
# 2. Create brand voice
bv = requests.post(f"{MV_BASE}/brand-voices", headers=MV_H, json={
"name": "Community Voice: Discord Voice Channels",
"extracted_content": full_text,
"description": f"Voice from {len(TRANSCRIPTS)} Discord voice channel transcripts. "
"Captures natural speech patterns, slang, emotional register, humor, "
"and unfiltered product opinions from community members.",
}).json()
print(f"Brand Voice: {bv.get('id','')} — {bv.get('traits', bv.get('voice_summary',''))}")
# 3. Test generation
tests = [
"Write a product update announcement (150 words) for the Discord community. Use the community's natural voice.",
"Write a tweet (280 chars) announcing a new feature, in the community's authentic tone.",
"Write a support reply to someone reporting the mobile app crashing, using community-native language.",
]
for prompt in tests:
gen = requests.post(f"{MV_BASE}/generations", headers=MV_H, json={
"brand_voice_id": bv["id"], "prompt": prompt,
}).json()
print(f"\n[TEST] {prompt[:60]}...")
print(gen.get("output", gen.get("content", ""))[:400])