multi-agent-system / app /core /preprocessor.py
firepenguindisopanda
updated with new prompts and new workflow to generate a document
94f31ec
Raw
History Blame Contribute Delete
3.63 kB
"""
Input Pre-processor
Deterministic transformation that extracts key information from raw project
descriptions and formats as a structured brief for the Product Owner agent.
Replaces the project_refiner agent with a zero-LLM-call alternative.
"""
def preprocess_input(description: str) -> str:
"""
Extract key information from a raw project description and format
as a structured brief for the Product Owner agent.
Args:
description: Raw project description from user
Returns:
Structured brief string
"""
if not description or not description.strip():
return "No project description provided."
# Extract potential project type indicators
project_types = {
"web application": "Web Application",
"mobile app": "Mobile Application",
"api": "API Service",
"dashboard": "Dashboard",
"e-commerce": "E-Commerce Platform",
"saas": "SaaS Platform",
"cms": "Content Management System",
"crm": "CRM System",
"tutoring": "Educational Platform",
"learning": "Educational Platform",
"social": "Social Platform",
"analytics": "Analytics Platform",
}
desc_lower = description.lower()
detected_type = "General Software Project"
for keyword, ptype in project_types.items():
if keyword in desc_lower:
detected_type = ptype
break
# Extract potential audience indicators
audience_indicators = {
"students": "Students and educators",
"teachers": "Teachers and educators",
"enterprise": "Enterprise users",
"consumer": "General consumers",
"developer": "Developers",
"admin": "Administrators",
"manager": "Managers and team leads",
"professional": "Professionals",
"team": "Teams and organizations",
}
detected_audience = "Not specified"
for keyword, audience in audience_indicators.items():
if keyword in desc_lower:
detected_audience = audience
break
# Count potential feature indicators
feature_keywords = [
"authentication",
"login",
"signup",
"dashboard",
"report",
"notification",
"search",
"filter",
"upload",
"download",
"payment",
"subscription",
"analytics",
"admin",
"api",
"integration",
"export",
"import",
"chat",
"messaging",
"calendar",
"scheduling",
"workflow",
"automation",
]
detected_features = [kw for kw in feature_keywords if kw in desc_lower]
# Extract constraint indicators
constraint_keywords = [
"must use",
"required to use",
"existing",
"legacy",
"compliance",
"gdpr",
"hipaa",
"soc2",
"budget",
"timeline",
"deadline",
"limited",
"constraint",
]
detected_constraints = [kw for kw in constraint_keywords if kw in desc_lower]
# Build structured brief
brief_parts = [
f"**Project Type:** {detected_type}",
f"**Target Audience:** {detected_audience}",
f"**Key Features Detected:** {', '.join(detected_features) if detected_features else 'To be determined from full description'}",
f"**Potential Constraints:** {', '.join(detected_constraints) if detected_constraints else 'None explicitly stated'}",
"",
"**Full Description:**",
description.strip(),
]
return "\n".join(brief_parts)