Initial commit: fluxcore project setup
- Adapter module for token counting
- Config module for provider configurations
- Errors with retry support
- Routing and proxy components
- Tracing and usage tracking
- Validation utilities
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802032778号
fluxcore
fluxcore 是 tokflux 项目的共享核心库,包含纯函数和数据结构。
设计原则
目录结构
核心模块
routing - 路由选择
adapter - 格式转换
usage - Token 估算
proxy - 代理转发
validate - 输入验证
config - 配置结构
核心类型
ErrorCode
ErrorResponse
ProviderSnapshot
路由策略
fluxcore 提供五种路由策略:
routing.StrategyQuotaFirstSelectByQuota()routing.StrategyPriceFirstSelectByPrice()routing.StrategyLatencyFirstSelectByLatency()routing.StrategyRoundRobinSelectByRoundRobin()routing.StrategyManualSelectByManual()所有选择函数使用 O(n) 算法(线性扫描),而非 O(n log n) 排序。
通过
GetStrategy(name)函数获取策略:RoundRobin 支持创建独立实例:
使用示例
路由选择
Token 估算
价格计算
格式检测
TraceID 生成
测试覆盖率
依赖关系
fluxcore 是纯核心库,不依赖 tokrouter 或 tokhub。