A Flutter chat application that integrates with multiple AI providers (Ollama, Llama.cpp, LM Studio) through Ngrok tunnels.
ScreenRecording_08-15-2025.15-03-52_1.MP4
- Multi-Provider Support: Choose between Ollama, Llama.cpp, and LM Studio
- Modern UI: Clean, responsive design with Material 3
- State Management: BLoC pattern for predictable state management
- Navigation: GoRouter for type-safe navigation
- Real-time Chat: Smooth chat experience with automatic scrolling
- Environment Configuration: Configurable API endpoints through .env
- Extensible Architecture: Designed to support dynamic provider configuration in future iterations
The app follows a feature-based architecture with clear separation of concerns:
lib/
├── core/ # Core app functionality
│ ├── config/ # App configuration and routing
│ ├── constants/ # App constants and enums
│ ├── di/ # Dependency injection setup
│ └── theme/ # App theming
└── features/ # Feature modules
├── home/ # Home screen with provider selection
│ └── screens/
└── chat/ # Chat functionality
├── bloc/ # BLoC state management
├── models/ # Data models
├── screens/ # Chat screen
├── services/ # AI service implementations
└── widgets/ # Chat widgets
- Flutter SDK 3.6.2 or higher
- Dart SDK
- One or more of the following AI providers running locally:
- Ollama (default port: 11434)
- Llama.cpp server (default port: 8080)
- LM Studio (default port: 1234)
-
Clone the repository:
git clone <repository-url> cd it_3265_ngrok
-
Install dependencies:
flutter pub get
-
Configure your AI provider endpoints and models in the
.env
file:# OpenAI API Key OPENAI_API_KEY=your_openai_api_key_here # Current supported providers (hardcoded for now) OLLAMA_URL=https://your-ngrok-url.ngrok.io OLLAMA_MODEL=llama3.1 LLAMA_CPP_URL=https://your-ngrok-url.ngrok.io LLAMA_CPP_MODEL=llama3.2 LMSTUDIO_URL=https://your-ngrok-url.ngrok.io LMSTUDIO_MODEL=llama3.2
-
Run the app:
flutter run
- Launch the app - You'll see the home screen with provider selection
- Choose an AI provider - Select from the dropdown (Ollama, Llama.cpp, or LM Studio)
- Start chatting - Tap "Start Chat" to begin a conversation
- Send messages - Type your message and tap the send button
- Return home - Use the back button to return to provider selection
- Dropdown interface for choosing AI providers
- Visual icons for each provider type
- Information panel about Ngrok tunneling
- Note: Currently supports 3 hardcoded providers, but architecture allows for dynamic expansion
- Message bubbles with distinct styling for user vs AI messages
- Timestamp display for each message
- Auto-scroll to latest messages
- Loading states during AI response
- Error handling with user feedback
- BLoC pattern for predictable state management
- Reactive UI updates
- Proper loading and error states
- Message history management
The app uses the following environment variables (configured in .env
):
Required Variables:
OPENAI_API_KEY
: Your OpenAI API key (if using OpenAI directly)
Current Supported Providers (Hardcoded):
OLLAMA_URL
: Ollama API endpointOLLAMA_MODEL
: Model name for Ollama (e.g., llama3.2, codellama)LLAMA_CPP_URL
: Llama.cpp server endpointLLAMA_CPP_MODEL
: Model name for Llama.cpp (e.g., llama-2-7b-chat)LMSTUDIO_URL
: LM Studio API endpointLMSTUDIO_MODEL
: Model file name for LM Studio (e.g., llama-2-7b-chat.Q4_K_M.gguf)
Future Enhancement: The app architecture is designed to support dynamic provider configuration, allowing users to add any number of AI providers through environment variables with minimal code changes.
All AI providers are accessed through OpenAI-compatible APIs using the dart_openai
package. The app automatically configures the base URL based on the selected provider.
Make sure all tunnels are configured - type
ngrok config edit
and make sure the content is similar to ( provide your own authtoken and proper ports)
version: "3"
agent:
authtoken: {YOUR_AUTH_TOKEN}
log_level: debug
endpoints:
- name: llama
upstream:
url: 8080
traffic_policy:
inbound:
- actions:
- type: "add-headers"
config:
headers:
host: localhost
- name: ollama
upstream:
url: 11434
traffic_policy:
inbound:
- actions:
- type: "add-headers"
config:
headers:
host: localhost
- name: lmStudio
upstream:
url: http://localhost:1234
traffic_policy:
inbound:
- actions:
- type: "add-headers"
config:
headers:
host: localhost
Then run the
ngrok start --all
command to initiates all tunnels and to obtain public urls.
flutter test
flutter analyze
flutter run
- Hardcoded Providers: Currently supports 3 specific providers (Ollama, Llama.cpp, LM Studio)
- Extensible Design: Architecture allows for easy addition of new providers
- Dynamic Provider Configuration: Planned feature to read provider list from environment variables
- Provider Agnostic Design: Framework supports any OpenAI-compatible API endpoint
- Chosen for predictable state management
- Separates business logic from UI
- Easy testing and debugging
- Modular organization
- Clear separation of concerns
- Scalable architecture
- Type-safe navigation
- Declarative routing
- Better deep linking support
- Simple service locator pattern
- Easy dependency management
- Testability
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the BSD-3-Clause license License - see the LICENSE file for details.
Created by Oleksandr Kholiavko
Extrawest.com, 2025