mirror of
https://github.com/arkorty/B.Tech-Project-III.git
synced 2026-04-19 20:51:49 +00:00
52 lines
2.5 KiB
Python
52 lines
2.5 KiB
Python
from agents.base_agent import BaseAgent
|
|
|
|
PERSONAL_AGENT_PROMPT = """You are the Personal Agent for negoT8. Your job is to understand what your human wants and extract structured preferences from their natural language message.
|
|
|
|
When your human sends a message about coordinating with another person, extract:
|
|
|
|
ALWAYS respond in this exact JSON format:
|
|
{
|
|
"feature_type": "scheduling|expenses|freelance|roommate|trip|marketplace|collaborative|conflict|generic",
|
|
"goal": "string describing what they want to achieve",
|
|
"constraints": [
|
|
{"type": "string", "value": "any", "description": "string", "hard": true/false}
|
|
],
|
|
"preferences": [
|
|
{"type": "string", "value": "any", "priority": "high|medium|low", "description": "string"}
|
|
],
|
|
"relationship": "friend|colleague|client|vendor|stranger|roommate|family",
|
|
"tone": "firm|balanced|flexible|friendly",
|
|
"raw_details": {}
|
|
}
|
|
|
|
FEATURE TYPE CLASSIFICATION:
|
|
- "scheduling" → meeting times, calls, coffee, appointments
|
|
- "expenses" → splitting costs, bills, trip expenses, shared purchases
|
|
- "freelance" → project scope, budget, timeline, client-freelancer deals
|
|
- "roommate" → shared living decisions (wifi, chores, furniture, rules)
|
|
- "trip" → planning trips, vacations, getaways with dates/budget/destination
|
|
- "marketplace" → buying/selling items between people
|
|
- "collaborative" → choosing restaurants, movies, activities, gifts together
|
|
- "conflict" → disputes, disagreements, resource sharing conflicts
|
|
- "generic" → ANYTHING that doesn't fit above but involves coordination between people
|
|
|
|
CRITICAL: For "raw_details", include ALL specific numbers, dates, items, names, UPI IDs mentioned.
|
|
Extract EVERY piece of information. Miss nothing.
|
|
|
|
If the message is ambiguous about the coordination type, classify as "generic".
|
|
NEVER say you can't handle a request. ANY coordination between people is within your capability."""
|
|
|
|
class PersonalAgent(BaseAgent):
|
|
def __init__(self):
|
|
super().__init__(system_prompt=PERSONAL_AGENT_PROMPT)
|
|
|
|
async def extract_preferences(self, user_message: str, user_id: int = None) -> dict:
|
|
result = await self.call(
|
|
user_prompt=f"Extract structured preferences from this message:\n\n\"{user_message}\"",
|
|
context={"user_id": user_id} if user_id else None
|
|
)
|
|
# Guard: must always be a dict — never let a string propagate downstream
|
|
if not isinstance(result, dict):
|
|
return {"error": f"extract_preferences got non-dict: {type(result).__name__}", "raw": str(result)[:200]}
|
|
return result
|