Repository navigation
Packages to keep track of
Squirrel edited this page Oct 10, 2024
·
5 revisions
- Use https://www.litellm.ai/ for the lowest layer to forward requests to LLM API
- Use https://github.com/MadcowD/ell for the middle layer to implement LLM program logic
- Use https://fastapi.tiangolo.com/ for the top layer to implement API
虽然 最底层就抽象了不同LLM service的接口问题 (https://www.litellm.ai/)
But, Advantages of using openai/anthropic apis:
- anthropic和openai的接口还挺不一样的,不知道他们处理的有多好
- anthropic支持prefill但是openai靠的是支持一次性16k/32k/64k输出,连续的部分比较难 应该可以先保持直接call openai/anthropic/openrouter的逻辑,这个逻辑还比较绕,因为我实现的时候continuation和prefill做了不少engineering的工作
- 用官方api的好处是prompt caching之类的定制化比较容易,prompt caching将来做loop/graph逻辑的话对减少cost和latency还蛮重要的 还有些最大公共子串判重和 end_tokens 之类的对terminal condition的判断
- 如果他们这些litellm/ell已经支持所有的功能了那用统一的接口当然是最好的
https://fastapi.tiangolo.com/tutorial/sql-databases/ 一般比较简单的 sqllite? mongoDB? Redis?
读取大于(并发)写入的场景用 sqlite:python 自带,而且不用跑数据库 server(the so called embedded db),就是指定一个文件路径就能用;如果你的服务器跑在云上可以看看 aws 自带的啥 managed db,redis 也有 managed instance,不用做运维
想要特别糙快猛对性能不是很 care 可以考虑任意用一个 orm 框架,比如 python 有个 sqlalchemy,可以在 python 写个 class 自动帮你生成数据库读写,很无脑
但如果你要存的东西很简单也可以 LLM 一下 sql,也挺快
OK这其实是个典型的cache,用reddish之类的很简单
确实不应该mix logs 和 cache,应该分开handle
cache也有很多办法,DB based 就是 redis,其实这个 file based 更简单,而且可以直接在前端typescript实现,比如这种 https://github.com/kwertop/persistent-node-cache
Cache是persistent的,所以也是基于tempfiles的 只不过把这些都给你abstract了,不用自己处理 你可以用persistent cache这个关键词搜包