BlockXAI Chat
A Python package that enables developers to create AI chatbots with just two lines of code. BlockXAI Chat uses Google's Gemini API to enhance simple prompts into comprehensive system prompts, which are then used with OpenAI's GPT models to generate chatbot responses.
Includes a preset Gemini API key - No need to obtain your own Gemini API key to get started!
✨ Create a Chatbot in Just Two Lines
from blockxai_chat.interface import create_and_run
create_and_run("A friendly assistant that helps users with their daily tasks.")
That's it! This will launch a beautiful Gradio interface where you can interact with your chatbot.
Features
- Simple Prompt Enhancement: Transform basic prompts into detailed system prompts using Gemini AI
- Gradio Interface: Beautiful, interactive web interface for chatbot creation and conversation
- Flexible API: Use as a package in your code or run as a standalone application
- Customizable: Configure model parameters, temperature, and other settings
- Developer-Friendly: Create a chatbot with just two lines of code
- Preset API Key: Includes a Gemini API key so you can get started immediately
- Robust Error Handling: Gracefully handles API key issues and model errors
- Latest Gemini Models: Compatible with gemini-2.0-flash for prompt enhancement
- Optional OpenAI API Key: Provide your OpenAI API key through code, environment variables, or directly in the interface
Installation
pip install blockxai-chat
Quick Start
Method 1: The Simplest Way (Two Lines of Code)
from blockxai_chat.interface import create_and_run
create_and_run("A friendly assistant that helps users with their daily tasks.")
Method 2: Step-by-Step Approach
from blockxai_chat.enhancer import enhance_prompt
from blockxai_chat.chatbot import Chatbot
from blockxai_chat.interface import run_interface
# Define a simple prompt
simple_prompt = "A friendly assistant that helps users with their daily tasks."
# Enhance the prompt using Gemini
enhanced_prompt = enhance_prompt(simple_prompt)
# Initialize the chatbot with the enhanced prompt
chatbot = Chatbot(enhanced_prompt)
# Launch the Gradio interface with the chatbot
run_interface(chatbot)
Method 3: Using Just the Prompt
from blockxai_chat.interface import run_interface
# Just provide the prompt to the interface
run_interface(prompt="A friendly assistant that helps users with their daily tasks.")
Environment Variables
Create a .env file in your project directory with the following variable:
OPENAI_API_KEY=your_openai_api_key
Note: A Gemini API key is pre-included in the package, so you don't need to provide one unless you want to use your own key. If you want to use your own key, you can add it to your .env file:
GEMINI_API_KEY=your_gemini_api_key
Alternatively, you can provide these keys directly in your code or through the Streamlit interface.
API Reference
Enhancer Module
from blockxai_chat.enhancer import enhance_prompt
# Enhance a simple prompt
enhanced_prompt = enhance_prompt("A helpful assistant", api_key="your_gemini_api_key")
Chatbot Module
from blockxai_chat.chatbot import Chatbot
# Create a chatbot
chatbot = Chatbot(
system_prompt="You are a helpful assistant...",
api_key="your_openai_api_key",
model="gpt-3.5-turbo"
)
# Get a response
response = chatbot.get_response("Hello, who are you?")
# Clear conversation history
chatbot.clear_history()
# Get conversation history
history = chatbot.get_conversation_history()
Interface Module
from blockxai_chat.interface import run_interface, create_and_run
# Run interface with an existing chatbot
run_interface(chatbot)
# Create and run a chatbot in one line
create_and_run("A helpful assistant")
Development
- Clone the repository
- Install development dependencies:
pip install -e ".[dev]"
- Run tests:
pytest
License
MIT License
Created By
BlockX - Simplifying AI Development
Metadata
Release files for blockxai-chat 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| blockxai_chat-0.1.2.tar.gz | 10.1 kB | Without provenance | Details for blockxai_chat-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| blockxai_chat-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for blockxai_chat-0.1.2-py3-none-any.whl |
Total release size: 19.6 kB
Release files / blockxai_chat-0.1.2.tar.gz
| Download URL | blockxai_chat-0.1.2.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a2df07fbfe4e72f4d83b72ef2a8b370cbe204c26b5d6428073287c7d0cc262b
|
|
BLAKE2b-256 checksum How to use checksums |
4d1ff9c18359ad8eb06b164489dbefd69191eefa77f8490d8a3d0f40fb05e57f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / blockxai_chat-0.1.2-py3-none-any.whl
| Download URL | blockxai_chat-0.1.2-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4620550ad237397c79128195507bd9e845c10e98b55a6b9edc5247684faebd2f
|
|
BLAKE2b-256 checksum How to use checksums |
4cc5f044cacd35cb8761d604c3de23f6477176eea5e5f0c26a4421178610079e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Security for blockxai-chat 0.1.2
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.