A QuackTool for extracting structured metadata from text documents using large language models.
- Download text documents from Google Drive
- Extract structured metadata using LLMs (like GPT-4 or Claude)
- Validate output against a Pydantic schema
- Store results as
.metadata.jsonfiles - Upload metadata back to Google Drive
- Display metadata as trading cards in the terminal
# Clone the repository
git clone https://github.com/yourusername/quacktool.git
cd quackmetadata
# Install with development dependencies
pip install -e ".[dev]"Create a quack_config.yaml file in your working directory:
general:
project_name: QuackMetadata
integrations:
google:
client_secrets_file: config/google_client_secret.json
credentials_file: config/google_credentials.json
llm:
default_provider: openai
openai:
api_key: YOUR_OPENAI_API_KEY
default_model: gpt-4o- Create a Google Cloud Project and enable the Google Drive API
- Create OAuth credentials (Desktop application)
- Save the client secrets JSON file to
config/google_client_secret.json - On first run, authenticate through your browser when prompted
- Obtain an API key from OpenAI or Anthropic
- Add it to your configuration file or set it as an environment variable:
OPENAI_API_KEYfor OpenAIANTHROPIC_API_KEYfor Anthropic
Extract metadata from a local text file:
quackmetadata metadata extract path/to/file.txtExtract metadata from a Google Drive file (using file ID):
quackmetadata metadata extract 1abc2defg3hijAdditional options:
# Use a custom prompt template
quackmetadata metadata extract file.txt --prompt-template path/to/custom.mustache
# Don't upload results back to Google Drive
quackmetadata metadata extract file.txt --dry-run
# Specify an output path
quackmetadata metadata extract file.txt --output path/to/output.metadata.json
# Set number of retries for LLM calls
quackmetadata metadata extract file.txt --retries 5
# Enable verbose output
quackmetadata metadata extract file.txt --verbosefrom quackmetadata.plugins.metadata import MetadataPlugin
# Create and initialize the plugin
plugin = MetadataPlugin()
plugin.initialize()
# Process a file
result = plugin.process_file(
file_path="path/to/file.txt",
output_path="path/to/output.metadata.json",
options={
"prompt_template": "path/to/custom.mustache",
"retries": 3,
"dry_run": False,
"verbose": True
}
)
if result.success:
# Access the extracted metadata
metadata = result.content.get("metadata")
print(metadata)
else:
print(f"Error: {result.error}")The extracted metadata follows this structure:
class AuthorProfile(BaseModel):
name: str # Author's name
profession: str # Author's profession
writing_style: str # Writing style
possible_age_range: str # Estimated age range
location_guess: str # Possible location
class Metadata(BaseModel):
title: str # Document title
summary: str # Brief summary
author_style: str # Writing style
tone: str # Emotional tone
language: str # Document language
domain: str # Subject domain
estimated_date: str | None = None # Estimated date
rarity: str # Rarity classification
author_profile: AuthorProfile # Generated author profileCreate custom prompt templates using Mustache syntax. Templates should be placed in the prompts/metadata/ directory with a .mustache extension.
Available context variables:
{{content}}: The document content
Example template:
You are an assistant extracting metadata from a document.
Here is the content:
---
{{content}}
---
Extract the following fields:
- Title: ...
- Summary: ...
...When running the tool, you'll see a "metadata card" displayed in the terminal:
ββββββββββββββββββββββββββββββββββββββββββββ
β π METADATA CARD β
β βββββββββββββββββββββββββββββββββββββββββββ£
β Title: The Duck Rebellion β
β Domain: Politics / Satire β
β Tone: Ironic β
β Rarity: π£ Legendary β
ββββββββββββββββββββββββββββββββββββββββββββ
GNU GPL
QuackMetadata was created as a teaching tool to demonstrate:
- Prompt engineering
- Schema validation
- Integration of cloud services
- Good CLI/UX design
- Modularity and debugging
QuackVerse is a modular ecosystem with mixed licensing to balance community contribution and project protection.
- Repositories:
quackcore,ducktyper - License: GNU Affero General Public License v3.0 (AGPL-3.0)
- Why? This license ensures that any public use of these tools β including SaaS or hosted services β must release the source code and improvements back to the community.
- Repositories: All
quacktools/* - License: Business Source License 1.1 (BUSL-1.1)
- What does this mean?
- You can view, fork, and modify the code.
- Production or commercial use is not allowed unless you obtain a commercial license from us.
- The license automatically converts to Apache 2.0 after 3 years, ensuring long-term openness.
- A short human summary is provided in each tool's README.
- Assets: Logos, Mascot (Quackster), design elements
- License: Creative Commons Attribution-NonCommercial-NoDerivs 4.0 (CC BY-NC-ND 4.0)
- You may not redistribute, remix, or use our branding for commercial purposes.
We love open-source and education. However, to continue building high-quality learning tools, we need to protect our work from being commercialized or rebranded by others without contributing back. Our structure enables:
- A healthy developer community.
- Opportunities for contributors to shape the future.
- Commercial protection for sustainability.
We welcome pull requests, issues, and feedback. If you're interested in commercial use, please reach out via rod@aip.engineer.