A Text Summarizer AI project using LLaMA via Ollama, integrated with FastAPI for the backend, Streamlit for the frontend, and GitHub for version control and publishing.
- Summarize any text using LLaMA (via Ollama)
- FastAPI backend API
- Streamlit web frontend
- Easy local setup
llama-text-summarizer/
├── backend/
│ ├── main.py
│ └── requirements.txt
├── frontend/
│ ├── app.py
├── requirements.txt
├── README.md
- Python 3.8+
- Ollama installed and running
- LLaMA model pulled via Ollama
- Git
git clone https://github.com/Ichrafsassi/llama-text-summarizer.git
cd llama-text-summarizerpython3 -m venv venv
source venv/bin/activateollama serve
ollama pull llama2cd backend
pip install -r requirements.txt
uvicorn main:app --reloadfrom fastapi import FastAPI, Form
import requests
app = FastAPI()
@app.post("/summarize/")
def summarize(text: str = Form(...)):
response = requests.post(
"http://localhost:11434/api/generate",
json={
"model": "llama2",
"prompt": f"Summarize this:\n\n{text}",
"stream": False
}
)
result = response.json()
return {"summary": result.get("response", "No summary generated.")}Open a new terminal, activate your virtual environment, then:
cd frontend
pip install -r requirements.txt
streamlit run app.pyimport streamlit as st
import requests
st.title("LLaMA Text Summarizer")
user_input = st.text_area("Enter your text here:")
if st.button("Summarize"):
response = requests.post(
"http://localhost:8000/summarize/",
data={"text": user_input}
)
summary = response.json().get("summary", "Error generating summary.")
st.subheader("Summary:")
st.write(summary)- Open http://localhost:8501 in your browser.
- Enter the text you want to summarize.
- Click Summarize.
- The summary will appear below.
