File size: 3,141 Bytes
4fd18a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
"""Profile tool for managing user profiles - profile.upsert endpoint."""

from typing import Dict, Any

from ..services import ProfileService


class ProfileTool:
    """Tool for managing user profiles."""

    def __init__(self):
        self.profile_service = ProfileService()

    def upsert(self, user_id: str, profile_data: str) -> Dict[str, Any]:
        """
        Store or update user profile.

        This is the main profile.upsert endpoint that stores the user résumé,
        skills, salary expectations, and career goals.

        Args:
            user_id: Unique identifier for the user
            profile_data: JSON string containing user profile information
                Expected format:
                {
                    "resume": "Full resume text...",
                    "skills": ["Python", "JavaScript", "React", ...],
                    "salary_wish": "$80,000 - $120,000 annually",
                    "career_goals": "Looking to transition into senior developer role...",
                    "experience_level": "Mid-level",  # Optional
                    "location": "Remote",             # Optional
                    "education": "BS Computer Science", # Optional
                    "certifications": ["AWS Certified"] # Optional
                }

        Returns:
            Dict with success status, message, and profile metadata
        """
        return self.profile_service.upsert_profile(user_id, profile_data)

    def get(self, user_id: str) -> Dict[str, Any]:
        """
        Get user profile by ID.

        Args:
            user_id: Unique user identifier

        Returns:
            Dict with profile data or error message
        """
        try:
            profile = self.profile_service.get_profile(user_id)
            if profile:
                return {"success": True, "profile": profile.dict()}
            else:
                return {"success": False, "message": "Profile not found"}
        except Exception as e:
            return {"success": False, "message": f"Error retrieving profile: {str(e)}"}

    def delete(self, user_id: str) -> Dict[str, Any]:
        """
        Delete user profile.

        Args:
            user_id: Unique user identifier

        Returns:
            Dict with operation result
        """
        try:
            deleted = self.profile_service.delete_profile(user_id)
            if deleted:
                return {"success": True, "message": "Profile deleted successfully"}
            else:
                return {"success": False, "message": "Profile not found"}
        except Exception as e:
            return {"success": False, "message": f"Error deleting profile: {str(e)}"}

    def list_all(self) -> Dict[str, Any]:
        """
        List all user IDs with profiles.

        Returns:
            Dict with list of user IDs
        """
        try:
            user_ids = self.profile_service.list_profiles()
            return {"success": True, "user_ids": user_ids, "count": len(user_ids)}
        except Exception as e:
            return {"success": False, "message": f"Error listing profiles: {str(e)}"}