Skip to main content

kotti2_g4f

CI Status PyPI Version

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

  1. Log in to your Kotti2 site as admin

  2. Navigate to any Document

  3. Click “Add” in the menu

  4. Select “G4F Chat”

  5. 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.

Metadata

Release files for kotti2-g4f 3.0.2

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

Source distribution (sdist)

Source distribution for kotti2-g4f 3.0.2
File Size Uploaded Provenance Actions
kotti2_g4f-3.0.2.tar.gz 14.9 kB Without provenance Details for kotti2_g4f-3.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kotti2-g4f 3.0.2
File Interpreter ABI Platform Actions
kotti2_g4f-3.0.2-py3-none-any.whl Python 3 none any Details for kotti2_g4f-3.0.2-py3-none-any.whl

Total release size: 31.3 kB

Release files / kotti2_g4f-3.0.2.tar.gz

Download URL kotti2_g4f-3.0.2.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5c1a5017e7e6a94d4c3bc6f815e09de8f90fde79d40661d2a01d03c0cd7964e2
BLAKE2b-256 checksum
How to use checksums
09e61246052fdbc4b3c5b586264fdc8973526a7fc2385c8416c872e538dc2d17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Release files / kotti2_g4f-3.0.2-py3-none-any.whl

Download URL kotti2_g4f-3.0.2-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55ce08bbca79de3dd4f07f9a6ee09e54ace6d535648b900d911e04496a72a250
BLAKE2b-256 checksum
How to use checksums
c6411b575c4a956c3bae1871489b06f8b1c08ea9fe9e30408c3b256a131df318
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Security for kotti2-g4f 3.0.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.

Release history Release notifications | RSS feed

This release

3.0.2 This release

2 release files No provenance

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