
Simple RAG Application to Summarize Paragraph Using Local Appsmith + Ollama+ Google Sheet
Goal
The goal is to create an app in Appsmith that can summarize text using Llama AI. It will take paragraphs from Google Sheets, summarize them, display the results in Appsmith, and save the summary back to Google Sheets.
Prerequisites
Google Sheet as Datasource
Ollama- Llama3.2 (LLM)
Self-hosted Appsmith instance
Overview
Paragraph summarization is built using Appsmith, which is installed locally (self-hosted) using Docker, and Ollama, which is also installed locally. This setup ensures better security, data privacy, and fast processing since everything runs on your own machine without relying on external services. To install and run Appsmith locally, follow the steps provided in the Self-Hosting Guide.
Install Ollama LLM Llama3.2 locally
- Download Ollama from https://ollama.com/download for MacOS
- Unzip downloaded file & install it locally
- Open MacBook terminal & types
ollama run llama3.2
to Install & Run Llama3.2 - Ask any query in terminal it will give the text output for it in terminal
- Verify Installation by running
ollama list
- Verify Ollama running on local host by using
http://localhost:11434/
in browser
Setup google sheet for data source in Appsmith
- Appsmith provide the inbuilt integration with Google Sheet
- Go to Datasource & Select Google Sheet> Give required permissions & select Sheet
- Write Appsmith query to get all Paragraphs available in datasource name it as "getAllParagraphs"
4. Write Google Sheet query to Update the Paragraph record with generates summary in summary column, name it as "SaveSummary"
Create Interactive & simple UI on Local Appsmith
-
Add a Table Widget to display paragraphs from Google Sheets.
Data binding
{{getAllParagraphs.data}}
-
Add a Text Widget to show the generated summary.
Data binding:
{{ generate_summary.data.response }}
- Add a Button Widget to save summary of paragraph
-
Connect Appsmith to Llama3.2
- In Appsmith, create a REST API Datasource pointing to the Llama model API.
- Use a POST request to send the paragraph for summarization.
- Method=> POST
- URL:
http://host.docker.internal:11434/api/generate
-
Body=> { "model": "llama3.2", "prompt": "{{ 'Summarize the paragraph in single line:\n\n' + JSON.stringify(Table1.triggeredRow.Paragraph) }}", "stream": false }
- Note: When running Appsmith locally using Docker, it runs inside a Docker container,
host.docker.internal
=> ensures that Appsmith inside the Docker container can successfully connect Ollama running on the local machine. - Name this API "generate_summary"
-
Call API on "Generate" button trigger Action for each rows of Table
Bind the response to the Text Widget to display the summary.
Store Summary in Google Sheet
- Add a "Save Summary" button in Appsmith.
-
Use the Google Sheets query to update the row with the generated summary. Name it as "SaveSummary"
Operation=> UpdateOne
Update row Object=>
{ "rowIndex": {{Table1.triggeredRow.rowIndex}}, "id": "{{Table1.triggeredRow.ID}}", "Paragraph": "{{Table1.triggeredRow.Paragraph}}", "Summary": "{{generate_summary.data.response}}" }
-
Call "SaveSummary" API on "Save Summary" button OnClick event
{{SaveSummary.run().then(() => { showAlert('Paragraph summary saved successfully!', 'success'); getAllParagraphs.run(); });}}
Conclusion
This setup allows for AI-powered text summarization while keeping data management simple and accessible.