This commit is contained in:
zachary62 2024-12-27 23:31:40 +00:00
parent f1f89d223a
commit b3994478eb
3 changed files with 16 additions and 12 deletions

View File

@ -2,7 +2,7 @@
![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg) ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
A 100-line minimalist LLM framework for agents, task decomposition, RAG, etc. A [100-line](minillmflow/__init__.py) minimalist LLM framework for agents, task decomposition, RAG, etc.
- Install via ```pip install minillmflow```, or just copy the [source](minillmflow/__init__.py) (only 100 lines) - Install via ```pip install minillmflow```, or just copy the [source](minillmflow/__init__.py) (only 100 lines)
@ -27,7 +27,7 @@ Hence, I built this framework that lets LLMs focus on what matters. It turns out
<div align="center"> <div align="center">
<img src="./assets/minillmflow.jpg" width="400"/> <img src="/assets/minillmflow.jpg" width="400"/>
</div> </div>
## Example ## Example

View File

@ -1,23 +1,26 @@
--- ---
layout: default layout: default
title: "Home" title: "Home"
nav_order: 1
--- ---
# Mini LLM Flow # Mini LLM Flow
A 100-line minimalist LLM framework for agents, task decomposition, RAG, etc. A 100-line minimalist LLM framework for agents, task decomposition, RAG, etc.
![Alt text](/docs/assets/minillmflow.jpg) <div align="center">
<img src="/assets/minillmflow.jpg" width="400"/>
</div>
## Core Abstraction ## Core Abstraction
We model the LLM workflow as a **Nested Flow**: We model the LLM workflow as a **Nested Flow**:
- Each **Node** handles a simple LLM task.
- Each **Node** handles a simple LLM task (e.g., text summarization, structure extraction, or question answering). - Nodes are chained together to form a **Flow** for more complex tasks.
- Nodes are chained together to form a **Flow** for more complex tasks. One Node can be chained to multiple Nodes based on **Actions**, e.g., for agentic steps. - One Node can be chained to multiple Nodes based on **Actions**.
- A Flow can be treated as a Node for **Nested Flows**. - A Flow can be treated as a Node for **Nested Flows**.
- Both Nodes and Flows can be **Batched** for data-intensive tasks (e.g., processing one file at a time in a directory of files). - Both Nodes and Flows can be **Batched** for data-intensive tasks.
- Nodes and Flows can be **Async**, e.g., for user feedback before proceeding. - Nodes and Flows can be **Async**.
- [Node](./node.md) - [Node](./node.md)
- [Flow](./flow.md) - [Flow](./flow.md)

View File

@ -1,6 +1,7 @@
--- ---
layout: default layout: default
title: "Node" title: "Node"
nav_order: 2
--- ---
# Node # Node
@ -38,16 +39,16 @@ 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: If you want to **gracefully handle** the error rather than raising it, you can override:
`` ```
def process_after_fail(self, shared, prep_res, exc): def process_after_fail(self, shared, prep_res, exc):
raise exc raise exc
`` ```
By **default**, it just re-raises `exc`. But you can return a fallback result instead. That fallback result becomes the `exec_res` passed to `post()`. By **default**, it just re-raises `exc`. But you can return a fallback result instead. That fallback result becomes the `exec_res` passed to `post()`.
## Minimal Example ## Minimal Example
`` ```
class SummarizeFile(Node): class SummarizeFile(Node):
def prep(self, shared): def prep(self, shared):
filename = self.params["filename"] filename = self.params["filename"]
@ -68,5 +69,5 @@ class SummarizeFile(Node):
filename = self.params["filename"] filename = self.params["filename"]
shared["summary"][filename] = exec_res shared["summary"][filename] = exec_res
# Return "default" by not returning anything # Return "default" by not returning anything
`` ```