This is a powerful, multi-functional chat application that leverages local language models to provide advanced conversational capabilities with integrated tool calling. Built using Flask and OpenAI's function calling API, the application allows users to interact with an AI assistant that can perform a wide range of tasks through specialized tools.
- Flask application with static folder set to "templates"
- Uses OpenAI client configured to connect to a local LM Studio instance (port 1234)
- Uses Qwen 2.5 7B Instruct model
The application provides 7 core tools:
python
: Executes Python code securelyweb
: Performs web searches and extracts citationswiki
: Searches Wikipedia articlesweb_url
: Scrapes content from specific URLsimage
: Searches for imagesvideo
: Searches YouTube videosyt_url
: Retrieves YouTube video metadata
- Conversations are stored in a "conversations" directory as JSON files
- Each conversation has:
- Unique UUID
- Last updated timestamp
- Message history
- Auto-generated name based on content
/
: Home page/chat
: Main chat endpoint (POST)/conversations
: List all conversations (GET)/conversation/<id>
: Get/Delete specific conversation (GET/DELETE)/new
: Create new conversation (POST)/interrupt
: Stop current processing (POST)/messages
: Get formatted message history (GET)/delete-last
: Remove last message (POST)/regenerate
: Regenerate last response (POST)
- Streaming response generation
- Tool execution pipeline
- Message history tracking
- Error handling
- Conversation auto-saving
- Message formatting for frontend display
- Receives user message
- Streams response from model
- Detects tool calls in response
- Executes tools as needed
- Streams results back to client
- Continues conversation if more tool calls needed
- Secure Python code execution (via separate executor)
- Error handling throughout
- Development server warning
- Interrupt capability for long-running operations
- Persistent storage of conversations
- Automatic conversation naming
- Message history formatting
- Tool results tracking
- Python 3.8+
- LM Studio
- pip (Python package manager)
- Clone the repository
git clone https://github.com/yossifibrahem/LLM-Tool-Calling-Web-Application.git
cd LLM-Tool-Calling-Web-Application
- Install required Python libraries
pip install numpy pandas sympy flask openai duckduckgo_search pytubefix youtube_transcript_api waitress
- Set Environment Variables
export FLASK_ENV=production
export FLASK_DEBUG=0
python app.py
The application will be accessible at http://localhost:5000
- Modify the OpenAI client configuration in
app.py
to point to your local LM Studio server - Adjust model selection as needed
- Customize tool configurations in the
Tools
list
- Model: Qwen2.5 7B Instruct (via LM Studio)
- Backend: Flask, Python
- Frontend: HTML, Tailwind CSS, JavaScript
- Libraries:
- OpenAI API
- Marked.js
- Prism.js
- KaTeX
Contributions are welcome! Please feel free to submit a Pull Request.
- LM Studio for providing local inference capabilities
- tankibaj for web searching
- crawl4ai for web scraping
- Open-source libraries used in the project
This project is a demonstration of local AI tool calling and should be used responsibly.
This README is written Anthropic's Claude