""" Startup Ideation Assistant - From Idea to Maturity Developed by Najaf Ali Sharqi """ import gradio as gr from groq import Groq import os import json from datetime import datetime # Initialize Groq client client = Groq(api_key=os.environ.get("GROQ_API_KEY")) # Session state management class IdeationSession: def __init__(self): self.ideas = [] self.current_idea = None session = IdeationSession() # System prompts DISCOVERY_PROMPT = """You are a startup ideation expert. Help users discover innovative startup ideas using these four sources: 1. **Problems**: Identify real problems (agricultural waste, infrastructure issues, import dependency) 2. **Intersections**: Combine fields (Transportation + Mobile = Uber, Hospitality + Internet = Airbnb) 3. **Future Trends**: Emerging technologies (AI, drones, IoT, renewable energy) 4. **Edges of Knowledge**: Cutting-edge breakthroughs (new materials, gene editing, quantum computing) Be specific, provide concrete examples, and encourage bold thinking.""" EVALUATION_PROMPT = """Evaluate startup ideas using the 4-question framework: **Q1: Is it a good problem?** Market size, pain level, financial loss, customer recognition **Q2: Can I fix it?** Skills, realistic assessment, learning curve **Q3: Is solution robust?** Easy to use, addresses pain, provides benefits, easy decision **Q4: Do I have resources?** MVP capability, customer access, scaling potential, minimum funding Rate honestly (1-10 for each criterion) and provide constructive feedback.""" REFINEMENT_PROMPT = """Help refine ideas based on evaluation: - Strong ideas: Develop MVP strategy, customer discovery plan, next steps - Weak areas: Suggest specific improvements and potential pivots - Focus on: Customer interviews (not surveys), building with own resources, minimal MVP, quick testing, finding mentors""" ACTION_PLANNING_PROMPT = """Create concrete action plans: 1. Immediate actions (this week): 3-5 specific validation tasks 2. Short-term goals (1 month): Customer discovery targets, MVP specs 3. Resources needed: Skills, team, tools, initial budget 4. Milestones: Success metrics, decision points, timeline Be specific and actionable for beginners.""" def chat_with_groq(message, system_prompt, history=None): """Send message to Groq API""" try: messages = [{"role": "system", "content": system_prompt}] if history: messages.extend(history) messages.append({"role": "user", "content": message}) response = client.chat.completions.create( model="llama-3.3-70b-versatile", messages=messages, temperature=0.7, max_tokens=2000, ) return response.choices[0].message.content except Exception as e: return f"Error: {str(e)}. Please check your GROQ_API_KEY environment variable." def format_for_chatbot(history): """Format chat history for Gradio Chatbot - handles both tuple and dict formats""" # Gradio 6.x uses dict format with role/content formatted = [] for msg in history: formatted.append({ "role": msg["role"], "content": msg["content"] }) return formatted def discover_ideas(source_type, user_input, context, history): """Help discover ideas""" if not user_input or not context: return history, history prompt = f"""Using the {source_type} approach: My Background: {context} My Observation: {user_input} Please help me explore innovative startup ideas. Provide: 1. Specific idea suggestions based on my observation 2. Real-world examples of similar successful solutions 3. Probing questions to help me think deeper 4. Potential opportunities I might be missing Focus on ideas that are innovative, address real needs, and have potential for scale.""" history.append({"role": "user", "content": prompt}) response = chat_with_groq(prompt, DISCOVERY_PROMPT, history) history.append({"role": "assistant", "content": response}) return format_for_chatbot(history), history def evaluate_idea(idea_desc, target_market, problem_stmt, solution, history): """Evaluate using 4-question framework""" if not idea_desc or not problem_stmt: return history, history, "Please fill in at least Idea Description and Problem Statement" prompt = f"""Evaluate this startup idea using the 4-question framework: **Idea Description:** {idea_desc} **Target Market:** {target_market} **Problem Statement:** {problem_stmt} **Solution Approach:** {solution} Please provide: 1. Detailed evaluation for each of the 4 questions 2. Scores (1-10) for each major criterion 3. Overall assessment 4. Specific areas that need improvement 5. Red flags or concerns (if any) 6. Strengths to leverage Be honest and constructive. This is for a beginner entrepreneur.""" history.append({"role": "user", "content": prompt}) response = chat_with_groq(prompt, EVALUATION_PROMPT, history) history.append({"role": "assistant", "content": response}) session.current_idea = { "description": idea_desc, "target_market": target_market, "problem": problem_stmt, "solution": solution, "evaluation": response, "timestamp": datetime.now().isoformat() } session.ideas.append(session.current_idea) return format_for_chatbot(history), history, f"✅ Idea #{len(session.ideas)} evaluated and saved!" def refine_idea(refinement_input, history): """Refine and improve idea""" if not session.current_idea: error_msg = [{"role": "assistant", "content": "⚠️ Please evaluate an idea first in the 'Evaluate Ideas' tab before seeking refinement advice."}] return format_for_chatbot(error_msg), history, "" if not refinement_input: return format_for_chatbot(history), history, "" prompt = f"""Based on the evaluation of my current idea, I need help with: {refinement_input} **Current Idea Summary:** - Problem: {session.current_idea['problem']} - Solution: {session.current_idea['solution']} - Target Market: {session.current_idea['target_market']} Please provide specific, actionable advice to improve this idea.""" history.append({"role": "user", "content": prompt}) # Include previous evaluation for context context_messages = [ {"role": "assistant", "content": f"Previous Evaluation:\n{session.current_idea['evaluation']}"}, {"role": "user", "content": prompt} ] response = chat_with_groq(prompt, REFINEMENT_PROMPT, context_messages) history.append({"role": "assistant", "content": response}) return format_for_chatbot(history), history, "💡 Refinement suggestions provided" def create_action_plan(goals, timeline, resources, history): """Create action plan""" if not session.current_idea: error_msg = [{"role": "assistant", "content": "⚠️ Please evaluate an idea first before creating an action plan."}] return format_for_chatbot(error_msg), history, "" if not goals or not timeline: return format_for_chatbot(history), history, "Please fill in at least Goals and Timeline" prompt = f"""Create a detailed action plan for my startup idea: **Idea:** {session.current_idea['description']} **Problem:** {session.current_idea['problem']} **Solution:** {session.current_idea['solution']} **Target Market:** {session.current_idea['target_market']} **My Goals:** {goals} **Timeline:** {timeline} **Available Resources:** {resources} Please create a comprehensive action plan with: 1. Immediate next steps (this week) 2. Short-term milestones (1 month) 3. Medium-term objectives (3 months) 4. Resource requirements (skills, team, tools, budget) 5. Key metrics to track 6. Potential obstacles and how to overcome them Make it specific and actionable for an absolute beginner.""" history.append({"role": "user", "content": prompt}) response = chat_with_groq(prompt, ACTION_PLANNING_PROMPT, history) history.append({"role": "assistant", "content": response}) session.current_idea['action_plan'] = response session.current_idea['updated'] = datetime.now().isoformat() return format_for_chatbot(history), history, "📋 Action plan created and saved!" def export_session(): """Export all ideas""" if not session.ideas: return "No ideas to export yet. Start by discovering and evaluating ideas!", "" report = f"""# STARTUP IDEATION SESSION REPORT Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')} Total Ideas Explored: {len(session.ideas)} {'='*80} """ for i, idea in enumerate(session.ideas, 1): report += f""" ## IDEA {i}: {idea['description'][:100]}{'...' if len(idea['description']) > 100 else ''} **Target Market:** {idea['target_market']} **Problem Statement:** {idea['problem']} **Solution Approach:** {idea['solution']} **Evaluation:** {idea['evaluation']} """ if 'action_plan' in idea: report += f""" **Action Plan:** {idea['action_plan']} """ report += f"\n{'='*80}\n" json_data = json.dumps({ "export_date": datetime.now().isoformat(), "total_ideas": len(session.ideas), "ideas": session.ideas }, indent=2) return report, json_data def clear_session(): """Reset session""" global session session = IdeationSession() return "✅ Session cleared! You can start fresh.", [], [] # Build Gradio Interface with gr.Blocks(title="Startup Ideation Assistant") as app: gr.HTML("""
AI-Powered Idea Discovery, Evaluation & Planning