-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathutils.py
44 lines (36 loc) · 1.23 KB
/
utils.py
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
def is_ready_for_train(groupchat, client):
messages = (
[
{
"role": "system",
"content": """Based on the dataset exploration, and the data processing, please determine whether the data is ready for model training.
Please give a short summary of what we know about the dataset and what we have done so far.
Please follow this format:
Summary: <Your summary>
Decision: <choose from "Ready for training" or "Need more processing">
""",
}
]
+ groupchat.messages
)
response = client.create(messages=messages)
response_str = client.extract_text_or_completion_object(response)[0]
print("-" * 50)
print(response_str)
print("-" * 50)
if "ready for training" in response_str.lower():
return True
return False
def count_train_trials(groupchat):
messages = groupchat.messages
tcount = 0
for i, message in enumerate(messages):
if message["name"] == "Model_Trainer":
tcount += 1
elif (
message["name"] == "Code_Executor"
and "exitcode: 1" in message["content"]
and messages[i - 1]["name"] == "Model_Trainer"
):
tcount -= 1
return tcount