Skip to main content

fastui-chat

Version Downloads license Twitter Follow

A minimalistic ChatBot Interface in pure python.
Build on top of FastUI and LangChain Core.

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.

Metadata

Release files for fastui-chat 0.3.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastui-chat 0.3.4
File Size Uploaded Provenance Actions
fastui_chat-0.3.4.tar.gz 8.0 kB Without provenance Details for fastui_chat-0.3.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fastui-chat 0.3.4
File Interpreter ABI Platform Actions
fastui_chat-0.3.4-py3-none-any.whl Python 3 none any Details for fastui_chat-0.3.4-py3-none-any.whl

Total release size: 16.3 kB

Release files / fastui_chat-0.3.4.tar.gz

Download URL fastui_chat-0.3.4.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8360fa47e84a1f797b14074094cc073f35d4074cc084f16952a27f7ebbf64b02
BLAKE2b-256 checksum
How to use checksums
7af1caee6cf311e8405f85b5e19b0e6e492a93d15a1c7571d737ce0f3a01c1ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Release files / fastui_chat-0.3.4-py3-none-any.whl

Download URL fastui_chat-0.3.4-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e60b9d927e9f7ebe7eb5a755bef2445e6b7f29d913f00f67c075b7f5be5eb59
BLAKE2b-256 checksum
How to use checksums
9ea60dfe54a394a60a6ea8c84e36eb1e1aa623122c1ccf6fc3f667070be36707
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Security for fastui-chat 0.3.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page