This project is a Streamlit-based AI Assistant that allows users to train, fine-tune, and chat with AI models using OpenAI's API.
- Upload and Process Data (PDF, CSV, JSON)
- Preprocess Data for fine-tuning
- Evaluate Model for model evaluation tool
- Fine-tune AI Models with OpenAI's API
- Multi-Agent AI Chat with customizable prompts
- Restricted Words Filtering to control AI responses
- Vision-Language Model (VLM) for AI-powered image analysis πΌοΈ
your_project/
βββ main.py # Main entry point for Streamlit app
βββ upload_and_train/
β βββ upload_an_Train.py # Handles file upload and preprocessing
βββ fine_tune/
β βββ fine_tune.py # Fine-tuning OpenAI models
βββ evaluate/
β βββ evaluate_model.py # Evaulate OpenAI models to the new trained model
βββ chat/
β βββ chat_with_model.py # AI chatbot interactions
βββ vlm/
β βββ text_vlm.py # AI Vision AI agent
βββ utils/
β βββ __init__.py # Marks `utils/` as a package
β βββ utils.py # Contains helper functions
βββ restricted_words.json # Stores restricted words & model list (optional)
βββ requirements.txt # Python dependencies
βββ README.md # Project documentation
git clone https://github.com/TimGoebel/Multi_Agent.git
cd Multi_Agentpython -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windowspip install -r requirements.txt
python -m spacy download en_core_web_smRun the Streamlit app with:
streamlit run main.pyor use run.bat (for Windows users):
@echo off
python -m streamlit run main.py
pause # Remove this if you don't want the CMD screen to stay open for troubleshooting
This project prepares and processes textual data from PDF, CSV, and JSON files for fine-tuning GPT models. It ensures high-quality, structured training data by applying advanced text cleaning, chunking, and formatting. The pipeline guarantees a minimum of 10 well-structured training examples, which is required for OpenAI fine-tuning.
- Supported Formats:
PDF,CSV,JSON - File Upload: Users can upload training data via Streamlitβs file uploader.
- Extraction Process:
CSVβ Loaded into a DataFrame.JSONβ Parsed as structured text.PDFβ Text is extracted page by page usingPyPDF2.
To improve model quality, raw text is cleaned using the following techniques:
- Unicode Normalization: Fixes encoding inconsistencies (
unicodedata.normalize("NFKC", text)). - HTML Tag Removal: Removes any embedded HTML content (
BeautifulSoup). - Hyphenation Fixes: Merges words split across lines (
cross-\nword β crossword). - Extra Whitespace Removal: Normalizes spacing (
re.sub(r"\s+", " ", text)). - Smart Quotes & Symbol Conversion: Converts to standard ASCII quotes and dashes (
ββ β ",β β -). - Spell Checking & Correction: Fixes common spelling errors (
SpellChecker).
To prevent mid-sentence breaks, the extracted text is split into meaningful units using spaCy:
- NLP Sentence-Based Chunking: Instead of breaking text arbitrarily at
chunk_size, it ensures semantic coherence. - Adaptive Chunking: If a chunk exceeds
1000characters, it is split into smaller, logical parts.
The UI supports flexible chunking and measurement settings:
- Chunking Method: Choose between Sentence-level or Paragraph-level segmentation.
- Measurement Type: Select how chunk length is measured β by Character count or Token count.
Each data sample is formatted as a conversational exchange:
{
"messages": [
{"role": "system", "content": "You are an AI trained on specialized data."},
{"role": "user", "content": "How does Mobile Lock protect authentication?"},
{"role": "assistant", "content": "Mobile Lock prevents unauthorized access by restricting authentication when threats are detected."}
]
}- Ensures well-structured conversations.
- Prevents empty "user" messages.
- Pairs each prompt with a valid assistant response.
- If the dataset contains fewer than 10 training pairs, additional examples are generated automatically.
- Large text blocks are split into multiple prompts, ensuring a diverse dataset.
- Default responses are used where assistant completions are missing.
The final dataset is saved in JSONL format, ready for OpenAI fine-tuning:
training_data.jsonlEach entry is saved on a new line to comply with OpenAIβs fine-tuning requirements.
- Upload a PDF, CSV, or JSON file.
- The data is chunked and preprocessed for fine-tuning.
- Train a new model using OpenAIβs fine-tuning API.
- Monitors training progress until completion.
- Click "Save Training Data" to export
training_data.jsonl. - Use OpenAIβs fine-tuning API to train the model.
Ensure the dataset is ready in JSONL format:
openai tools fine_tunes.prepare_data -f training_data.jsonlFine-tune using OpenAIβs API:
openai api fine_tunes.create -t training_data.jsonl -m gpt-3.5-turboUse the fine-tuned model in your AI assistant.
- Add local model fine-tuning support.
- add embedings
- Expand AI assistant multi-modal capabilities.
- Integrate vector search for improved retrieval.
This project is licensed under the MIT License.
- GitHub: Timothy Goebel
- LinkedIn: Timothy Goebel