A Python package for managing LLM context windows
Project description
EffiMemo
一个用于管理大语言模型(LLM)上下文窗口的Python包。
功能特性
- 智能上下文管理:自动管理对话历史,确保不超过token限制
- 多种裁切策略:支持first、last和selective策略
- 灵活配置:可自定义最大token数、模型类型等参数
- 系统消息保护:可选择性保留重要的系统消息
安装
pip install effimemo
快速开始
from effimemo import create_context_manager
# 创建上下文管理器
manager = create_context_manager(
max_tokens=8192,
model_name="gpt-4",
strategy="last",
preserve_system=True
)
# 使用管理器处理对话
messages = [
{"role": "system", "content": "你是一个有用的助手"},
{"role": "user", "content": "你好"},
{"role": "assistant", "content": "你好!有什么可以帮助你的吗?"}
]
# 管理上下文
managed_messages = manager.manage_context(messages)
API文档
create_context_manager
创建上下文管理器实例。
参数:
max_tokens(int): 最大token数量,默认8192model_name(str): 模型名称,默认"gpt-4"strategy(str): 裁切策略,可选"first"、"last"或"selective",默认"last"preserve_system(bool): 是否保留系统消息,默认True
返回:
ContextManager: 上下文管理器实例
许可证
MIT License
作者
Manus AI
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
effimemo-0.1.1.tar.gz
(23.9 kB
view details)
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
effimemo-0.1.1-py3-none-any.whl
(14.8 kB
view details)
File details
Details for the file effimemo-0.1.1.tar.gz.
File metadata
- Download URL: effimemo-0.1.1.tar.gz
- Upload date:
- Size: 23.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2434322659679beaa755d4189cb70353c34d3e6ecc78fd06a910382bbec249fd
|
|
| MD5 |
206f010e91340e3b6bb9245a0cbeaf81
|
|
| BLAKE2b-256 |
b40d01824c193c7b33b991d69c61c71e5a1bef3d10e72632960aae761ce0b4dc
|
File details
Details for the file effimemo-0.1.1-py3-none-any.whl.
File metadata
- Download URL: effimemo-0.1.1-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd67002972420f99b6afbd7f64151173922c3e230347e7c94254ee16207c1e91
|
|
| MD5 |
11b63b29650f02d1995571c1f25d49f3
|
|
| BLAKE2b-256 |
1d3d567eb051873fdac53681fe7cd8435cc2f035eea5c6985c064f011aa940b1
|