Create utilities.py
Browse files- utilities.py +21 -0
utilities.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def preprocess_features(data):
|
2 |
+
# Example of building a simple structured representation
|
3 |
+
text = (
|
4 |
+
f"Industry: {data.get('industry')}. "
|
5 |
+
f"Stage: {data.get('stage')}. "
|
6 |
+
f"Amount: {data.get('amount')} USD. "
|
7 |
+
f"Lead Score: {data.get('lead_score')}. "
|
8 |
+
f"{data.get('emails_last_7_days', 0)} emails in last 7 days. "
|
9 |
+
f"{data.get('meetings_last_30_days', 0)} meetings in last 30 days."
|
10 |
+
)
|
11 |
+
return {"text": text}
|
12 |
+
|
13 |
+
def generate_recommendation(summarizer, data):
|
14 |
+
prompt = (
|
15 |
+
f"Generate a next action for a deal at stage {data['stage']} with "
|
16 |
+
f"{data['emails_last_7_days']} emails and {data['meetings_last_30_days']} meetings."
|
17 |
+
)
|
18 |
+
input_ids = summarizer.tokenizer(prompt, return_tensors="pt").input_ids
|
19 |
+
output_ids = summarizer.generate(input_ids, max_new_tokens=30)
|
20 |
+
summary = summarizer.tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
21 |
+
return summary
|