Download core/content_crew_config.py from aliroya32/ContiAI: direct link, hf CLI and curl.
- Browser
- Download file 1.64 kB
-
https://huggingface.co/spaces/aliroya32/ContiAI/resolve/main/core/content_crew_config.py
- Command line
-
hf download hf://spaces/aliroya32/ContiAI/core/content_crew_config.py
-
curl -L -o content_crew_config.py https://huggingface.co/spaces/aliroya32/ContiAI/resolve/main/core/content_crew_config.py
1.64 kB
| # app/core/crew_config.py | |
| import litellm | |
| from crewai import Crew, Process | |
| # ====== LITELLM GLOBAL CONFIG ====== | |
| litellm.num_retries = 4 | |
| litellm.retry_policy = { | |
| "TimeoutError": 4, | |
| "APIError": 3, | |
| "OpenRouterException": 3, | |
| "Exception": 2, | |
| } | |
| litellm.request_timeout = 120 | |
| litellm.drop_params = True | |
| # # ====== IMPORT AGENT + TASK ====== | |
| # from agents.content_phase import ( | |
| # course_writer_agent, | |
| # course_writer_task, | |
| # ) # انت عندك دول جاهزين | |
| # # ====== CACHED CREW (يُستخدم في أي مكان) ====== | |
| # agent = course_writer_agent() | |
| # task = course_writer_task(agent) | |
| # cached_crew = Crew( | |
| # agents=[agent], | |
| # tasks=[task], | |
| # process=Process.sequential, | |
| # memory=False, | |
| # verbose=False, | |
| # ) | |
| # ====== SAFE RUN WRAPPER ====== | |
| import json | |
| import time | |
| def safe_run_cached(inputs, cached_crew, retries: int = 4): | |
| """ | |
| يلف حوالين cached_crew.kickoff ويحاول يعمل JSON parsing كذا مرة | |
| ويرجع (generated_content, sources) | |
| """ | |
| for attempt in range(1, retries + 1): | |
| result = cached_crew.kickoff(inputs=inputs) | |
| try: | |
| # لو result.raw موجود بنفس الشكل اللي كنت بتستخدمه | |
| raw = json.loads(result.raw) | |
| return raw.get("generated_content", ""), raw.get("sources", []) | |
| except Exception: | |
| print(f"❌ JSON Error attempt {attempt}") | |
| # تطبع أول جزء من الرد عشان الديبج | |
| print(str(result)[:300]) | |
| time.sleep(0.7) | |
| return "", [] | |