A lightweight asynchronous task flow framework
Project description
DESC
flame-core是一个轻量级、高效的异步任务流框架, 旨在简化复杂异步任务的调度和管理。 无论是处理大规模并发任务、构建灵活的工作流, 还是对文本进行语义分割并存储到向量数据库, flame-core 都能提供强大而直观的工具。 它结合了异步编程的性能优势和模块化设计, 适用于从简单脚本到复杂应用的各种场景
flame-core is a lightweight, efficient asynchronous task flow framework designed to simplify the scheduling and management of complex asynchronous tasks. Whether you're working with massively concurrent tasks, building flexible workflows, or semantically segmenting text and storing it in a vector database, flame provides powerful and intuitive tools. It combines the performance benefits of asynchronous programming with a modular design for a wide range of scenarios, from simple scripts to complex applications
CORE
-
异步任务调度:通过 SignHub 管理任务的生命周期,支持优先级、超时和取消。
-
工作流编排:使用 Workflow 轻松定义任务之间的依赖关系和执行顺序。
-
语义文本分割:SemanticTextSplitter 提供基于语义的文本分块,支持最大句子数和 token 限制。
-
向量存储集成:AsyncQdrantVector 实现高效的异步向量存储,适用于嵌入和搜索任务。
-
可扩展性:模块化设计,支持自定义回调和事件监听
-
Asynchronous Task Scheduling: Manage task lifecycles with
SignHub, supporting priorities, timeouts, and cancellation. -
Workflow Orchestration: Define task dependencies and execution order effortlessly using
Workflow. -
Semantic Text Splitting: Use
SemanticTextSplitterfor meaning-aware text chunking, with configurable sentence and token limits. -
Vector Storage Integration: Store and manage embeddings asynchronously with
AsyncQdrantVector. -
Extensibility: Modular architecture with custom callbacks and event listeners
pip install flame-core
Quick start
import asyncio
from flame-core import SignHub, Workflow, SemanticTextSplitter
async def split_text_task(text: str) -> List[str]:
splitter = SemanticTextSplitter(max_sentences=2, max_tokens=1000, semantic=True)
result = [chunk async for chunk in splitter.split(text)]
logger.info(f"Split result: {result}")
return result
async def next_step_task(chunks: List[str]) -> None:
logger.info(f"Next step received chunks: {chunks}")
# 这里可以添加后续处理逻辑,例如打印或存储
return None
async def main():
# Initialize the task hub
hub = SignHub()
await hub.start()
# Define a workflow
wf = Workflow(hub, "Text Processing")
wf.add_node("split", lambda: split_text_task("Cats are cute. Dogs are loyal. Birds fly."))
wf.add_node("next_step", lambda: next_step_task(wf.nodes["split"].data)) # 添加 next_step 节点
wf.add_edge("split", "next_step") # 连接两个节点
# Run the workflow
await wf.run()
# Wait for tasks to complete
while not all(node.is_finished for node in wf.nodes.values()):
await asyncio.sleep(1)
logger.info("Waiting for tasks to complete...")
# Log results
split_result = wf.nodes["split"]._result if wf.nodes["split"]._status == SignStatus.FINISHED else "Failed"
next_result = wf.nodes["next_step"]._result if wf.nodes["next_step"]._status == SignStatus.FINISHED else "Failed"
logger.info(f"Split result: {split_result}")
logger.info(f"Next step result: {next_result}")
await hub.stop()
if __name__ == "__main__":
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flame_core-0.1.1.tar.gz.
File metadata
- Download URL: flame_core-0.1.1.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7115a4243ff8fbcd3b0c0714b41cc300c32da8b3ae5ebeb5c2524249e4692cd6
|
|
| MD5 |
fde643caf7ea0e86cf4d0e7ac7e76543
|
|
| BLAKE2b-256 |
cb254a5f83dd7314f83acf514dfcd9e050ed502efe6d0f6d86abf4b34a9510f0
|
File details
Details for the file flame_core-0.1.1-py3-none-any.whl.
File metadata
- Download URL: flame_core-0.1.1-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a0988b5fc48bbb50b26ffb1b34ae8da59c2ef6fdc63b74e02e1588bb7dd8cd2
|
|
| MD5 |
41b368b866c5035d72774c00ac29df51
|
|
| BLAKE2b-256 |
e002f3a608bde1e4e60f2f0dca6ec7e3d8abce5c76ba1c09db74e42fec533e26
|