以前简单介绍过chainlit 以及litellm 以下是fastapi 集成chainlit ,使用litellm proxy 包装的标准openai 能力(同时还能实现计费)
参考玩法
环境准备
包含了litellm proxy 以及ollama 的比较简单,我就不多介绍了,具体可以通过静态配置或者api 动态配置
- ollama 安装
比较简单,选择对操作系统就可以了,注意需要先pull 使用的模型 - litellm proxy 启动
可以静态也可以动态 - litellm 模型 api 配置模式(包含计费)
注意是示例实际的结合自己的部署
fastapi 集成chainlit
对于聊天使用的llm api 基于了litellm proxy 的openai 服务
- 安装依赖
- 启动&效果
访问: http://localhost:8000/chainlit
说明
chainlit 提供了开箱即用的功能,对于快速开发一个chat app 还是很方便的,值得尝试下
参考资料
https://docs.chainlit.io/integrations/openai https://github.com/Chainlit/chainlit
https://github.com/rongfengliang/ollama-litellm-fastapi-chainlit-chatapp