markdown-flow 0.2.16__py3-none-any.whl → 0.2.17__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 +1 -1
- markdown_flow/constants.py +43 -18
- markdown_flow/core.py +71 -502
- markdown_flow/llm.py +7 -9
- markdown_flow/utils.py +6 -8
- {markdown_flow-0.2.16.dist-info → markdown_flow-0.2.17.dist-info}/METADATA +36 -118
- markdown_flow-0.2.17.dist-info/RECORD +13 -0
- markdown_flow-0.2.16.dist-info/RECORD +0 -13
- {markdown_flow-0.2.16.dist-info → markdown_flow-0.2.17.dist-info}/WHEEL +0 -0
- {markdown_flow-0.2.16.dist-info → markdown_flow-0.2.17.dist-info}/licenses/LICENSE +0 -0
- {markdown_flow-0.2.16.dist-info → markdown_flow-0.2.17.dist-info}/top_level.txt +0 -0
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
|
|
8
|
+
from collections.abc import AsyncGenerator
|
|
9
9
|
from dataclasses import dataclass
|
|
10
10
|
from enum import Enum
|
|
11
11
|
from typing import Any
|
|
@@ -29,7 +29,6 @@ class LLMResult:
|
|
|
29
29
|
prompt: str | None = None # Used prompt
|
|
30
30
|
variables: dict[str, str | list[str]] | None = None # Extracted variables
|
|
31
31
|
metadata: dict[str, Any] | None = None # Metadata
|
|
32
|
-
transformed_to_interaction: bool = False # Whether content block was transformed to interaction block
|
|
33
32
|
|
|
34
33
|
def __bool__(self):
|
|
35
34
|
"""Support boolean evaluation."""
|
|
@@ -40,23 +39,22 @@ class LLMProvider(ABC):
|
|
|
40
39
|
"""Abstract LLM provider interface."""
|
|
41
40
|
|
|
42
41
|
@abstractmethod
|
|
43
|
-
def complete(self, messages: list[dict[str, str]]
|
|
42
|
+
async def complete(self, messages: list[dict[str, str]]) -> str:
|
|
44
43
|
"""
|
|
45
|
-
Non-streaming LLM call
|
|
44
|
+
Non-streaming LLM call.
|
|
46
45
|
|
|
47
46
|
Args:
|
|
48
47
|
messages: Message list in format [{"role": "system/user/assistant", "content": "..."}]
|
|
49
|
-
tools: Optional tools/functions for LLM to call
|
|
50
48
|
|
|
51
49
|
Returns:
|
|
52
|
-
|
|
50
|
+
str: LLM response content
|
|
53
51
|
|
|
54
52
|
Raises:
|
|
55
53
|
ValueError: When LLM call fails
|
|
56
54
|
"""
|
|
57
55
|
|
|
58
56
|
@abstractmethod
|
|
59
|
-
def stream(self, messages: list[dict[str, str]]) ->
|
|
57
|
+
async def stream(self, messages: list[dict[str, str]]) -> AsyncGenerator[str, None]:
|
|
60
58
|
"""
|
|
61
59
|
Streaming LLM call.
|
|
62
60
|
|
|
@@ -74,8 +72,8 @@ class LLMProvider(ABC):
|
|
|
74
72
|
class NoLLMProvider(LLMProvider):
|
|
75
73
|
"""Empty LLM provider for prompt-only scenarios."""
|
|
76
74
|
|
|
77
|
-
def complete(self, messages: list[dict[str, str]]
|
|
75
|
+
async def complete(self, messages: list[dict[str, str]]) -> str:
|
|
78
76
|
raise NotImplementedError(NO_LLM_PROVIDER_ERROR)
|
|
79
77
|
|
|
80
|
-
def stream(self, messages: list[dict[str, str]]) ->
|
|
78
|
+
async def stream(self, messages: list[dict[str, str]]) -> AsyncGenerator[str, None]:
|
|
81
79
|
raise NotImplementedError(NO_LLM_PROVIDER_ERROR)
|
markdown_flow/utils.py
CHANGED
|
@@ -23,7 +23,6 @@ from .constants import (
|
|
|
23
23
|
CONTEXT_QUESTION_MARKER,
|
|
24
24
|
CONTEXT_QUESTION_TEMPLATE,
|
|
25
25
|
JSON_PARSE_ERROR,
|
|
26
|
-
OUTPUT_INSTRUCTION_EXPLANATION,
|
|
27
26
|
OUTPUT_INSTRUCTION_PREFIX,
|
|
28
27
|
OUTPUT_INSTRUCTION_SUFFIX,
|
|
29
28
|
SMART_VALIDATION_TEMPLATE,
|
|
@@ -559,7 +558,7 @@ def parse_json_response(response_text: str) -> dict[str, Any]:
|
|
|
559
558
|
raise ValueError(JSON_PARSE_ERROR)
|
|
560
559
|
|
|
561
560
|
|
|
562
|
-
def process_output_instructions(content: str) -> str:
|
|
561
|
+
def process_output_instructions(content: str) -> tuple[str, bool]:
|
|
563
562
|
"""
|
|
564
563
|
Process output instruction markers, converting !=== format to [output] format.
|
|
565
564
|
|
|
@@ -569,7 +568,9 @@ def process_output_instructions(content: str) -> str:
|
|
|
569
568
|
content: Raw content containing output instructions
|
|
570
569
|
|
|
571
570
|
Returns:
|
|
572
|
-
|
|
571
|
+
Tuple of (processed_content, has_preserved_content):
|
|
572
|
+
- processed_content: Content with === and !=== markers converted to XML format
|
|
573
|
+
- has_preserved_content: True if content contained preserved markers
|
|
573
574
|
"""
|
|
574
575
|
lines = content.split("\n")
|
|
575
576
|
result_lines = []
|
|
@@ -650,11 +651,8 @@ def process_output_instructions(content: str) -> str:
|
|
|
650
651
|
# Assemble final content
|
|
651
652
|
processed_content = "\n".join(result_lines)
|
|
652
653
|
|
|
653
|
-
#
|
|
654
|
-
|
|
655
|
-
processed_content = OUTPUT_INSTRUCTION_EXPLANATION + processed_content
|
|
656
|
-
|
|
657
|
-
return processed_content
|
|
654
|
+
# Return both processed content and whether it contains preserved content
|
|
655
|
+
return processed_content, has_output_instruction
|
|
658
656
|
|
|
659
657
|
|
|
660
658
|
def extract_preserved_content(content: str) -> str:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: markdown-flow
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.17
|
|
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
|
|
@@ -73,7 +73,7 @@ llm_provider = YourLLMProvider(api_key="your-key")
|
|
|
73
73
|
mf = MarkdownFlow(document, llm_provider=llm_provider)
|
|
74
74
|
|
|
75
75
|
# Process with different modes
|
|
76
|
-
result = mf.process(
|
|
76
|
+
result = await mf.process(
|
|
77
77
|
block_index=0,
|
|
78
78
|
mode=ProcessMode.COMPLETE,
|
|
79
79
|
variables={'name': 'Alice', 'level': 'Intermediate'}
|
|
@@ -84,7 +84,7 @@ result = mf.process(
|
|
|
84
84
|
|
|
85
85
|
```python
|
|
86
86
|
# Stream processing for real-time responses
|
|
87
|
-
for chunk in mf.process(
|
|
87
|
+
async for chunk in mf.process(
|
|
88
88
|
block_index=0,
|
|
89
89
|
mode=ProcessMode.STREAM,
|
|
90
90
|
variables={'name': 'Bob'}
|
|
@@ -92,36 +92,6 @@ for chunk in mf.process(
|
|
|
92
92
|
print(chunk.content, end='')
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
### Dynamic Interaction Generation ✨
|
|
96
|
-
|
|
97
|
-
Transform natural language content into interactive elements automatically:
|
|
98
|
-
|
|
99
|
-
```python
|
|
100
|
-
from markdown_flow import MarkdownFlow, ProcessMode
|
|
101
|
-
|
|
102
|
-
# Dynamic interaction generation works automatically
|
|
103
|
-
mf = MarkdownFlow(
|
|
104
|
-
document="询问用户的菜品偏好,并记录到变量{{菜品选择}}",
|
|
105
|
-
llm_provider=llm_provider,
|
|
106
|
-
document_prompt="你是中餐厅服务员,提供川菜、粤菜、鲁菜等选项"
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
# Process with Function Calling
|
|
110
|
-
result = mf.process(0, ProcessMode.COMPLETE)
|
|
111
|
-
|
|
112
|
-
if result.transformed_to_interaction:
|
|
113
|
-
print(f"Generated interaction: {result.content}")
|
|
114
|
-
# Output: ?[%{{菜品选择}} 宫保鸡丁||麻婆豆腐||水煮鱼||...其他菜品]
|
|
115
|
-
|
|
116
|
-
# Continue with user input
|
|
117
|
-
user_result = mf.process(
|
|
118
|
-
block_index=0,
|
|
119
|
-
mode=ProcessMode.COMPLETE,
|
|
120
|
-
user_input={"菜品选择": ["宫保鸡丁", "麻婆豆腐"]},
|
|
121
|
-
dynamic_interaction_format=result.content
|
|
122
|
-
)
|
|
123
|
-
```
|
|
124
|
-
|
|
125
95
|
### Interactive Elements
|
|
126
96
|
|
|
127
97
|
```python
|
|
@@ -152,66 +122,13 @@ user_input = {
|
|
|
152
122
|
'skills': ['Python', 'JavaScript', 'Go'] # Multi-selection
|
|
153
123
|
}
|
|
154
124
|
|
|
155
|
-
result = mf.process(
|
|
125
|
+
result = await mf.process(
|
|
156
126
|
block_index=1, # Process skills interaction
|
|
157
127
|
user_input=user_input,
|
|
158
128
|
mode=ProcessMode.COMPLETE
|
|
159
129
|
)
|
|
160
130
|
```
|
|
161
131
|
|
|
162
|
-
## ✨ Key Features
|
|
163
|
-
|
|
164
|
-
### 🏗️ Three-Layer Architecture
|
|
165
|
-
|
|
166
|
-
- **Document Level**: Parse `---` separators and `?[]` interaction patterns
|
|
167
|
-
- **Block Level**: Categorize as CONTENT, INTERACTION, or PRESERVED_CONTENT
|
|
168
|
-
- **Interaction Level**: Handle 6 different interaction types with smart validation
|
|
169
|
-
|
|
170
|
-
### 🔄 Dynamic Interaction Generation
|
|
171
|
-
|
|
172
|
-
- **Natural Language Input**: Write content in plain language
|
|
173
|
-
- **AI-Powered Conversion**: LLM automatically detects interaction needs using Function Calling
|
|
174
|
-
- **Structured Data Generation**: LLM returns structured data, core builds MarkdownFlow format
|
|
175
|
-
- **Language Agnostic**: Support for any language with proper document prompts
|
|
176
|
-
- **Context Awareness**: Both original and resolved variable contexts provided to LLM
|
|
177
|
-
|
|
178
|
-
### 🤖 Unified LLM Integration
|
|
179
|
-
|
|
180
|
-
- **Single Interface**: One `complete()` method for both regular and Function Calling modes
|
|
181
|
-
- **Automatic Detection**: Tools parameter determines processing mode automatically
|
|
182
|
-
- **Consistent Returns**: Always returns `LLMResult` with structured metadata
|
|
183
|
-
- **Error Handling**: Automatic fallback from Function Calling to regular completion
|
|
184
|
-
- **Provider Agnostic**: Abstract interface supports any LLM service
|
|
185
|
-
|
|
186
|
-
### 📝 Variable System
|
|
187
|
-
|
|
188
|
-
- **Replaceable Variables**: `{{variable}}` for content personalization
|
|
189
|
-
- **Preserved Variables**: `%{{variable}}` for LLM understanding in interactions
|
|
190
|
-
- **Multi-Value Support**: Handle both single values and arrays
|
|
191
|
-
- **Smart Extraction**: Automatic detection from document content
|
|
192
|
-
|
|
193
|
-
### 🎯 Interaction Types
|
|
194
|
-
|
|
195
|
-
- **Text Input**: `?[%{{var}}...question]` - Free text entry
|
|
196
|
-
- **Single Select**: `?[%{{var}} A|B|C]` - Choose one option
|
|
197
|
-
- **Multi Select**: `?[%{{var}} A||B||C]` - Choose multiple options
|
|
198
|
-
- **Mixed Mode**: `?[%{{var}} A||B||...custom]` - Predefined + custom input
|
|
199
|
-
- **Display Buttons**: `?[Continue|Cancel]` - Action buttons without assignment
|
|
200
|
-
- **Value Separation**: `?[%{{var}} Display//value|...]` - Different display/stored values
|
|
201
|
-
|
|
202
|
-
### 🔒 Content Preservation
|
|
203
|
-
|
|
204
|
-
- **Multiline Format**: `!===content!===` blocks output exactly as written
|
|
205
|
-
- **Inline Format**: `===content===` for single-line preserved content
|
|
206
|
-
- **Variable Support**: Preserved content can contain variables for substitution
|
|
207
|
-
|
|
208
|
-
### ⚡ Performance Optimized
|
|
209
|
-
|
|
210
|
-
- **Pre-compiled Regex**: All patterns compiled once for maximum performance
|
|
211
|
-
- **Synchronous Interface**: Clean synchronous operations with optional streaming
|
|
212
|
-
- **Stream Processing**: Real-time streaming responses supported
|
|
213
|
-
- **Memory Efficient**: Lazy evaluation and generator patterns
|
|
214
|
-
|
|
215
132
|
## 📖 API Reference
|
|
216
133
|
|
|
217
134
|
### Core Classes
|
|
@@ -231,7 +148,7 @@ class MarkdownFlow:
|
|
|
231
148
|
def get_all_blocks(self) -> List[Block]: ...
|
|
232
149
|
def extract_variables(self) -> Set[str]: ...
|
|
233
150
|
|
|
234
|
-
def process(
|
|
151
|
+
async def process(
|
|
235
152
|
self,
|
|
236
153
|
block_index: int,
|
|
237
154
|
mode: ProcessMode = ProcessMode.COMPLETE,
|
|
@@ -276,15 +193,15 @@ class ProcessMode(Enum):
|
|
|
276
193
|
|
|
277
194
|
```python
|
|
278
195
|
# Generate prompt only
|
|
279
|
-
prompt_result = mf.process(0, ProcessMode.PROMPT_ONLY)
|
|
196
|
+
prompt_result = await mf.process(0, ProcessMode.PROMPT_ONLY)
|
|
280
197
|
print(prompt_result.content) # Raw prompt text
|
|
281
198
|
|
|
282
199
|
# Complete response
|
|
283
|
-
complete_result = mf.process(0, ProcessMode.COMPLETE)
|
|
200
|
+
complete_result = await mf.process(0, ProcessMode.COMPLETE)
|
|
284
201
|
print(complete_result.content) # Full LLM response
|
|
285
202
|
|
|
286
203
|
# Streaming response
|
|
287
|
-
for chunk in mf.process(0, ProcessMode.STREAM):
|
|
204
|
+
async for chunk in mf.process(0, ProcessMode.STREAM):
|
|
288
205
|
print(chunk.content, end='')
|
|
289
206
|
```
|
|
290
207
|
|
|
@@ -294,14 +211,14 @@ Abstract base class for implementing LLM providers.
|
|
|
294
211
|
|
|
295
212
|
```python
|
|
296
213
|
from abc import ABC, abstractmethod
|
|
297
|
-
from typing import
|
|
214
|
+
from typing import AsyncGenerator
|
|
298
215
|
|
|
299
216
|
class LLMProvider(ABC):
|
|
300
217
|
@abstractmethod
|
|
301
|
-
def complete(self, prompt: str) -> LLMResult: ...
|
|
218
|
+
async def complete(self, prompt: str) -> LLMResult: ...
|
|
302
219
|
|
|
303
220
|
@abstractmethod
|
|
304
|
-
def stream(self, prompt: str) ->
|
|
221
|
+
async def stream(self, prompt: str) -> AsyncGenerator[str, None]: ...
|
|
305
222
|
```
|
|
306
223
|
|
|
307
224
|
**Custom Implementation:**
|
|
@@ -309,23 +226,23 @@ class LLMProvider(ABC):
|
|
|
309
226
|
```python
|
|
310
227
|
class OpenAIProvider(LLMProvider):
|
|
311
228
|
def __init__(self, api_key: str):
|
|
312
|
-
self.client = openai.
|
|
229
|
+
self.client = openai.AsyncOpenAI(api_key=api_key)
|
|
313
230
|
|
|
314
|
-
def complete(self, prompt: str) -> LLMResult:
|
|
315
|
-
response = self.client.completions.create(
|
|
231
|
+
async def complete(self, prompt: str) -> LLMResult:
|
|
232
|
+
response = await self.client.completions.create(
|
|
316
233
|
model="gpt-3.5-turbo",
|
|
317
234
|
prompt=prompt,
|
|
318
235
|
max_tokens=500
|
|
319
236
|
)
|
|
320
237
|
return LLMResult(content=response.choices[0].text.strip())
|
|
321
238
|
|
|
322
|
-
def stream(self, prompt: str):
|
|
323
|
-
stream = self.client.completions.create(
|
|
239
|
+
async def stream(self, prompt: str):
|
|
240
|
+
stream = await self.client.completions.create(
|
|
324
241
|
model="gpt-3.5-turbo",
|
|
325
242
|
prompt=prompt,
|
|
326
243
|
stream=True
|
|
327
244
|
)
|
|
328
|
-
for chunk in stream:
|
|
245
|
+
async for chunk in stream:
|
|
329
246
|
if chunk.choices[0].text:
|
|
330
247
|
yield chunk.choices[0].text
|
|
331
248
|
```
|
|
@@ -485,7 +402,7 @@ The new version introduces multi-select interaction support with improvements to
|
|
|
485
402
|
user_input = "Python"
|
|
486
403
|
|
|
487
404
|
# Process interaction
|
|
488
|
-
result = mf.process(
|
|
405
|
+
result = await mf.process(
|
|
489
406
|
block_index=1,
|
|
490
407
|
user_input=user_input,
|
|
491
408
|
mode=ProcessMode.COMPLETE
|
|
@@ -502,7 +419,7 @@ user_input = {
|
|
|
502
419
|
}
|
|
503
420
|
|
|
504
421
|
# Process interaction
|
|
505
|
-
result = mf.process(
|
|
422
|
+
result = await mf.process(
|
|
506
423
|
block_index=1,
|
|
507
424
|
user_input=user_input,
|
|
508
425
|
mode=ProcessMode.COMPLETE
|
|
@@ -545,10 +462,10 @@ class CustomAPIProvider(LLMProvider):
|
|
|
545
462
|
def __init__(self, base_url: str, api_key: str):
|
|
546
463
|
self.base_url = base_url
|
|
547
464
|
self.api_key = api_key
|
|
548
|
-
self.client = httpx.
|
|
465
|
+
self.client = httpx.AsyncClient()
|
|
549
466
|
|
|
550
|
-
def complete(self, prompt: str) -> LLMResult:
|
|
551
|
-
response = self.client.post(
|
|
467
|
+
async def complete(self, prompt: str) -> LLMResult:
|
|
468
|
+
response = await self.client.post(
|
|
552
469
|
f"{self.base_url}/complete",
|
|
553
470
|
headers={"Authorization": f"Bearer {self.api_key}"},
|
|
554
471
|
json={"prompt": prompt, "max_tokens": 1000}
|
|
@@ -556,14 +473,14 @@ class CustomAPIProvider(LLMProvider):
|
|
|
556
473
|
data = response.json()
|
|
557
474
|
return LLMResult(content=data["text"])
|
|
558
475
|
|
|
559
|
-
def stream(self, prompt: str):
|
|
560
|
-
with self.client.stream(
|
|
476
|
+
async def stream(self, prompt: str):
|
|
477
|
+
async with self.client.stream(
|
|
561
478
|
"POST",
|
|
562
479
|
f"{self.base_url}/stream",
|
|
563
480
|
headers={"Authorization": f"Bearer {self.api_key}"},
|
|
564
481
|
json={"prompt": prompt}
|
|
565
482
|
) as response:
|
|
566
|
-
for chunk in response.
|
|
483
|
+
async for chunk in response.aiter_text():
|
|
567
484
|
if chunk.strip():
|
|
568
485
|
yield chunk
|
|
569
486
|
|
|
@@ -575,7 +492,7 @@ mf = MarkdownFlow(document, llm_provider=provider)
|
|
|
575
492
|
### Multi-Block Document Processing
|
|
576
493
|
|
|
577
494
|
```python
|
|
578
|
-
def process_conversation():
|
|
495
|
+
async def process_conversation():
|
|
579
496
|
conversation = """
|
|
580
497
|
# AI Assistant
|
|
581
498
|
|
|
@@ -612,7 +529,7 @@ Would you like to start with the basics?
|
|
|
612
529
|
for i, block in enumerate(blocks):
|
|
613
530
|
if block.block_type == BlockType.CONTENT:
|
|
614
531
|
print(f"\n--- Processing Block {i} ---")
|
|
615
|
-
result = mf.process(
|
|
532
|
+
result = await mf.process(
|
|
616
533
|
block_index=i,
|
|
617
534
|
mode=ProcessMode.COMPLETE,
|
|
618
535
|
variables=variables
|
|
@@ -627,8 +544,9 @@ Would you like to start with the basics?
|
|
|
627
544
|
|
|
628
545
|
```python
|
|
629
546
|
from markdown_flow import MarkdownFlow, ProcessMode
|
|
547
|
+
import asyncio
|
|
630
548
|
|
|
631
|
-
def stream_with_progress():
|
|
549
|
+
async def stream_with_progress():
|
|
632
550
|
document = """
|
|
633
551
|
Generate a comprehensive Python tutorial for {{user_name}}
|
|
634
552
|
focusing on {{topic}} with practical examples.
|
|
@@ -642,7 +560,7 @@ Include code samples, explanations, and practice exercises.
|
|
|
642
560
|
content = ""
|
|
643
561
|
chunk_count = 0
|
|
644
562
|
|
|
645
|
-
for chunk in mf.process(
|
|
563
|
+
async for chunk in mf.process(
|
|
646
564
|
block_index=0,
|
|
647
565
|
mode=ProcessMode.STREAM,
|
|
648
566
|
variables={
|
|
@@ -681,13 +599,13 @@ class InteractiveDocumentBuilder:
|
|
|
681
599
|
self.user_responses = {}
|
|
682
600
|
self.current_block = 0
|
|
683
601
|
|
|
684
|
-
def start_interaction(self):
|
|
602
|
+
async def start_interaction(self):
|
|
685
603
|
blocks = self.mf.get_all_blocks()
|
|
686
604
|
|
|
687
605
|
for i, block in enumerate(blocks):
|
|
688
606
|
if block.block_type == BlockType.CONTENT:
|
|
689
607
|
# Process content block with current variables
|
|
690
|
-
result = self.mf.process(
|
|
608
|
+
result = await self.mf.process(
|
|
691
609
|
block_index=i,
|
|
692
610
|
mode=ProcessMode.COMPLETE,
|
|
693
611
|
variables=self.user_responses
|
|
@@ -696,11 +614,11 @@ class InteractiveDocumentBuilder:
|
|
|
696
614
|
|
|
697
615
|
elif block.block_type == BlockType.INTERACTION:
|
|
698
616
|
# Handle user interaction
|
|
699
|
-
response = self.handle_interaction(block.content)
|
|
617
|
+
response = await self.handle_interaction(block.content)
|
|
700
618
|
if response:
|
|
701
619
|
self.user_responses.update(response)
|
|
702
620
|
|
|
703
|
-
def handle_interaction(self, interaction_content: str):
|
|
621
|
+
async def handle_interaction(self, interaction_content: str):
|
|
704
622
|
from markdown_flow.utils import InteractionParser
|
|
705
623
|
|
|
706
624
|
interaction = InteractionParser.parse(interaction_content)
|
|
@@ -717,7 +635,7 @@ class InteractiveDocumentBuilder:
|
|
|
717
635
|
return {interaction.variable: selected}
|
|
718
636
|
except (ValueError, IndexError):
|
|
719
637
|
print("Invalid choice")
|
|
720
|
-
return self.handle_interaction(interaction_content)
|
|
638
|
+
return await self.handle_interaction(interaction_content)
|
|
721
639
|
|
|
722
640
|
elif interaction.name == "TEXT_ONLY":
|
|
723
641
|
response = input(f"{interaction.question}: ")
|
|
@@ -739,7 +657,7 @@ Great choice, {{name}}! {{subject}} is an excellent field to study.
|
|
|
739
657
|
"""
|
|
740
658
|
|
|
741
659
|
builder = InteractiveDocumentBuilder(template, your_llm_provider)
|
|
742
|
-
builder.start_interaction()
|
|
660
|
+
await builder.start_interaction()
|
|
743
661
|
```
|
|
744
662
|
|
|
745
663
|
### Variable System Deep Dive
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
markdown_flow/__init__.py,sha256=B7yG1jRkkbsS-V73sqUUl7T_ogzCjDCavOqKXFtJeaI,2875
|
|
2
|
+
markdown_flow/constants.py,sha256=HI061nHbGG9BeN-n9dMX17GlAT7fmYmsRZ6Cr8OSbXY,8809
|
|
3
|
+
markdown_flow/core.py,sha256=hTqq4bss9519SzhOPl5OHAJK_2YgB7hpwZlmC4HgsVo,32921
|
|
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=ERCOsdywh0wyWAa1lN54BbfNQNNwES8F6hzoYxtfAXc,2225
|
|
7
|
+
markdown_flow/models.py,sha256=ENcvXMVXwpFN-RzbeVHhXTjBN0bbmRpJ96K-XS2rizI,2893
|
|
8
|
+
markdown_flow/utils.py,sha256=rJOalKxCGuXYiAJzI3WfD-loLc-7BHQGpac934_uC4c,28504
|
|
9
|
+
markdown_flow-0.2.17.dist-info/licenses/LICENSE,sha256=qz3BziejhHPd1xa5eVtYEU5Qp6L2pn4otuj194uGxmc,1069
|
|
10
|
+
markdown_flow-0.2.17.dist-info/METADATA,sha256=6hz7PDbT1LrfF4n_IjqnX-p42IkED_V-fS4cQczwRlQ,21010
|
|
11
|
+
markdown_flow-0.2.17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
12
|
+
markdown_flow-0.2.17.dist-info/top_level.txt,sha256=DpigGvQuIt2L0TTLnDU5sylhiTGiZS7MmAMa2hi-AJs,14
|
|
13
|
+
markdown_flow-0.2.17.dist-info/RECORD,,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
markdown_flow/__init__.py,sha256=IOL89FC4C8kH6qU5bjNsmuumPk3YDEHKHEjnJFFzQRU,2875
|
|
2
|
-
markdown_flow/constants.py,sha256=Wq10-gvskBT6CpI3WiNfZpDIfl-lnAMaHVvjGvYpGG0,8006
|
|
3
|
-
markdown_flow/core.py,sha256=INQ5vIJOFOCYHkBszqCbgn0BGVQ0WXMONtQ6AJmRXkM,51237
|
|
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.16.dist-info/licenses/LICENSE,sha256=qz3BziejhHPd1xa5eVtYEU5Qp6L2pn4otuj194uGxmc,1069
|
|
10
|
-
markdown_flow-0.2.16.dist-info/METADATA,sha256=0uwa1wYOmt5MjukW6x2MTlUxYO-zn9Q4hkKu_NSiKOc,24287
|
|
11
|
-
markdown_flow-0.2.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
12
|
-
markdown_flow-0.2.16.dist-info/top_level.txt,sha256=DpigGvQuIt2L0TTLnDU5sylhiTGiZS7MmAMa2hi-AJs,14
|
|
13
|
-
markdown_flow-0.2.16.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|