add test cases

This commit is contained in:
zachary62
2024-12-31 02:37:49 +00:00
parent c1ba9dd0d4
commit 643534bc2f
8 changed files with 508 additions and 18 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ nav_order: 5
# Async
**Mini LLM Flow** allows fully asynchronous nodes by implementing `prep_async()`, `exec_async()`, and/or `post_async()`. This is useful for:
**Mini LLM Flow** allows fully asynchronous nodes by implementing `prep_async()`, `exec_async()`, `exec_fallback_async()`, and/or `post_async()`. This is useful for:
## Implementation
+3 -3
View File
@@ -42,7 +42,7 @@ When an exception occurs in `exec()`, the Node automatically retries until:
If you want to **gracefully handle** the error rather than raising it, you can override:
```python
def process_after_fail(self, shared, prep_res, exc):
def exec_fallback(self, shared, prep_res, exc):
raise exc
```
@@ -64,7 +64,7 @@ class SummarizeFile(Node):
summary = call_llm(prompt) # might fail
return summary
def process_after_fail(self, shared, prep_res, exc):
def exec_fallback(self, shared, prep_res, exc):
# Provide a simple fallback instead of crashing
return "There was an error processing your request."
@@ -76,7 +76,7 @@ class SummarizeFile(Node):
summarize_node = SummarizeFile(max_retries=3)
# Run the node standalone for testing (calls prep->exec->post).
# If exec() fails, it retries up to 3 times before calling process_after_fail().
# If exec() fails, it retries up to 3 times before calling exec_fallback().
summarize_node.set_params({"filename": "test_file.txt"})
action_result = summarize_node.run(shared)