Skip to content

Instantly share code, notes, and snippets.

@shricodev
Created June 4, 2025 08:30
Show Gist options
  • Save shricodev/a69d25311c14c24646747520e3771e20 to your computer and use it in GitHub Desktop.
Save shricodev/a69d25311c14c24646747520e3771e20 to your computer and use it in GitHub Desktop.
Google Sheet AI Agent (Claude Sonnet 4)
● I'll create a Google Sheets agent project for you. Let me start by setting up the project structure and files.
● Update Todos
⎿  ☐ Initialize uv project with pyproject.toml
☐ Create main application file
☐ Create utility functions for connections
☐ Create example configuration file
● Bash(uv init --lib)…
⎿  Initialized project `google-sheet-agent`
● Update Todos
⎿  ☒ Initialize uv project with pyproject.toml
☐ Create main application file
☐ Create utility functions for connections
☐ Create example configuration file
● Read(pyproject.toml)…
⎿  Read 15 lines (ctrl+r to expand)
● Update(pyproject.toml)…
⎿  Updated pyproject.toml with 6 additions and 2 removals
1 [project]
2 name = "google-sheet-agent"
3 version = "0.1.0"
4 description = "Add your description here"
4 description = "Natural language interface for Google Sheets operations"
5 readme = "README.md"
6 authors = [
7 { name = "Shrijal Acharya", email = "[email protected]" }
8 ]
9 requires-python = ">=3.12"
10 dependencies = []
10 dependencies = [
11 "composio_llamaindex",
12 "llama-index-llms-openai",
13 "python-dotenv"
14 ]
15
16 [build-system]
17 requires = ["hatchling"]
● Write(sheet_assistant.py)…
⎿  Wrote 101 lines to sheet_assistant.py
import os
from pathlib import Path
from composio_llamaindex import App, ComposioToolSet
from dotenv import load_dotenv
from llama_index.core.agent import FunctionCallingAgentWorker
from llama_index.core.llms import ChatMessage
from llama_index.llms.openai import OpenAI
from connection_helper import setup_google_sheets_auth
… +91 lines (ctrl+r to expand)
● Update Todos
⎿  ☒ Initialize uv project with pyproject.toml
☒ Create main application file
☐ Create utility functions for connections
☐ Create example configuration file
● Write(connection_helper.py)…
⎿  Wrote 41 lines to connection_helper.py
"""
Helper module for managing Google Sheets authentication and connections.
"""
def setup_google_sheets_auth(user_entity_id, application_name, composio_toolset):
"""
Establish or retrieve existing Google Sheets connection for the user.
Args:
user_entity_id (str): Unique identifier for the user entity
… +31 lines (ctrl+r to expand)
● Update Todos
⎿  ☒ Initialize uv project with pyproject.toml
☒ Create main application file
☒ Create utility functions for connections
☐ Create example configuration file
● Write(config_example.yml)…
⎿  Wrote 30 lines to config_example.yml
id: sheets_natural_language_interface
name: Google Sheets Natural Language Interface
description: AI-powered assistant for interacting with Google Sheets using conversational commands
metadata:
language: python
framework: llamaindex
tools_used:
- googlesheets
… +20 lines (ctrl+r to expand)
● Write(.env.example)…
⎿  Wrote 8 lines to .env.example
# Composio API Configuration
COMPOSIO_API_KEY=your_composio_api_key_here
# OpenAI API Configuration
OPENAI_API_KEY=your_openai_api_key_here
# Entity Configuration
ENTITY_ID=your_entity_id_here
● Update Todos
⎿  ☒ Initialize uv project with pyproject.toml
☒ Create main application file
☒ Create utility functions for connections
☒ Create example configuration file
● Perfect! I've created a complete Google Sheets agent project with the following structure:
Project Files Created:
1. pyproject.toml - Project configuration with dependencies
2. sheet_assistant.py - Main application with natural language interface
3. connection_helper.py - Authentication and connection utilities
4. config_example.yml - Example configuration and usage guide
5. .env.example - Environment variables template
Key Features:
- Natural Language Interface: Ask questions in plain English about your spreadsheets
- Robust Error Handling: Comprehensive validation and error messages
- Clean Code Structure: Modular design with separated concerns
- User-Friendly: Clear prompts and feedback messages
Next Steps:
1. Install dependencies: Run uv sync to install all required packages
2. Set up environment: Copy .env.example to .env and add your API keys
3. Run the application: Use uv run sheet_assistant.py to start the assistant
The application will prompt you for a Google Sheets URL and then ask what operations you'd like to perform using natural language commands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment