feat(workflow): implement target channel personalities, raw review cards, on-demand AI rewrites and multi-target dispatch
This commit is contained in:
@@ -26,7 +26,7 @@ logging.basicConfig(
|
||||
logger = logging.getLogger("copykar.main")
|
||||
|
||||
async def main():
|
||||
logger.info("Starting Copykar System...")
|
||||
logger.info("Starting Copykar System with Persian Target Rewriting & Review Pipeline...")
|
||||
|
||||
# 1. Start Prometheus metrics server
|
||||
metrics_port = int(os.getenv("METRICS_PORT", "8000"))
|
||||
@@ -43,28 +43,16 @@ async def main():
|
||||
llm = LLMClient()
|
||||
|
||||
# 3. Create Services
|
||||
admin_bot = AdminBotService(repo=repo)
|
||||
ai_processor = AIProcessor(repo=repo, llm=llm)
|
||||
|
||||
# Wrap AI processor to automatically push reviewed posts to admin review channel
|
||||
original_process_post = ai_processor.process_post
|
||||
async def process_and_notify(post_id: int):
|
||||
post = await original_process_post(post_id)
|
||||
if post:
|
||||
await admin_bot.send_review_post(post.id)
|
||||
return post
|
||||
ai_processor.process_post = process_and_notify
|
||||
|
||||
collector = CollectorService(repo=repo, ai_processor=ai_processor, queue=redis_queue)
|
||||
admin_bot = AdminBotService(repo=repo, ai_processor=ai_processor)
|
||||
collector = CollectorService(repo=repo, queue=redis_queue, on_post_received=admin_bot.send_raw_review_post)
|
||||
admin_bot.set_collector(collector)
|
||||
publisher = PublisherService(repo=repo)
|
||||
queue_consumer = QueueConsumerService(queue=redis_queue, ai_processor=ai_processor)
|
||||
queue_consumer = QueueConsumerService(queue=redis_queue, on_post_popped=admin_bot.send_raw_review_post)
|
||||
|
||||
# 4. Start all services
|
||||
await admin_bot.start()
|
||||
await collector.start(notify_fn=admin_bot.notify_admins)
|
||||
await queue_consumer.start()
|
||||
await publisher.start()
|
||||
|
||||
logger.info("All Copykar services are active and running.")
|
||||
|
||||
@@ -76,7 +64,7 @@ async def main():
|
||||
try:
|
||||
loop.add_signal_handler(sig, stop_event.set)
|
||||
except NotImplementedError:
|
||||
pass # Windows or specific platforms
|
||||
pass
|
||||
|
||||
try:
|
||||
await stop_event.wait()
|
||||
@@ -86,7 +74,6 @@ async def main():
|
||||
logger.info("Shutting down Copykar services...")
|
||||
await collector.stop()
|
||||
await queue_consumer.stop()
|
||||
await publisher.stop()
|
||||
await admin_bot.stop()
|
||||
await redis_queue.close()
|
||||
await close_db_pool()
|
||||
|
||||
Reference in New Issue
Block a user