GemmaLangServeAPI is a FastAPI-powered API service built using Google's Gemma 2B LLM integrated through LangChain and LangServe. It allows users to submit Python code and receive human-like explanations in response — ideal for educational, debugging, or AI-assistance use cases.
Hosted via ngrok for easy sharing and accessible testing through Postman.
- 🧠 Explains Python functions in natural language
- 🔗 Easily deployable via FastAPI + LangServe
- ⚡ Supports Hugging Face Gemma 2B model pipeline
- 🧪 API testing-ready via Postman or Swagger UI
- ☁️ Hosted via Google Colab with public URL through ngrok
| Layer | Technology / Tool |
|---|---|
| API Framework | FastAPI |
| LLM | Gemma 2B by Google |
| Model Pipeline | HuggingFace Transformers |
| Orchestration | LangChain + LangServe |
| Serving | Uvicorn |
| Tunneling | ngrok |
| LLM Wrapper | HuggingFacePipeline |
| Test Tool | Postman |
| Platform | Google Colab |
Install dependencies:
pip install fastapi uvicorn transformers langchain langserve langchain_huggingface huggingface_hub pyngrok nest_asynciopython app.pyYou’ll get a public URL via ngrok, like:
🔗 https://your-subdomain.ngrok-free.app/docs
Open the /docs route to explore Swagger UI or test it using Postman.
| Method | Endpoint | Description |
|---|---|---|
| POST | /explain | Submit Python code for explanation |
Content-Type: application/json
{
"code": "def add(a, b): return a + b"
}{
"output": "This function takes two parameters and returns their sum."
}GemmaLangServeAPI/
├── app.py # FastAPI + LangChain setup
├── requirements.txt # All dependencies
└── README.md # You're reading it!
- 👨💻 Educational tools or tutorials
- 🧠 AI-powered code explanation service
- 🤖 Backend service for developer assistance tools
This project is licensed under the MIT License.
- 🤖 Google AI – Gemma LLM
- 🧱 LangChain
- 🤗 Hugging Face
- ⚡ FastAPI