Easy Streamlit UI template for ChatBots
Project description
PocBot
Description
Simple streamlit UI to implement chatbots.
- Objective: Develop a pip installable package to create easy ChatBot interfaces.
- Scope: First iteration - Simple UI. It should work out of the box.
To see it used in a real project, check out the e-commerce chatbot
Installation
Installing is as easy as running pip install pocbot in your terminal. Make sure you have your virtual environment activated!
Usage
Here's a basic example on how to use pocbot. Let's assume we are chatting with Pikachu, who only knows how to say "pika" a random number of times.
from typing import Any, List
from pocbot.ui_template import ChatBotUITemplate
from pocbot.chain_template import ChatBotChain
from random import randint
# LLM Simulation
class Pikachu(ChatBotChain):
"""This is a test chain model"""
def __init__(self):
pass
def invoke(self, input: str, chat_history: List[Any]) -> str:
""""""
return " ".join(["pika"] * randint(1, 10)) + "!"
# UI
pocbot = ChatBotUITemplate(name="PikaBot", chain=Pikachu())
if __name__ == "__main__":
pocbot()
To get started, copy and paste this code in a file in your Python project. Then, one can run it as any other Streamlit app: streamlit run <file_name>.py
That's it! You should see a UI in port 8501.
Brief Explanation
The ChatBotUITemplate class is whre the magic happens. It is thought out to be a simple class that helps one create a UI for a chatbot in a few lines of code. It has the following parameters:
name: Name of the chatbot. It will be displayed in the UI.chain:ChatBotChainobject. This is the chain that will be used to generate the responses. It is explained in the next section.
The ChatBotChain class is designed to act as an interface between the UI and the logic of the chatbot. It si pretty simple. The only constraint is that it must have an invoke method (see example above) defined.
Contributing
If you would like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome. You can find the repository here
References
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pocbot-0.1.3.tar.gz.
File metadata
- Download URL: pocbot-0.1.3.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.12.0 Darwin/23.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7e9338c6be5a2f95b7570b32e02c25ed4c4361d22ce23ff7c0f1d17898f25b0
|
|
| MD5 |
cd1995856587f8d8a0d8ec8e9ecc5a92
|
|
| BLAKE2b-256 |
a3fa6668549727bbad786dab7a1be7894c32f35499c8608ffa9a047090f33788
|
File details
Details for the file pocbot-0.1.3-py3-none-any.whl.
File metadata
- Download URL: pocbot-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.12.0 Darwin/23.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2804b03013d26305b42b92fc3fc3b4c966e0aa0ced8f5f65ea01f57103ef01d6
|
|
| MD5 |
1c9f96ba95b23d4d4060e914ed8ff1f6
|
|
| BLAKE2b-256 |
c7cd267699ed3e96bf590a505b0210b98264e88c17713ba5681304dda08876da
|