agentle 0.9.32__py3-none-any.whl → 0.9.33__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agentle/agents/whatsapp/whatsapp_bot.py +54 -22
- {agentle-0.9.32.dist-info → agentle-0.9.33.dist-info}/METADATA +1 -1
- {agentle-0.9.32.dist-info → agentle-0.9.33.dist-info}/RECORD +5 -5
- {agentle-0.9.32.dist-info → agentle-0.9.33.dist-info}/WHEEL +0 -0
- {agentle-0.9.32.dist-info → agentle-0.9.33.dist-info}/licenses/LICENSE +0 -0
|
@@ -2041,7 +2041,7 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
|
|
|
2041
2041
|
This method converts:
|
|
2042
2042
|
- Headers (# ## ###) to bold text with separators
|
|
2043
2043
|
- Tables to formatted text
|
|
2044
|
-
- Markdown lists to plain text lists
|
|
2044
|
+
- Markdown lists to plain text lists (preserving line breaks)
|
|
2045
2045
|
- Links to "text (url)" format
|
|
2046
2046
|
- Images to descriptive text
|
|
2047
2047
|
- Blockquotes to indented text
|
|
@@ -2111,7 +2111,7 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
|
|
|
2111
2111
|
i += 1
|
|
2112
2112
|
continue
|
|
2113
2113
|
|
|
2114
|
-
# Process regular line
|
|
2114
|
+
# Process regular line (preserve empty lines for spacing)
|
|
2115
2115
|
processed_lines.append(line)
|
|
2116
2116
|
i += 1
|
|
2117
2117
|
|
|
@@ -2119,7 +2119,7 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
|
|
|
2119
2119
|
if table_lines:
|
|
2120
2120
|
processed_lines.extend(self._format_table(table_lines))
|
|
2121
2121
|
|
|
2122
|
-
# Rejoin lines
|
|
2122
|
+
# Rejoin lines - CRITICAL: preserve all line breaks
|
|
2123
2123
|
text = "\n".join(processed_lines)
|
|
2124
2124
|
|
|
2125
2125
|
# Handle inline markdown elements
|
|
@@ -2698,22 +2698,32 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
|
|
|
2698
2698
|
|
|
2699
2699
|
if is_list_paragraph:
|
|
2700
2700
|
# Group list items together instead of splitting each line
|
|
2701
|
+
# IMPORTANT: Keep line breaks intact for list formatting
|
|
2701
2702
|
grouped_list = self._group_list_items(lines)
|
|
2702
2703
|
messages.extend(grouped_list)
|
|
2703
2704
|
else:
|
|
2704
|
-
# For non-list paragraphs,
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2705
|
+
# For non-list paragraphs, keep the whole paragraph together if possible
|
|
2706
|
+
paragraph_text = paragraph.strip()
|
|
2707
|
+
if not paragraph_text:
|
|
2708
|
+
continue
|
|
2709
|
+
|
|
2710
|
+
# Check if paragraph fits within message length limits
|
|
2711
|
+
if len(paragraph_text) <= self.config.max_message_length:
|
|
2712
|
+
messages.append(paragraph_text)
|
|
2713
|
+
else:
|
|
2714
|
+
# Split by individual lines only if paragraph is too long
|
|
2715
|
+
for line in lines:
|
|
2716
|
+
line = line.strip()
|
|
2717
|
+
if not line:
|
|
2718
|
+
continue
|
|
2719
|
+
|
|
2720
|
+
# Check if this line fits within message length limits
|
|
2721
|
+
if len(line) <= self.config.max_message_length:
|
|
2722
|
+
messages.append(line)
|
|
2723
|
+
else:
|
|
2724
|
+
# Split long lines by length
|
|
2725
|
+
split_lines = self._split_long_line(line)
|
|
2726
|
+
messages.extend(split_lines)
|
|
2717
2727
|
|
|
2718
2728
|
# Filter out empty messages and validate
|
|
2719
2729
|
final_messages = []
|
|
@@ -2826,7 +2836,13 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
|
|
|
2826
2836
|
return chunks
|
|
2827
2837
|
|
|
2828
2838
|
def _is_list_content(self, lines: Sequence[str]) -> bool:
|
|
2829
|
-
"""Check if lines contain list markers (numbered or bullet points).
|
|
2839
|
+
"""Check if lines contain list markers (numbered or bullet points).
|
|
2840
|
+
|
|
2841
|
+
Detects various list formats including:
|
|
2842
|
+
- Numbered lists: "1.", "2)", "1 -"
|
|
2843
|
+
- Bullet points: "•", "*", "-", "→"
|
|
2844
|
+
- Indented sub-items
|
|
2845
|
+
"""
|
|
2830
2846
|
if not lines:
|
|
2831
2847
|
return False
|
|
2832
2848
|
|
|
@@ -2844,13 +2860,20 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
|
|
|
2844
2860
|
# Check for bullet points: "•", "*", "-", "→", etc.
|
|
2845
2861
|
elif re.match(r"^[•\*\-→▪►]\s", stripped):
|
|
2846
2862
|
list_markers += 1
|
|
2863
|
+
# Check for indented items (common in nested lists)
|
|
2864
|
+
elif re.match(r"^\s+[•\*\-→▪►]\s", line):
|
|
2865
|
+
list_markers += 1
|
|
2847
2866
|
|
|
2848
|
-
# If more than
|
|
2867
|
+
# If more than 30% of non-empty lines are list items, consider it a list
|
|
2868
|
+
# Lowered threshold to catch lists with headers/descriptions
|
|
2849
2869
|
non_empty_lines = sum(1 for line in lines if line.strip())
|
|
2850
|
-
return non_empty_lines > 0 and (list_markers / non_empty_lines) >= 0.
|
|
2870
|
+
return non_empty_lines > 0 and (list_markers / non_empty_lines) >= 0.3
|
|
2851
2871
|
|
|
2852
2872
|
def _group_list_items(self, lines: Sequence[str]) -> Sequence[str]:
|
|
2853
|
-
"""Group list items together to avoid splitting each item into a separate message.
|
|
2873
|
+
"""Group list items together to avoid splitting each item into a separate message.
|
|
2874
|
+
|
|
2875
|
+
CRITICAL: Preserves line breaks between list items for proper WhatsApp formatting.
|
|
2876
|
+
"""
|
|
2854
2877
|
if not lines:
|
|
2855
2878
|
return []
|
|
2856
2879
|
|
|
@@ -2859,8 +2882,15 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
|
|
|
2859
2882
|
current_length = 0
|
|
2860
2883
|
|
|
2861
2884
|
for line in lines:
|
|
2862
|
-
line
|
|
2885
|
+
# Don't strip the line completely - preserve leading spaces for indentation
|
|
2886
|
+
# But remove trailing whitespace
|
|
2887
|
+
line = line.rstrip()
|
|
2888
|
+
|
|
2889
|
+
# Skip completely empty lines but preserve them in the group for spacing
|
|
2863
2890
|
if not line:
|
|
2891
|
+
# Add empty line to group for spacing between items
|
|
2892
|
+
if current_group:
|
|
2893
|
+
current_group.append("")
|
|
2864
2894
|
continue
|
|
2865
2895
|
|
|
2866
2896
|
# Calculate potential length if we add this line
|
|
@@ -2870,6 +2900,7 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
|
|
|
2870
2900
|
|
|
2871
2901
|
# If adding this line would exceed the limit, save current group and start new one
|
|
2872
2902
|
if potential_length > self.config.max_message_length and current_group:
|
|
2903
|
+
# Join with newlines to preserve line breaks
|
|
2873
2904
|
messages.append("\n".join(current_group))
|
|
2874
2905
|
current_group = [line]
|
|
2875
2906
|
current_length = len(line)
|
|
@@ -2879,6 +2910,7 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
|
|
|
2879
2910
|
|
|
2880
2911
|
# Add remaining group
|
|
2881
2912
|
if current_group:
|
|
2913
|
+
# Join with newlines to preserve line breaks
|
|
2882
2914
|
messages.append("\n".join(current_group))
|
|
2883
2915
|
|
|
2884
2916
|
return messages
|
|
@@ -3369,7 +3401,7 @@ class WhatsAppBot[T_Schema: WhatsAppResponseBase = WhatsAppResponseBase](BaseMod
|
|
|
3369
3401
|
|
|
3370
3402
|
message = self._parse_evolution_message_from_data(
|
|
3371
3403
|
data,
|
|
3372
|
-
from_number=payload.data.key.remoteJidAlt
|
|
3404
|
+
from_number=payload.data.key.remoteJidAlt or ""
|
|
3373
3405
|
if "@lid" in payload.data.key.remoteJid
|
|
3374
3406
|
else payload.data.key.remoteJid,
|
|
3375
3407
|
)
|
|
@@ -137,7 +137,7 @@ agentle/agents/ui/__init__.py,sha256=IjHRV0k2DNwvFrEHebmsXiBvmITE8nQUnsR07h9tVkU
|
|
|
137
137
|
agentle/agents/ui/streamlit.py,sha256=9afICL0cxtG1o2pWh6vH39-NdKiVfADKiXo405F2aB0,42829
|
|
138
138
|
agentle/agents/whatsapp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
139
139
|
agentle/agents/whatsapp/human_delay_calculator.py,sha256=BGCDeoNTPsMn4d_QYmG0BWGCG8SiUJC6Fk295ulAsAk,18268
|
|
140
|
-
agentle/agents/whatsapp/whatsapp_bot.py,sha256=
|
|
140
|
+
agentle/agents/whatsapp/whatsapp_bot.py,sha256=2WmNPeTFxN3gyCmSo2o_ZVjXYtxCw0S3Z0W3TTCKnJg,163642
|
|
141
141
|
agentle/agents/whatsapp/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
142
142
|
agentle/agents/whatsapp/models/audio_message.py,sha256=kUqG1HdNW6DCYD-CqscJ6WHlAyv9ufmTSKMdjio9XWk,2705
|
|
143
143
|
agentle/agents/whatsapp/models/context_info.py,sha256=sk80KuNE36S6VRnLh7n6UXmzZCXIB4E4lNxnRyVizg8,563
|
|
@@ -1018,7 +1018,7 @@ agentle/web/actions/scroll.py,sha256=WqVVAORNDK3BL1oASZBPmXJYeSVkPgAOmWA8ibYO82I
|
|
|
1018
1018
|
agentle/web/actions/viewport.py,sha256=KCwm88Pri19Qc6GLHC69HsRxmdJz1gEEAODfggC_fHo,287
|
|
1019
1019
|
agentle/web/actions/wait.py,sha256=IKEywjf-KC4ni9Gkkv4wgc7bY-hk7HwD4F-OFWlyf2w,571
|
|
1020
1020
|
agentle/web/actions/write_text.py,sha256=9mxfHcpKs_L7BsDnJvOYHQwG8M0GWe61SRJAsKk3xQ8,748
|
|
1021
|
-
agentle-0.9.
|
|
1022
|
-
agentle-0.9.
|
|
1023
|
-
agentle-0.9.
|
|
1024
|
-
agentle-0.9.
|
|
1021
|
+
agentle-0.9.33.dist-info/METADATA,sha256=t7nLpdc3KL1qtk-eDYCAnWDl37Ju9-WrtjL8RJeDD4I,86849
|
|
1022
|
+
agentle-0.9.33.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
1023
|
+
agentle-0.9.33.dist-info/licenses/LICENSE,sha256=T90S9vqRS6qP-voULxAcvwEs558wRRo6dHuZrjgcOUI,1085
|
|
1024
|
+
agentle-0.9.33.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|