This project demonstrates how to integrate the AI model google/gemma-2-2b-it
from Hugging Face into a Flutter application. The app functions as a chatbot, allowing users to ask questions and receive AI-generated responses. The AI model is accessed through HTTP requests using the Hugging Face Inference API, and the responses are displayed in markdown format within the app.
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter development, view the online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
-
Clone the repository
git clone https://github.com/FarrelAD/Flutter-AI-Chat-App.git
-
Navigate to the project repository
cd Flutter-AI-Chat-App
-
Install dependencies
flutter pub get
-
Configure Hugging Face API key
Rename file
.env.example
to.env
. And then, change API key value with your actual API key from Hugging Face. -
Run the app
flutter run
This project is a simple demonstration and is not perfect. If you plan to build an AI chat application based on this app, please consider the following limitations:
-
Stateless AI Chat
- The AI chat is stateless, meaning it cannot understand or remember previous conversations. Each message is treated independently, and only the current input is sent to the model.
- If your app requires conversational context or memory, additional implementation for state management or conversation history is necessary.
-
Raw Response Formatting
- The chat response is not formatted perfectly. Sometimes the AI model responds in a markdown-like format, but the app currently displays the raw data response as is.
- To improve user experience, you may need to implement proper formatting or markdown rendering for consistent output.
These are key areas to improve upon if you plan to extend this app for real-world use cases.