-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.jac
98 lines (77 loc) · 2.09 KB
/
start.jac
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
92
93
94
95
96
97
98
import:py os;
import:py logging;
import:py datetime;
import:py from jac_cloud.core.architype { NodeAnchor }
import:py from mtllm.llms { OpenAI }
with entry {
os.environ["OPEN_API_KEY"] = "PUT KEY HERE";
}
glob logger = logging.getLogger("littelX");
# Define nodes
# Define Edges
# Add Meaning-type LLM
# Define Walkers
# Profile
# Tweets
# Follow
### DO NOT MODIFY BELOW THIS LINE
### Boilerplate code for littleX ###
walker update_profile :visit_profile: {
has new_username: str;
can update_profile with profile entry {
here.username = self.new_username;
report here;
}
}
walker get_profile :visit_profile: {
can get_profile with profile entry {
report here;
}
}
walker load_user_profiles {
obj __specs__ {
static has auth: bool = False;
}
can load_profiles with `root entry {
self.profiles: list = [];
for user in NodeAnchor.Collection.find({"name": "profile"}) {
user_node = user.architype;
self.profiles.append(
{"name": user_node.username, "id": jid(user_node)}
);
}
report self.profiles;
}
}
walker un_follow_request :visit_profile: {
has profile_id: str;
can un_follow with profile entry {
here.followees.remove(self.profile_id);
logger.info(f"Followe removed: {self.profile_id}");
here del-:follow:-> &self.profile_id;
report here;
}
}
walker update_tweet :visit_profile: {
has tweet_id: str;
has updated_content: str;
can visit_tweet with profile entry {
tweet_node = &self.tweet_id;
visit tweet_node;
logger.info(f"Tweet deleted: {tweet_node}");
}
# can be enhanced to directly use the jid instead
can update_tweet with tweet entry {
here.content = self.updated_content;
report here;
}
}
walker remove_tweet :visit_profile: {
has tweet_id: str;
can remove_tweet with profile entry {
tweet_node = &self.tweet_id;
del tweet_node;
logger.info(f"Tweet deleted: {tweet_node}");
report True;
}
}