fix: switch to OpenAI client for llm-proxy compatibility

- Replace Anthropic SDK with OpenAI SDK (proxy uses OpenAI-compatible API)
- Add combined post fetching to include hidden/moderated posts
- Update system prompt to be more thorough at catching violations
- Add --debug flag to CLI for troubleshooting
This commit is contained in:
Ben
2026-01-06 03:58:08 +00:00
parent e9479e442a
commit e09f74578d
5 changed files with 215 additions and 59 deletions

View File

@@ -61,6 +61,11 @@ def cli() -> None:
default=True,
help="Fetch full post content (slower but more accurate)",
)
@click.option(
"--debug",
is_flag=True,
help="Show debug output including sample post content",
)
def review(
username: str,
days: int,
@@ -69,6 +74,7 @@ def review(
verbose: bool,
max_posts: int,
enrich: bool,
debug: bool,
) -> None:
"""
Review a user's forum posts for potential rule violations.
@@ -94,6 +100,7 @@ def review(
verbose=verbose,
max_posts=max_posts,
enrich=enrich,
debug=debug,
)
)
@@ -118,6 +125,7 @@ async def _review_user(
verbose: bool,
max_posts: int,
enrich: bool,
debug: bool = False,
) -> None:
"""Async implementation of user review."""
try:
@@ -134,14 +142,16 @@ async def _review_user(
console.print(f"[red]User not found:[/red] {username}")
raise SystemExit(1)
# Fetch posts
# Fetch posts (using combined method to include hidden posts)
with console.status(f"[bold blue]Fetching posts from last {days} days..."):
posts = await client.get_user_posts(
posts = await client.get_user_posts_combined(
username=username,
days=days,
max_posts=max_posts,
)
console.print(f"[green]Found {len(posts)} posts[/green]")
console.print(
f"[green]Found {len(posts)} posts (including hidden)[/green]"
)
if not posts:
console.print(
@@ -155,6 +165,26 @@ async def _review_user(
posts = await client.enrich_posts(posts)
console.print("[green]Enriched posts with full content[/green]")
# Debug: show sample post content
if debug and posts:
console.print("\n[bold yellow]DEBUG: Sample post content[/bold yellow]")
for i, post in enumerate(posts[:3]): # Show first 3 posts
console.print(f"\n[cyan]--- Post {i + 1} ---[/cyan]")
console.print(f"[dim]Topic:[/dim] {post.topic_title}")
console.print(f"[dim]URL:[/dim] {post.url}")
console.print(f"[dim]Date:[/dim] {post.created_at}")
console.print(
f"[dim]Raw length:[/dim] {len(post.content_raw)} chars"
)
console.print(
f"[dim]Text length:[/dim] {len(post.content_text)} chars"
)
content_preview = post.content_text[:500]
if len(post.content_text) > 500:
content_preview += "..."
console.print(f"[dim]Content:[/dim]\n{content_preview}")
console.print("\n")
except DiscourseError as e:
console.print(f"[red]Forum Error:[/red] {e}")
raise SystemExit(1)