markdown-flow 0.2.9__py3-none-any.whl → 0.2.11__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.

Potentially problematic release.


This version of markdown-flow might be problematic. Click here for more details.

markdown_flow/__init__.py CHANGED
@@ -83,4 +83,4 @@ __all__ = [
83
83
  "replace_variables_in_text",
84
84
  ]
85
85
 
86
- __version__ = "0.2.9"
86
+ __version__ = "0.2.11"
markdown_flow/core.py CHANGED
@@ -478,7 +478,7 @@ class MarkdownFlow:
478
478
  error_msg = f"Please select from: {', '.join(button_displays)}"
479
479
  return self._render_error(error_msg, mode)
480
480
 
481
- # Validate input values against available buttons
481
+ # First, check if user input matches available buttons
482
482
  valid_values = []
483
483
  invalid_values = []
484
484
 
@@ -491,19 +491,30 @@ class MarkdownFlow:
491
491
  break
492
492
 
493
493
  if not matched:
494
- if allow_text_input:
495
- # Allow custom text in buttons+text mode - same as normal interactions
496
- valid_values.append(value)
497
- else:
498
- invalid_values.append(value)
499
-
500
- # Check for validation errors
501
- if invalid_values and not allow_text_input:
494
+ invalid_values.append(value)
495
+
496
+ # If there are invalid values and this interaction allows text input, use LLM validation
497
+ if invalid_values and allow_text_input:
498
+ # Use LLM validation for text input interactions
499
+ button_displays = [btn["display"] for btn in buttons]
500
+ question = parse_result.get("question", "")
501
+
502
+ return self._process_llm_validation_with_options(
503
+ block_index=0, # Not used in the method
504
+ user_input={target_variable: target_values},
505
+ target_variable=target_variable,
506
+ options=button_displays,
507
+ question=question,
508
+ mode=mode,
509
+ )
510
+
511
+ # Check for validation errors in pure button mode or when text input not allowed
512
+ if invalid_values:
502
513
  button_displays = [btn["display"] for btn in buttons]
503
514
  error_msg = f"Invalid options: {', '.join(invalid_values)}. Please select from: {', '.join(button_displays)}"
504
515
  return self._render_error(error_msg, mode)
505
516
 
506
- # Success: return validated values
517
+ # Success: return validated button values
507
518
  return LLMResult(
508
519
  content="",
509
520
  variables={target_variable: valid_values},
@@ -513,6 +524,7 @@ class MarkdownFlow:
513
524
  "valid_values": valid_values,
514
525
  "invalid_values": invalid_values,
515
526
  "total_input_count": len(target_values),
527
+ "llm_validated": False,
516
528
  },
517
529
  )
518
530
 
@@ -815,7 +827,14 @@ Original Error: {error_message}
815
827
  if match:
816
828
  prefix = match.group(1)
817
829
  suffix = match.group(2)
818
- return f"{prefix}{cleaned_question}{suffix}"
830
+ # Extract only the closing bracket from suffix, remove original question
831
+ # suffix format is "original_question]", we only want "]"
832
+ if suffix.endswith("]"):
833
+ clean_suffix = "]"
834
+ else:
835
+ clean_suffix = suffix
836
+
837
+ return f"{prefix}{cleaned_question}{clean_suffix}"
819
838
  return original_content # type: ignore[unreachable]
820
839
 
821
840
  # Dynamic Interaction Methods
@@ -1111,9 +1130,8 @@ Analyze the content and provide the structured interaction data.""")
1111
1130
  "empty_input": True,
1112
1131
  },
1113
1132
  )
1114
- else:
1115
- error_msg = f"No input provided for variable '{variable_name}'"
1116
- return self._render_error(error_msg, mode)
1133
+ error_msg = f"No input provided for variable '{variable_name}'"
1134
+ return self._render_error(error_msg, mode)
1117
1135
 
1118
1136
  # Use the same validation logic as normal interactions
1119
1137
  if interaction_type in [
@@ -1132,7 +1150,7 @@ Analyze the content and provide the structured interaction data.""")
1132
1150
  )
1133
1151
 
1134
1152
  # Merge with existing variables for dynamic interactions
1135
- if hasattr(button_result, 'variables') and button_result.variables is not None and variables:
1153
+ if hasattr(button_result, "variables") and button_result.variables is not None and variables:
1136
1154
  merged_variables = dict(variables)
1137
1155
  merged_variables.update(button_result.variables)
1138
1156
  return LLMResult(
@@ -1142,7 +1160,7 @@ Analyze the content and provide the structured interaction data.""")
1142
1160
  )
1143
1161
  return button_result
1144
1162
 
1145
- elif interaction_type == InteractionType.NON_ASSIGNMENT_BUTTON:
1163
+ if interaction_type == InteractionType.NON_ASSIGNMENT_BUTTON:
1146
1164
  # Non-assignment buttons: don't set variables, keep existing ones
1147
1165
  return LLMResult(
1148
1166
  content="",
@@ -1152,16 +1170,15 @@ Analyze the content and provide the structured interaction data.""")
1152
1170
  "user_input": user_input,
1153
1171
  },
1154
1172
  )
1155
- else:
1156
- # Text-only input type - merge with existing variables
1157
- merged_variables = dict(variables or {})
1158
- merged_variables[variable_name] = target_values
1159
- return LLMResult(
1160
- content="",
1161
- variables=merged_variables,
1162
- metadata={
1163
- "interaction_type": "text_only",
1164
- "target_variable": variable_name,
1165
- "values": target_values,
1166
- },
1167
- )
1173
+ # Text-only input type - merge with existing variables
1174
+ merged_variables = dict(variables or {})
1175
+ merged_variables[variable_name] = target_values
1176
+ return LLMResult(
1177
+ content="",
1178
+ variables=merged_variables,
1179
+ metadata={
1180
+ "interaction_type": "text_only",
1181
+ "target_variable": variable_name,
1182
+ "values": target_values,
1183
+ },
1184
+ )
markdown_flow/llm.py CHANGED
@@ -5,7 +5,7 @@ Provides LLM provider interfaces and related data models, supporting multiple pr
5
5
  """
6
6
 
7
7
  from abc import ABC, abstractmethod
8
- from collections.abc import AsyncGenerator, Generator
8
+ from collections.abc import Generator
9
9
  from dataclasses import dataclass
10
10
  from enum import Enum
11
11
  from typing import Any
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdown-flow
3
- Version: 0.2.9
3
+ Version: 0.2.11
4
4
  Summary: An agent library designed to parse and process MarkdownFlow documents
5
5
  Project-URL: Homepage, https://github.com/ai-shifu/markdown-flow-agent-py
6
6
  Project-URL: Bug Tracker, https://github.com/ai-shifu/markdown-flow-agent-py/issues
@@ -0,0 +1,13 @@
1
+ markdown_flow/__init__.py,sha256=xKyJPYz2k6AvfCx8QuffJe8WIS9PPMgXkpR7n-1s0Cc,2875
2
+ markdown_flow/constants.py,sha256=pd_KCpTEVlz_IXYekrByqb9VWCQR_XHXoGsFYdLW1Eg,8006
3
+ markdown_flow/core.py,sha256=xeE35QzNRURw6nIongn5tW5Z7u4xP_CkNFrBiLrfpmY,49371
4
+ markdown_flow/enums.py,sha256=Wr41zt0Ce5b3fyLtOTE2erEVp1n92g9OVaBF_BZg_l8,820
5
+ markdown_flow/exceptions.py,sha256=9sUZ-Jd3CPLdSRqG8Pw7eMm7cv_S3VZM6jmjUU8OhIc,976
6
+ markdown_flow/llm.py,sha256=MhllCwqzrN_RtIG-whfdkNk6e0WQ2H6RJVCRv3lNM_0,2531
7
+ markdown_flow/models.py,sha256=ENcvXMVXwpFN-RzbeVHhXTjBN0bbmRpJ96K-XS2rizI,2893
8
+ markdown_flow/utils.py,sha256=cVi0zDRK_rCMAr3EDhgITmx6Po5fSvYjqrprYaitYE0,28450
9
+ markdown_flow-0.2.11.dist-info/licenses/LICENSE,sha256=qz3BziejhHPd1xa5eVtYEU5Qp6L2pn4otuj194uGxmc,1069
10
+ markdown_flow-0.2.11.dist-info/METADATA,sha256=DMbPePTA9ZK5wOgrm7X9tjyGAiXbVB2v3rqGM9EzbHg,24287
11
+ markdown_flow-0.2.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
+ markdown_flow-0.2.11.dist-info/top_level.txt,sha256=DpigGvQuIt2L0TTLnDU5sylhiTGiZS7MmAMa2hi-AJs,14
13
+ markdown_flow-0.2.11.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- markdown_flow/__init__.py,sha256=zeJ4ycW4uPIIRp3sFbh_FPn-jUXSuZk6wUqnrls_6r0,2874
2
- markdown_flow/constants.py,sha256=pd_KCpTEVlz_IXYekrByqb9VWCQR_XHXoGsFYdLW1Eg,8006
3
- markdown_flow/core.py,sha256=-cJBzyeL5dWs-iI_-7vnBstIt0GEhkmiyve0wXunedg,48618
4
- markdown_flow/enums.py,sha256=Wr41zt0Ce5b3fyLtOTE2erEVp1n92g9OVaBF_BZg_l8,820
5
- markdown_flow/exceptions.py,sha256=9sUZ-Jd3CPLdSRqG8Pw7eMm7cv_S3VZM6jmjUU8OhIc,976
6
- markdown_flow/llm.py,sha256=7DjOL2h2N1g0L4NF9kn0M5mR45ZL0vPsW3TzuOGy1bw,2547
7
- markdown_flow/models.py,sha256=ENcvXMVXwpFN-RzbeVHhXTjBN0bbmRpJ96K-XS2rizI,2893
8
- markdown_flow/utils.py,sha256=cVi0zDRK_rCMAr3EDhgITmx6Po5fSvYjqrprYaitYE0,28450
9
- markdown_flow-0.2.9.dist-info/licenses/LICENSE,sha256=qz3BziejhHPd1xa5eVtYEU5Qp6L2pn4otuj194uGxmc,1069
10
- markdown_flow-0.2.9.dist-info/METADATA,sha256=T4V_MG3pWdsXOcHkk5jDPcPQCwMSRn_GKkkfso4wh-U,24286
11
- markdown_flow-0.2.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
- markdown_flow-0.2.9.dist-info/top_level.txt,sha256=DpigGvQuIt2L0TTLnDU5sylhiTGiZS7MmAMa2hi-AJs,14
13
- markdown_flow-0.2.9.dist-info/RECORD,,