Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.mavera.io/llms.txt

Use this file to discover all available pages before exploring further.

Scenario

Subreddits surface emerging topics hours before mainstream channels. This job monitors /rising, sends each trend to Mave for brand-alignment, then feeds approved trends into Generate.

Architecture

Code

import os, requests, time

# --- Auth setup same as Job 1 ---

SUB = "marketing"
BRAND = "B2B marketing analytics platform. Audience: Marketing directors/VPs. Tone: Data-driven, practical, contrarian."

# 1. Rising posts
rising = [p["data"] for p in requests.get(f"{RD}/r/{SUB}/rising",
    headers=RD_H, params={"limit": 20, "raw_json": 1}).json()["data"]["children"]]

# 2. Brand alignment via Mave
aligned = []
for post in rising:
    check = requests.post(f"{MV_BASE}/mave/chat", headers=MV_H, json={
        "message": f"Evaluate trend for brand alignment (score 1-10).\n\nTREND: {post['title']}\nCONTEXT: {post.get('selftext','')[:300]}\nSUBREDDIT: /r/{SUB} | Score: {post.get('score',0)}\n\nBRAND: {BRAND}\n\nIf 7+: suggest angle + format. Estimate trend velocity."
    }).json()
    content = check.get("content", "")
    lines = [l for l in content.split("\n") if "/10" in l or "score" in l.lower()]
    try: score = int("".join(c for c in (lines[0] if lines else "0") if c.isdigit())[:2])
    except: score = 0
    if score >= 7:
        aligned.append({"title": post["title"], "score": post.get("score",0), "alignment": score, "angle": content[:300]})
    time.sleep(0.5)

print(f"Evaluated: {len(rising)} | Aligned: {len(aligned)}")

# 3. Generate content
for trend in aligned[:5]:
    gen = requests.post(f"{MV_BASE}/generations", headers=MV_H, json={
        "prompt": f"Write a LinkedIn article (600-800 words) based on:\n\nTREND: {trend['title']}\nANGLE: {trend['angle'][:200]}\n\nHook: Open with Reddit insight. Body: Data + frameworks. CTA: Free trial. Tone: data-driven, contrarian.",
    }).json()
    print(f"\n{'='*50}\nTREND: {trend['title']} | Alignment: {trend['alignment']}/10")
    print(gen.get("output", gen.get("content", ""))[:500])

Example Output

Evaluated: 20 | Aligned: 6

TREND: "Our attribution model was completely wrong" | Alignment: 10/10

# Our Attribution Model Was Lying to Us (and Yours Probably Is Too)

A thread in /r/marketing surfaced something uncomfortable: a director
rebuilt attribution and found 40% of "high-performing" channels were
getting credit for conversions they didn't influence...

Error Handling

/rising surfaces fast-growing posts. Fall back to /hot?limit=10 for smaller subreddits.
If truncated, increase max_tokens or split into sections.

Reddit Integration

Mave Agent