Spaces:
Sleeping
Sleeping
File size: 1,368 Bytes
6859bba | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | import re
def clean_text(text: str | None) -> str:
"""Normalize text for model input.
- Strips leading/trailing whitespace
- Collapses multiple whitespace into single spaces
- Removes non-printable characters
"""
if not text:
return ""
text = re.sub(r"[^\S ]+", " ", text) # non-space whitespace → space
text = re.sub(r" {2,}", " ", text) # collapse multiple spaces
return text.strip()
def build_task_prompt(title: str, description: str | None, tags: list[str]) -> str:
"""Build a structured prompt string from task fields.
Used by the decomposition model to understand the task context.
"""
parts = [f"Task: {clean_text(title)}"]
desc = clean_text(description)
if desc:
parts.append(f"Description: {desc}")
if tags:
parts.append(f"Tags: {', '.join(tags)}")
return "\n".join(parts)
def build_member_profile(
name: str,
skills: list[str],
skill_levels: dict[str, str],
role: str,
) -> str:
"""Build a text profile for a team member (used by assigner embedding)."""
skill_parts = []
for s in skills:
level = skill_levels.get(s, "intermediate")
skill_parts.append(f"{s} ({level})")
skills_str = ", ".join(skill_parts) if skill_parts else "no listed skills"
return f"{name} | role: {role} | skills: {skills_str}"
|