Minor fixes
This commit is contained in:
66
agentstuff/sentiment_agent/main.py
Normal file
66
agentstuff/sentiment_agent/main.py
Normal file
@@ -0,0 +1,66 @@
|
||||
"""CLI entry point for the sentiment analysis agent."""
|
||||
|
||||
import argparse
|
||||
import anyio
|
||||
|
||||
from sentiment_agent.agent import run_sentiment_analysis
|
||||
from sentiment_agent.config import SafetyConfig
|
||||
|
||||
|
||||
async def async_main(args: argparse.Namespace) -> None:
|
||||
config = SafetyConfig(
|
||||
max_turns=args.max_turns,
|
||||
max_budget_usd=args.max_budget,
|
||||
max_total_api_calls=args.max_api_calls,
|
||||
min_credibility_score=args.min_credibility,
|
||||
flag_bot_threshold=args.flag_threshold,
|
||||
)
|
||||
|
||||
result = await run_sentiment_analysis(
|
||||
topic=args.topic,
|
||||
sources=args.sources,
|
||||
config=config,
|
||||
)
|
||||
print("\n" + "=" * 60)
|
||||
print("SENTIMENT ANALYSIS REPORT")
|
||||
print("=" * 60)
|
||||
print(result)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Run sentiment analysis on a topic with bot/disinfo detection",
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
||||
)
|
||||
parser.add_argument("topic", help="The topic to analyze sentiment for")
|
||||
parser.add_argument(
|
||||
"--sources", nargs="*", help="Specific URLs or sources to also analyze"
|
||||
)
|
||||
|
||||
safety = parser.add_argument_group("safety limits")
|
||||
safety.add_argument(
|
||||
"--max-turns", type=int, default=20, help="Max agent turns"
|
||||
)
|
||||
safety.add_argument(
|
||||
"--max-budget", type=float, default=0.50, help="Max Claude API spend (USD)"
|
||||
)
|
||||
safety.add_argument(
|
||||
"--max-api-calls", type=int, default=50, help="Max total API calls across all platforms"
|
||||
)
|
||||
|
||||
credibility = parser.add_argument_group("credibility filtering")
|
||||
credibility.add_argument(
|
||||
"--min-credibility", type=float, default=0.3,
|
||||
help="Posts below this score are excluded (0.0-1.0)",
|
||||
)
|
||||
credibility.add_argument(
|
||||
"--flag-threshold", type=float, default=0.5,
|
||||
help="Posts between min and this are flagged but included (0.0-1.0)",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
anyio.run(async_main, args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user