Python Chatbot for Multi-Line Translation (Stateless & Configurable)
I'm sharing a Python script designed to send multi-line text requests to an AI server without storing conversation history. The folder structure is simple:
chatbot_project/
├── chatbot.py
├── run_chatbot.bat
├── setup.py
├── run setup.bat
├── venv/
└── configs/
├── 01 ChatGPT 3.5 Turbo.txt
├── 02 DeepSeek V3 0324.txt
└── 03 Mistral Local.txt
Each `.txt` file inside `configs/` contains settings like the following example:
BASE_URL = "
You must be registered to see the links
"
MODEL = "deepseek-ai/DeepSeek-V3-0324"
API_KEY = "your-api-key"
SERVER_TYPE = "openai"
TEMPERATURE = 0.6
MAX_TOKENS = 8000
ENABLED = false
PROMPT = "You are a professional translator."
Key Features of `chatbot.py`:
- ✅ Supports multi-line input via terminal (note: you can't edit previously entered lines during input)
- ✅ Displays streaming responses as the AI types
- ✅ Stateless: does not retain history, ideal for long-form translations like VN scripts (the AI does not remember past exchanges)
- ✅ Only one AI will be used at a time—the first config file with `ENABLED = true` (based on filename order)
- ✅ You can add support for local servers like Ollama by changing the `BASE_URL` (never tested though, I personally have only used Chutes.ai so far)
- ✅ AI profile files are **fully customizable** — you can rename them, add new ones, or delete existing profiles at any time. As long as the format remains consistent, the script will work without any code changes.
Note: This project uses a virtual environment (`venv`).
Make sure to activate the environment before running the scripts,
unless you're running `setup.py`, which handles that automatically.
⚠ If you move this project to a different folder or copy it to another computer,
you'll need to reactivate or recreate the virtual environment.
In some cases, the existing `venv/` may not work due to absolute path references
tied to the original system.
To fix this, it's recommended to delete the existing `venv/` folder
and re-run `setup.py` or `run setup.bat` with working internet connection, which will recreate the environment
and install the necessary dependencies.
I also wrote a separate **Python script for counting tokens** in `.txt` files. It only needs an internet connection once to install the tokenizer library (like `tiktoken`) and can then be used completely offline. Very useful when you're working with long scripts and want to check if your input fits within a model’s token limit.
I'm not a programmer — this entire project was built with help from ChatGPT and Copilot as part of a hands-on learning process. If anyone would like to try it or wants the complete scripts (`chatbot.py` and the token counter), I’d be happy to share them.
If you encounter any issues, I kindly ask for your understanding.