GPT4Free integration for Kotti2 CMS - Add AI chat content type
Project description
A Kotti2 plugin that integrates g4f (GPT4Free) AI chat functionality.
Kotti2 is a fork of Kotti CMS with Python 3.12 and SQLAlchemy 2.0 support.
Features
G4FChat Content Type: Add AI chat pages anywhere in your Kotti2 site
Configurable System Prompts: Customize AI behavior per chat instance
Model Selection: Choose from multiple AI models (GPT-4, GPT-3.5, Claude, Gemini)
Security Built-in: Input validation, model whitelist, XSS protection
Chat History: Session-based conversation history
Installation
Add to your pip requirements or setup.py dependencies:
pip install kotti2_g4f
Then add kotti_g4f.kotti_configure to your kotti.configurators setting in your INI file:
kotti.configurators =
kotti_g4f.kotti_configure
Configuration
The plugin can be configured via INI settings:
- kotti.g4f.enabled
Enable or disable the g4f integration. Default: true
- kotti.g4f.model
The default model to use. Default: gpt-4
- kotti.g4f.provider
The provider to use (optional). Default: auto
Usage
Adding a G4FChat Content Type
Log in to your Kotti2 site as admin
Navigate to any Document
Click “Add” in the menu
Select “G4F Chat”
Configure: - Title: Name of your chat page - Description: Brief description - System Prompt: Instructions for the AI (optional) - Welcome Message: Message shown to users (optional) - Model: AI model to use (e.g., gpt-4, gpt-3.5-turbo)
Direct Chat Access
Navigate to /@@g4f-chat to access the global AI chat interface.
API Endpoint
POST /@@g4f-api or /<g4f-chat-page>/api
Send a chat message and receive AI response.
Request body (JSON):
{
"message": "Your question here",
"history": [
{"role": "user", "content": "Previous question"},
{"role": "assistant", "content": "Previous answer"}
]
}
Response (JSON):
{
"response": "AI response text"
}
Security
kotti2_g4f includes several security measures:
Input Validation: Message length limits (10,000 chars), history limits (50 items)
Model Whitelist: Only approved models can be used
XSS Protection: All user input is escaped
Error Handling: Generic error messages, detailed logging
Supported Models
GPT-4, GPT-4o, GPT-4-turbo
GPT-3.5-turbo
Claude-3-opus, Claude-3-sonnet, Claude-3-haiku
Gemini-pro, Gemini-1.5-pro
Development
Running Tests
pip install -e ".[testing]" pytest
Code Quality
pip install black isort flake8 black kotti_g4f isort kotti_g4f flake8 kotti_g4f
Docker
docker-compose up
This starts: - Kotti web server on port 5000 - PostgreSQL database on port 5432
License
MIT License. See LICENSE.txt for details.
Links
Documentation: https://github.com/Kotti/kotti2_g4f#readme
Source Code: https://github.com/Kotti/kotti2_g4f
Issue Tracker: https://github.com/Kotti/kotti2_g4f/issues
Kotti2 CMS: https://pypi.org/project/Kotti2/
Project details
Release history Release notifications | RSS feed
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 kotti2_g4f-3.0.2.tar.gz.
File metadata
- Download URL: kotti2_g4f-3.0.2.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c1a5017e7e6a94d4c3bc6f815e09de8f90fde79d40661d2a01d03c0cd7964e2
|
|
| MD5 |
62845ff51b85f4bd7caab7d95e0e2399
|
|
| BLAKE2b-256 |
09e61246052fdbc4b3c5b586264fdc8973526a7fc2385c8416c872e538dc2d17
|
File details
Details for the file kotti2_g4f-3.0.2-py3-none-any.whl.
File metadata
- Download URL: kotti2_g4f-3.0.2-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55ce08bbca79de3dd4f07f9a6ee09e54ace6d535648b900d911e04496a72a250
|
|
| MD5 |
1a743d61ac8d4c7a75c48feac57fe882
|
|
| BLAKE2b-256 |
c6411b575c4a956c3bae1871489b06f8b1c08ea9fe9e30408c3b256a131df318
|