-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathresume_sim.py
More file actions
117 lines (101 loc) · 3.43 KB
/
resume_sim.py
File metadata and controls
117 lines (101 loc) · 3.43 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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import pandas as pd
from short_term_memory import short_term_memory
from long_term_memory import long_term_memory
def get_iteration():
try:
res = short_term_memory.get(
where={
"Iteration": {
"$gte": 0
}
},
include=["metadatas"],
)
iterations = [metadata['Iteration'] for metadata in res['metadatas']]
if not iterations:
max_iteration = 0
else:
max_iteration = max(iterations)
return max_iteration
except Exception as e:
print("Vector search failed : ", e)
def load_actions_dict(csv_file_path):
actions_dict = []
df = pd.read_csv(csv_file_path)
for index, row in df.iterrows():
actions_dict.append({
'Iteration': row['Iteration'],
'Agent': row['Agent'],
'Choice': row['Choice'],
'Reason': row['Reason'],
'Content': row['Content']
})
return actions_dict
def load_comments_dict(csv_file_path):
comments_dict = []
df = pd.read_csv(csv_file_path)
for index, row in df.iterrows():
comments_dict.append({
'Iteration': row['Iteration'],
'Commenting Agent': row['Commenting Agent'],
'Source Agent': row['Source Agent'],
'Content': row['Content'],
'Comment History': row['Comment History'],
'Number of Comments': int(row['Number of Comments'])
})
return comments_dict
def load_connections_dict(csv_file_path):
connections_dict = []
df = pd.read_csv(csv_file_path)
for index, row in df.iterrows():
connections_dict.append({
'Iteration': row['Iteration'],
'Agent': row['Agent'],
'Followed Agent': row['Followed Agent'],
})
return connections_dict
def load_interviews_dict(csv_file_path):
interviews_dict = []
df = pd.read_csv(csv_file_path)
for index, row in df.iterrows():
interviews_dict.append({
'Iteration': row['Iteration'],
'Agent': row['Agent'],
'Main Influence': row['Main Influence'],
'Explanation': row['Explanation']
})
return interviews_dict
def load_stm(csv_file_path):
df = pd.read_csv(csv_file_path)
ids: list = []
metadatas: list = []
documents: list = []
for index, row in df.iterrows():
ids.append(row['ID'])
metadatas.append({"Author": row['Author'], "Virality Score": row['Virality Score'], "Sentiment Score": row['Sentiment Score'], "Iteration": row['Iteration']})
documents.append(row['Document'])
try:
short_term_memory.add(
ids=ids,
metadatas=metadatas,
documents=documents
)
except Exception as e:
print("Add data to db failed: ", e)
def load_ltm(csv_file_path):
df = pd.read_csv(csv_file_path)
ids: list = []
metadatas: list = []
documents: list = []
for index, row in df.iterrows():
ids.append(row['ID'])
metadatas.append({"Author": row['Author'], "Virality Score": row['Virality Score'], "Sentiment Score": row['Sentiment Score'], "Iteration": row['Iteration']})
documents.append(row['Document'])
try:
long_term_memory.add(
ids=ids,
metadatas=metadatas,
documents=documents
)
except Exception as e:
print("Add data to db failed: ", e)