Spaces:
Runtime error
Runtime error
Download app/utils/response_builder.py from VcRlAgent/workwise-backend-gpu: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/spaces/VcRlAgent/workwise-backend-gpu/resolve/main/app/utils/response_builder.py
- Command line
-
hf download hf://spaces/VcRlAgent/workwise-backend-gpu/app/utils/response_builder.py
-
curl -L -o response_builder.py https://huggingface.co/spaces/VcRlAgent/workwise-backend-gpu/resolve/main/app/utils/response_builder.py
1.14 kB
| """Helper functions for building API responses""" | |
| from typing import Optional, List, Dict, Any | |
| from app.models.jira_schema import QueryResponse, ChartData | |
| def build_query_response( | |
| answer: str, | |
| chart_type: Optional[str] = None, | |
| chart_data: Optional[List[Dict]] = None, | |
| sources: Optional[List[str]] = None | |
| ) -> QueryResponse: | |
| """Build a structured query response""" | |
| chart = None | |
| if chart_type and chart_data: | |
| chart = ChartData(type=chart_type, data=chart_data) | |
| return QueryResponse( | |
| answer=answer, | |
| chart=chart, | |
| sources=sources | |
| ) | |
| def extract_chart_intent(query: str) -> Optional[str]: | |
| """Determine if query requires visualization""" | |
| chart_keywords = { | |
| "bar": ["compare", "by project", "breakdown", "distribution"], | |
| "line": ["trend", "over time", "timeline", "progress"], | |
| "pie": ["percentage", "proportion", "share"] | |
| } | |
| query_lower = query.lower() | |
| for chart_type, keywords in chart_keywords.items(): | |
| if any(keyword in query_lower for keyword in keywords): | |
| return chart_type | |
| return None | |