A curated collection of practical AI projects implementing OCR systems, RAG, AI agents, and other AI use cases.
clean project directory
cyberholics9cac4f874b4f
diff --git a/ai_agents/marketing_strategy_agent/marketing_strategy_agent/agents.py b/ai_agents/marketing_strategy_agent/marketing_strategy_agent/agents.pyindex c8329a7..794a964 100644--- a/ai_agents/marketing_strategy_agent/marketing_strategy_agent/agents.py+++ b/ai_agents/marketing_strategy_agent/marketing_strategy_agent/agents.py@@ -1,10 +1,10 @@"""-Marketing Strategy Agent — Agent definitions.+Marketing Strategy Agent - Agent definitions.Three specialist agents run sequentially via the OpenAI SDK:- 1. Market Analyst — researches market, competitors, and audience (uses Serper)- 2. Strategy Officer — formulates the marketing strategy- 3. Creative Director — writes the full campaign content+ 1. Market Analyst - researches market, competitors, and audience (uses Serper)+ 2. Strategy Officer - formulates the marketing strategy+ 3. Creative Director - writes the full campaign content"""from __future__ import annotations@@ -19,8 +19,6 @@ from .tools import search_webORQ_BASE_URL = "https://my.orq.ai/v3/router"MODEL_ID = "alibaba/deepseek-v4-flash"-# ── Tool schema for the Market Analyst ────────────────────────────────────────-SEARCH_TOOL = {"type": "function","function": {@@ -39,17 +37,16 @@ SEARCH_TOOL = {},}-# ── Shared LLM client factory ──────────────────────────────────────────────────def _client(api_key: str) -> OpenAI:return OpenAI(base_url=ORQ_BASE_URL, api_key=api_key)-# ── Agent 1: Market Analyst ────────────────────────────────────────────────────+# -- Agent 1: Market Analyst ---------------------------------------------------ANALYST_SYSTEM = """\You are a senior market researcher with 15 years of experience across consumer, B2B, and SaaS markets.-You are known for tight, actionable research briefs that cut straight to what matters.+You produce tight, actionable research briefs that cut straight to what matters.Use web search to ground every claim in current, real data."""@@ -66,7 +63,7 @@ def run_market_analyst(api_key: str, product: str, audience: str) -> str:f"Target Audience: {audience}\n\n""Research and cover:\n""1. Market size and growth trends\n"- "2. Top 3–5 competitors — positioning, strengths, and weaknesses\n"+ "2. Top 3 to 5 competitors - positioning, strengths, and weaknesses\n""3. Target audience pain points, motivations, and buying behaviour\n""4. Key market opportunities and gaps\n""5. Relevant industry trends that affect the campaign\n\n"@@ -77,7 +74,6 @@ def run_market_analyst(api_key: str, product: str, audience: str) -> str:},]- # Tool-calling loopwhile True:response = client.chat.completions.create(model=MODEL_ID,@@ -101,11 +97,11 @@ def run_market_analyst(api_key: str, product: str, audience: str) -> str:return msg.content or ""-# ── Agent 2: Strategy Officer ──────────────────────────────────────────────────+# -- Agent 2: Strategy Officer -------------------------------------------------STRATEGIST_SYSTEM = """\You are a Chief Marketing Strategist who has launched products across consumer tech, fintech, and enterprise software.-You think in frameworks but write in plain language, and you never produce a strategy that can't be executed.+You think in frameworks but write in plain language, and you never produce a strategy that cannot be executed."""def run_strategy_officer(api_key: str, product: str, audience: str, research: str) -> str:@@ -123,9 +119,9 @@ def run_strategy_officer(api_key: str, product: str, audience: str, research: stf"Target Audience: {audience}\n\n"f"## Market Research\n{research}\n\n""Your strategy must define:\n"- "1. Positioning statement — what makes this product uniquely valuable\n"- "2. Core messaging pillars (3–4 themes across all comms)\n"- "3. Target channels — ranked by priority with rationale\n"+ "1. Positioning statement - what makes this product uniquely valuable\n"+ "2. Core messaging pillars (3 to 4 themes across all comms)\n"+ "3. Target channels, ranked by priority with rationale\n""4. Campaign goals and KPIs (awareness, acquisition, retention)\n""5. Budget allocation guidance (% split across channels)\n""6. 90-day phased rollout plan\n\n"@@ -137,7 +133,7 @@ def run_strategy_officer(api_key: str, product: str, audience: str, research: streturn response.choices[0].message.content or ""-# ── Agent 3: Creative Director ─────────────────────────────────────────────────+# -- Agent 3: Creative Director ------------------------------------------------CREATIVE_SYSTEM = """\You are a Creative Director who has led campaigns for challenger brands and Fortune 500 companies.@@ -161,14 +157,14 @@ def run_creative_director(api_key: str, product: str, audience: str, strategy: s"Deliver:\n""1. Campaign name and tagline\n""2. Hero headline and 3 supporting headlines\n"- "3. Elevator pitch (2–3 sentences for ads and landing pages)\n"+ "3. Elevator pitch (2 to 3 sentences for ads and landing pages)\n""4. Channel-specific copy:\n"" - 3 LinkedIn post drafts\n"" - 3 short-form social posts (X/Instagram)\n"- " - 1 email subject line + preview text\n"+ " - 1 email subject line and preview text\n"" - 1 Google Ads headline set (3 headlines, 2 descriptions)\n""5. 5 content marketing ideas (blog posts, videos, or case studies)\n"- "6. Launch week playbook — day-by-day activity plan\n\n"+ "6. Launch week playbook - day-by-day activity plan\n\n""Return everything in clean markdown."),},diff --git a/ai_agents/marketing_strategy_agent/marketing_strategy_agent/crew.py b/ai_agents/marketing_strategy_agent/marketing_strategy_agent/crew.pyindex 21e26e0..83ebd31 100644--- a/ai_agents/marketing_strategy_agent/marketing_strategy_agent/crew.py+++ b/ai_agents/marketing_strategy_agent/marketing_strategy_agent/crew.py@@ -1,5 +1,5 @@"""-Marketing Strategy Agent — Pipeline.+Marketing Strategy Agent - Pipeline.Runs the three agents sequentially and returns all three outputs."""diff --git a/ai_agents/marketing_strategy_agent/marketing_strategy_agent/tasks.py b/ai_agents/marketing_strategy_agent/marketing_strategy_agent/tasks.pydeleted file mode 100644index 7b8e67c..0000000--- a/ai_agents/marketing_strategy_agent/marketing_strategy_agent/tasks.py+++ /dev/null@@ -1,88 +0,0 @@-"""-Marketing Strategy Agent — Task definitions.--Tasks run sequentially. Each task receives the previous task's output as context.-"""--from crewai import Task--from .agents import creative_director, market_analyst, strategy_officer--# ── Task 1: Market Research ────────────────────────────────────────────────────--research_task = Task(- description=(- "Conduct market research for the following product and target audience.\n\n"- "Product: {product_description}\n"- "Target Audience: {target_audience}\n\n"- "Research and cover:\n"- "1. Market size and growth trends\n"- "2. Top 3–5 competitors — their positioning, strengths, and weaknesses\n"- "3. Target audience pain points, motivations, and buying behaviour\n"- "4. Key market opportunities and gaps\n"- "5. Relevant industry trends or shifts that affect the campaign\n\n"- "Use web search to ground your findings in real, current data."- ),- expected_output=(- "A structured market research brief in markdown with sections for: "- "Market Overview, Competitor Analysis, Audience Insights, Opportunities, "- "and Key Trends. Include specific data points and sources where possible."- ),- agent=market_analyst,-)--# ── Task 2: Marketing Strategy ─────────────────────────────────────────────────--strategy_task = Task(- description=(- "Using the market research brief above, develop a comprehensive marketing "- "strategy for the following product.\n\n"- "Product: {product_description}\n"- "Target Audience: {target_audience}\n\n"- "Your strategy must define:\n"- "1. Positioning statement — what makes this product uniquely valuable\n"- "2. Core messaging pillars (3–4 themes that will run through all comms)\n"- "3. Target channels — ranked by priority with rationale\n"- "4. Campaign goals and KPIs (awareness, acquisition, retention)\n"- "5. Budget allocation guidance (% split across channels)\n"- "6. 90-day phased rollout plan\n\n"- "Be specific and practical. Avoid generic advice."- ),- expected_output=(- "A complete marketing strategy document in markdown with sections for: "- "Positioning, Messaging Pillars, Channel Strategy, Goals & KPIs, "- "Budget Guidance, and 90-Day Rollout Plan."- ),- agent=strategy_officer,- context=[research_task],-)--# ── Task 3: Creative Campaign ──────────────────────────────────────────────────--creative_task = Task(- description=(- "Using the marketing strategy above, produce the full creative campaign plan "- "for the following product.\n\n"- "Product: {product_description}\n"- "Target Audience: {target_audience}\n\n"- "Deliver:\n"- "1. Campaign name and tagline\n"- "2. Hero headline and 3 supporting headlines\n"- "3. Elevator pitch (2–3 sentences for paid ads and landing pages)\n"- "4. Channel-specific copy:\n"- " - 3 LinkedIn post drafts\n"- " - 3 short-form social posts (X/Instagram)\n"- " - 1 email subject line + preview text\n"- " - 1 Google Ads headline set (3 headlines, 2 descriptions)\n"- "5. 5 content marketing ideas (blog posts, videos, or case studies)\n"- "6. Launch week playbook — day-by-day activity plan\n\n"- "Keep the voice consistent, on-brand, and tailored to the target audience."- ),- expected_output=(- "A complete creative campaign document in markdown with all deliverables "- "listed above: campaign name, headlines, ad copy, channel-specific posts, "- "content ideas, and the launch week playbook."- ),- agent=creative_director,- context=[strategy_task],-)diff --git a/ai_agents/marketing_strategy_agent/marketing_strategy_agent/tools.py b/ai_agents/marketing_strategy_agent/marketing_strategy_agent/tools.pyindex 0706ce2..7a56e0c 100644--- a/ai_agents/marketing_strategy_agent/marketing_strategy_agent/tools.py+++ b/ai_agents/marketing_strategy_agent/marketing_strategy_agent/tools.py@@ -1,5 +1,5 @@"""-Marketing Strategy Agent — Tools.+Marketing Strategy Agent - Tools."""from __future__ import annotations@@ -13,7 +13,7 @@ def search_web(query: str, num_results: int = 5) -> str:"""Search the web using Serper and return formatted results."""api_key = os.getenv("SERPER_API_KEY", "")if not api_key:- return "Web search unavailable — SERPER_API_KEY not set."+ return "Web search unavailable - SERPER_API_KEY not set."try:r = httpx.post(@@ -27,14 +27,12 @@ def search_web(query: str, num_results: int = 5) -> str:results = []- # Answer box (quick fact)if "answerBox" in data:ab = data["answerBox"]answer = ab.get("answer") or ab.get("snippet", "")if answer:results.append(f"**Quick Answer:** {answer}")- # Organic resultsfor item in data.get("organic", [])[:num_results]:title = item.get("title", "")snippet = item.get("snippet", "")