-
Notifications
You must be signed in to change notification settings - Fork 523
Expand file tree
/
Copy pathadmin_tools.py
More file actions
41 lines (36 loc) · 1.15 KB
/
admin_tools.py
File metadata and controls
41 lines (36 loc) · 1.15 KB
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
from langchain.tools import tool
from typing import List, Dict
# Simulated Course and User DB
ALL_COURSES = {
"python101": "Intro to Python",
"ml202": "Machine Learning Fundamentals",
"dl301": "Deep Learning with PyTorch"
}
ALL_USERS = {
"user_001": "admin",
"user_002": "learner",
"user_003": "mentor"
}
@tool
def list_all_courses() -> List[str]:
"""
List all available courses in the platform (Admin only).
"""
return list(ALL_COURSES.values())
@tool
def manage_users(action: str, target_user: str, new_role: str = "") -> Dict:
"""
Simulate user management operations (Admin only).
Supported actions: 'view', 'update'
"""
if target_user not in ALL_USERS:
return {"error": "User not found"}
if action == "view":
return {target_user: ALL_USERS[target_user]}
elif action == "update":
if not new_role:
return {"error": "New role must be specified for update"}
ALL_USERS[target_user] = new_role
return {"message": f"Role updated to '{new_role}' for user '{target_user}'"}
else:
return {"error": "Unsupported action. Use 'view' or 'update'"}