项目
在 GitHub 查看
shroominic/fastui-chat
关于
💬 minimalistic ChatBot Interface in pure python
人工智能与机器学习可以做什么
- Minimalistic & Lightweight
- LangChain Compatible
- FastAPI Compatible
- Parallel Chat Sessions
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文fastui-chat
A minimalistic ChatBot Interface in pure python.
Build on top of FastUI and Funcchain.
Usage
pip install fastui-chat
from fastui_chat import ChatUI
# chatui inherits from FastAPI so you can use it as a FastAPI app
app = ChatUI()
# Run with:
# uvicorn examples.minimal:app
# for hot reloading:
# uvicorn examples.minimal:app --reload
# or use the built-in method
if __name__ == "__main__":
app.start_with_uvicorn()
Extend FastAPI
You can also only use the router and extend your existing FastAPI app.
from fastapi import FastAPI
from fastui_chat import create_chat_handler, create_history_factory
from fastui_chat.chat import ChatAPIRouter
from fastui_chat.history import InMemoryChatMessageHistory
from fastui_chat.runtime import router as fastui_runtime
# callable that returns a ChatMessageHistory given a session_id
history_factory = create_history_factory(
# swap out with any from langchain_community.chat_message_histories
InMemoryChatMessageHistory,
)
# a chat handler generates an AIMessage based on a given HumanMessage and ChatHistory
chat_handler = create_chat_handler(
llm="openai/gpt-4-turbo-preview",
history_factory=history_factory,
)
# setup your fastapi app
app = FastAPI()
# add the chatui router to your app
app.include_router(
ChatAPIRouter(history_factory, chat_handler),
prefix="/api",
)
# make sure to add the runtime router as latest since it has a catch-all route
app.include_router(fastui_runtime)
# start the server with `uvicorn examples.fastapi_router:app`
Features
- Python Only
- Easy to use
- Minimalistic & Lightweight
- LangChain Compatible
- FastAPI Compatible
- Parallel Chat Sessions
- Switchable ChatHistory Backends
- Insert your custom chat handler
Development Setup
git clone https://github.com/shroominic/fastui-chat.git && cd fastui-chat
./dev-install.sh
Roadmap
If you want to contribute or see whats coming soon checkout the roadmap.todo file for open todos.
探索相关项目
加载中…