Clean, composable micro agentic bot - Teaching kernel for agentic AI
Project description
Groqqy ๐ค
Clean, composable micro agentic bot powered by Groq
Ultra-fast, ultra-cheap, and truly agentic. Groqqy is a multi-step reasoning agent that can read files, run commands, search content, and chain tool calls to complete complex tasks.
Why Groqqy?
- โก Fast: 460+ tokens/sec (11x faster than standard inference)
- ๐ฐ Cheap: $0.00002-$0.00006 per interaction (300x cheaper than GPT-4)
- ๐ง Agentic: Multi-step reasoning loop (THINK โ ACT โ OBSERVE)
- ๐ ๏ธ Tool-capable: Execute local tools with automatic chaining
- ๐งฉ Composable: Mix and match components (Agent, Tools, Memory, etc.)
- ๐ Teaching-friendly: Clean, readable code perfect for learning agentic AI
What's New in v2.0.0
Strategy Pattern + Platform Tools - Extensible tool execution architecture:
- โจ Strategy Pattern: Pluggable tool execution (Local/Platform/Hybrid strategies)
- ๐ Web Search: Browser search via Groq's platform tools (Tavily API)
- ๐ Platform Tools: Server-side tool execution (browser_search, web_search)
- ๐ฏ Auto-Detection: Automatically selects appropriate strategy based on tool types
- ๐ Backward Compatible: Existing code works unchanged
See CHANGELOG.md for full details.
Previous: v0.3.0 Architecture Refactor
- โ Agentic Loop: Multi-step reasoning (think/act/observe pattern)
- โ Tool Registry: Dynamic tool registration
- โ Composable Components: ConversationManager, ToolExecutor, CostTracker
Installation
# Clone the repository
git clone https://github.com/scottsen/groqqy.git
cd groqqy
# Install (use virtual environment recommended)
pip install -e .
Note: Requires Python 3.8+ and a Groq API key (set GROQ_API_KEY environment variable).
Quick Start
Interactive Chat
groqqy
Or using Python module directly:
python -m groqqy.cli
Programmatic Use
Basic usage (same API as before):
from groqqy import Groqqy
bot = Groqqy()
# Simple conversation
response, cost = bot.chat("Hello! What can you do?")
print(response)
print(f"Cost: ${cost:.6f}")
# Use tools (agent will chain them as needed)
response, cost = bot.chat("Find all .py files and count the lines in each")
print(response) # Agent will: search โ read each file โ count โ report
# Reset conversation
bot.reset()
Advanced usage (new in v0.3.0):
from groqqy import Groqqy, ToolRegistry
# Create custom tool registry
registry = ToolRegistry()
def analyze_sentiment(text: str) -> str:
"""Analyze sentiment of text."""
# Your implementation
return "Positive sentiment detected"
registry.register_function(analyze_sentiment)
# Create bot with custom tools and settings
bot = Groqqy(
model="llama-3.3-70b-versatile",
tools=registry,
max_iterations=20, # Allow more complex reasoning
system_instruction="You are a helpful code analyst"
)
response, cost = bot.chat("Analyze the sentiment of README.md")
Platform Tools & Web Search (v2.0+)
Groqqy now supports platform tools that execute on Groq's servers, starting with browser_search for web access:
from groqqy import Groqqy
from groqqy.tool import ToolRegistry
# Create registry with platform tool
registry = ToolRegistry()
registry.register_platform_tool("browser_search")
# Use a compatible model
bot = Groqqy(
model="openai/gpt-oss-20b", # Required for platform tools
tools=registry
)
# Ask questions that require web search
response, cost = bot.chat(
"What are the latest developments in AI this week?"
)
print(response) # Gets current information from the web
Compatible Models for Platform Tools:
openai/gpt-oss-20b(recommended)llama-3.3-70b-versatile- Llama 4 Scout (when available)
Mix with Local Tools (Hybrid):
from groqqy.tools import read_file, search_files
# Add both platform and local tools
registry.register_platform_tool("browser_search")
registry.register_function(read_file)
registry.register_function(search_files)
bot = Groqqy(model="openai/gpt-oss-20b", tools=registry)
# Agent automatically uses appropriate tools
response, cost = bot.chat(
"Search the web for Python best practices, "
"then check if our code follows them"
)
# Uses browser_search for web + read_file for local code
How Platform Tools Work:
- Tools execute server-side on Groq's infrastructure
- Results appear directly in the response (no local execution)
- Strategy Pattern automatically detects and handles tool types
- See
examples/example_web_search.pyfor complete examples
Architecture
High-Level Overview
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Bot (Simple API) โ
โ chat() โโโบ Agent.run() โ
โ reset() โโโบ Agent.reset() โ
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโผโโโโโโโโโโโ
โ Agent โ
โ (Agentic Loop) โ
โ THINKโACTโOBSERVE โ
โโโโโโโโโโโฌโโโโโโโโโโโ
โ
โโโโโโโโโโโโโผโโโโโโโโโโโโฌโโโโโโโโโโโโโโโ
โ โ โ โ
โผ โผ โผ โผ
โโโโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โConversat-โ โ Tool โ โ Cost โ โ Provider โ
โion Mgr โ โExecutorโ โ Tracker โ โ (LLM) โ
โโโโโโโโโโโโ โโโโโโฌโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโ
โToolRegistry โ
โ (extensible) โ
โโโโโโโโโโโโโโโโ
Agentic Loop (THINK โ ACT โ OBSERVE)
The heart of Groqqy is the multi-step reasoning loop in agent.py:
User: "Find Python files and count their lines"
โ
โผ
โโโโโโโโโโโโโโโโโ
โ THINK (LLM) โ โโโบ "I need to search for .py files first"
โโโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโ
โ ACT (Tool) โ โโโบ execute: search_files("*.py")
โโโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโ
โ OBSERVE โ โโโบ "Found: app.py, test.py, main.py"
โโโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโ
โ THINK (LLM) โ โโโบ "Now I need to read each file and count lines"
โโโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโ
โ ACT (Tools) โ โโโบ execute: read_file("app.py"), read_file("test.py"), ...
โโโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโ
โ OBSERVE โ โโโบ "app.py: 150 lines, test.py: 89 lines, ..."
โโโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโ
โ THINK (LLM) โ โโโบ "I have all the data, I'll summarize"
โโโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Response: "Found 3 Python โ
โ files with a total of 289 โ
โ lines: app.py (150), ..." โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
This pattern follows the ReAct framework (Yao et al., 2022) and enables true agentic behavior.
File Structure
groqqy/
โโโ __init__.py # Package exports
โโโ bot.py (140 lines) # Simple facade over Agent
โโโ agent.py (175 lines) # Agentic loop (THINK/ACT/OBSERVE)
โโโ strategy.py (209 lines) # Tool execution strategies (v2.0+)
โโโ tool.py (199 lines) # Tool registry system
โโโ tools.py (77 lines) # Built-in tools (read, search, run)
โโโ cli.py (141 lines) # Interactive CLI
โโโ config.py (116 lines) # Configuration system (~/.groqqy/)
โโโ log.py (117 lines) # Logging (loguru + JSONL)
โโโ provider.py (35 lines) # Provider interface
โโโ utils.py (73 lines) # Tool schema builder
โ
โโโ components/ # Composable components
โ โโโ conversation.py # Message history manager
โ โโโ executor.py # Tool execution with error handling
โ โโโ tracker.py # Cost tracking
โ
โโโ providers/ # LLM providers
โโโ groq.py # Groq provider implementation
Key Design Principles:
- All files <200 lines
- Single responsibility per component
- Easy to understand and modify
- Production-ready patterns
See ARCHITECTURE.md for detailed component descriptions.
Built-in Tools
Groqqy comes with 4 essential tools:
- read_file(file_path: str) - Read file contents
- run_command(command: str) - Execute shell commands (secure)
- search_files(pattern: str, path: str) - Find files by pattern
- search_content(query: str, path: str) - Search text in files
All tools use shlex.quote() for security (prevents shell injection).
Custom Tools
Simple Approach (Pass Functions)
from groqqy import Groqqy
def get_weather(city: str) -> str:
"""Get weather for a city."""
# Your implementation
return f"Weather in {city}: Sunny, 72ยฐF"
def calculate_tip(bill: float, percent: float = 15.0) -> str:
"""Calculate tip amount."""
tip = bill * (percent / 100)
return f"Tip: ${tip:.2f}, Total: ${bill + tip:.2f}"
# Just pass functions - auto-registration!
bot = Groqqy(tools=[get_weather, calculate_tip])
response, cost = bot.chat("What's the weather in SF?")
Advanced Approach (Tool Registry)
from groqqy import Groqqy, ToolRegistry
# Create registry
registry = ToolRegistry()
# Define tools
def analyze_code(file_path: str) -> str:
"""Analyze Python code for issues."""
# Your implementation
return "Analysis: 3 issues found..."
def run_tests(test_pattern: str) -> str:
"""Run tests matching pattern."""
# Your implementation
return "Tests passed: 15/15"
# Register with custom descriptions
registry.register_function(analyze_code, "Static analysis tool")
registry.register_function(run_tests, "Test runner")
# Inspect registry
print(f"Available tools: {registry.list_names()}")
print(f"Total tools: {len(registry)}")
# Use in bot
bot = Groqqy(tools=registry)
Tool Requirements:
- Type annotations for all parameters
- Docstring (used as tool description for LLM)
- Return type:
str(LLM sees the output) - Handle errors gracefully (return error message, don't raise)
See examples/custom_tools.py for complete examples.
Configuration
Groqqy supports persistent configuration via ~/.groqqy/:
~/.groqqy/
โโโ boot.md # System instructions (loaded on startup)
โโโ knowledge/ # Additional context files
โโโ domain_info.md
โโโ api_docs.txt
CLI options:
# Interactive mode (loads boot.md)
groqqy
# Single-shot mode
groqqy --prompt "What's 15 * 23?"
# With context files
groqqy --context docs.md --context api.txt -p "Explain the API"
# Skip boot.md
groqqy --no-boot
# Custom model
groqqy --model llama-3.3-70b-versatile
Programmatic configuration:
bot = Groqqy(
model="llama-3.1-8b-instant",
tools=my_tools,
max_iterations=20,
system_instruction="You are a code analyst specialized in Python"
)
Cost Examples
Real costs from actual usage:
- Simple conversation: $0.000022
- Search files: $0.000028
- Run command: $0.000032
- Read file: $0.000058
- Multi-step task (3 tool calls): ~$0.000120
1,000 interactions: ~$0.03-$0.12 (vs $10-$100 with other providers)
Models
Groqqy supports all Groq models:
# Fast and cheap (default)
bot = Groqqy(model="llama-3.1-8b-instant")
# Fastest (460+ tok/sec)
bot = Groqqy(model="llama-4-scout")
# Best quality
bot = Groqqy(model="llama-3.3-70b-versatile")
# Mixture of experts
bot = Groqqy(model="mixtral-8x7b-32768")
Advanced Usage
Component Composition
For advanced users who want to customize behavior:
from groqqy import Agent, ToolRegistry, ConversationManager, ToolExecutor, CostTracker
from groqqy.providers import GroqProvider
# Create custom components
provider = GroqProvider(model="llama-3.3-70b-versatile")
registry = ToolRegistry()
registry.register_function(my_custom_tool)
# Compose custom agent
agent = Agent(
provider=provider,
tools=registry,
max_iterations=50 # More complex reasoning
)
# Run directly
result = agent.run("Complex multi-step task")
print(result.response)
print(f"Iterations: {result.iterations}")
print(f"Tool calls: {result.tool_calls_made}")
print(f"Cost: ${result.total_cost:.6f}")
Custom Components
Extend components with custom behavior:
from groqqy.components import ToolExecutor
class CachingExecutor(ToolExecutor):
"""Tool executor with result caching."""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.cache = {}
def execute(self, tool_call):
# Create cache key
key = (tool_call['function']['name'],
tool_call['function']['arguments'])
# Check cache
if key in self.cache:
return self.cache[key]
# Execute and cache
result = super().execute(tool_call)
self.cache[key] = result
return result
# Use in agent
from groqqy import Agent
agent = Agent(provider, tools, executor=CachingExecutor(tools))
Examples
See examples/ directory:
- basic_chat.py - Simple conversation
- custom_tools.py - Adding custom tools
- tool_usage.py - Tool calling patterns
Teaching & Learning
Groqqy is designed as a teaching kernel for agentic AI. The codebase is:
- Readable: All files <200 lines, clear intent
- Well-structured: Clean separation of concerns
- Pedagogical: Comments explain THINK/ACT/OBSERVE pattern
- Production-ready: Real patterns (logging, cost tracking, safety)
For educators and learners, see:
- TEACHING_GUIDE.md - How to use Groqqy to learn/teach agentic AI
- ARCHITECTURE.md - Deep dive into component design
- AGENTIC_ARCHITECTURE_PROPOSAL.md - Design philosophy
Key concepts demonstrated:
- ReAct pattern (Thought โ Action โ Observation)
- Tool calling and execution
- Multi-step reasoning
- Dynamic tool registration
- Composable architecture
- Production safety (max iterations, error handling, cost tracking)
Requirements
- Python 3.8+
- Groq API key (set
GROQ_API_KEYenv var) - Dependencies:
requests,loguru(auto-installed via pip)
License
MIT
Related
- Groq API Docs
- ReAct Paper (Yao et al., 2022)
- LangChain - Production agentic framework
- LangGraph - Graph-based agents
Version History
- v0.3.0 (2025-11-28) - Agentic architecture refactor (multi-step reasoning)
- v0.2.0 (2025-11-28) - Configuration system + security fixes
- v0.1.0 (2025-11-27) - Initial standalone release
Built with โค๏ธ using Groq's blazing-fast LPU inference
Perfect for: Learning agentic AI, rapid prototyping, cost-conscious automation, teaching AI agents
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file groqqy-2.0.0.tar.gz.
File metadata
- Download URL: groqqy-2.0.0.tar.gz
- Upload date:
- Size: 27.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42cc51e0ae1583cd9602c942843c6040982f0ef73b9911d50bcbc6740fd86fac
|
|
| MD5 |
fe1955c962506bd76bef78a8a87cf540
|
|
| BLAKE2b-256 |
8cdcc44dd8eac522873390647aab65e781ee463243d773e54126c04e7a7c46a4
|
Provenance
The following attestation bundles were made for groqqy-2.0.0.tar.gz:
Publisher:
publish.yml on scottsen/groqqy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
groqqy-2.0.0.tar.gz -
Subject digest:
42cc51e0ae1583cd9602c942843c6040982f0ef73b9911d50bcbc6740fd86fac - Sigstore transparency entry: 731663313
- Sigstore integration time:
-
Permalink:
scottsen/groqqy@44b2d89ee53665d2d5575f38d9a49deea5142e54 -
Branch / Tag:
refs/tags/v2.0.0-post1 - Owner: https://github.com/scottsen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@44b2d89ee53665d2d5575f38d9a49deea5142e54 -
Trigger Event:
release
-
Statement type:
File details
Details for the file groqqy-2.0.0-py3-none-any.whl.
File metadata
- Download URL: groqqy-2.0.0-py3-none-any.whl
- Upload date:
- Size: 27.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
880835b17af0c9224b6d418727b6edb6866acf45e123a9aa9ff76dc70c29fd6f
|
|
| MD5 |
3357a3f89b2f357a65d23c3cbf5bf0cc
|
|
| BLAKE2b-256 |
dd865c9d17e0e858e0bf10893aec4a205f78f4315117854fbc0b06253f3b5e3a
|
Provenance
The following attestation bundles were made for groqqy-2.0.0-py3-none-any.whl:
Publisher:
publish.yml on scottsen/groqqy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
groqqy-2.0.0-py3-none-any.whl -
Subject digest:
880835b17af0c9224b6d418727b6edb6866acf45e123a9aa9ff76dc70c29fd6f - Sigstore transparency entry: 731663316
- Sigstore integration time:
-
Permalink:
scottsen/groqqy@44b2d89ee53665d2d5575f38d9a49deea5142e54 -
Branch / Tag:
refs/tags/v2.0.0-post1 - Owner: https://github.com/scottsen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@44b2d89ee53665d2d5575f38d9a49deea5142e54 -
Trigger Event:
release
-
Statement type: