Universal Context Transformation Engine - Transform questions into perfect, portable contexts
Project description
mycontext
Transform any question into perfect context - use it anywhere
What is mycontext?
mycontext is the universal context transformation engine for AI applications.
The Problem: Raw questions and unstructured prompts lead to inconsistent AI behavior, context rot, and wasted tokens.
The Solution: Transform questions into perfect, portable contexts that work with ANY AI system.
from mycontext.templates.free import QuestionAnalyzer
# Step 1: Transform raw question into perfect context
question = "Should I invest in solar panels?"
analyzer = QuestionAnalyzer()
# This creates a structured, optimized context
context = analyzer.build_context(
question=question,
context="Home: 2000 sqft, California, $200/month bill",
depth="comprehensive"
)
# Step 2: Use this context ANYWHERE!
# Option A: LangGraph
langgraph_agent.invoke(context.to_langchain())
# Option B: CrewAI
crew.kickoff(context=context.to_dict())
# Option C: Direct OpenAI
openai.chat.completions.create(messages=context.to_messages())
# Option D: Any framework via JSON
requests.post(api_url, json=context.to_json())
# Option E: Even humans can read it!
print(context.to_markdown())
One transformation โ Infinite uses
Why mycontext?
๐ฏ The Core Insight
Your questions need transformation, not just prompting.
โ Old Way: Raw Question โ LLM
"Should I invest in solar panels?"
โ Inconsistent, shallow responses
โ
New Way: Raw Question โ mycontext โ Perfect Context โ LLM
"Should I invest in solar panels?"
โ Structured analysis framework
โ Decision criteria
โ Evidence requirements
โ Financial calculations
โ Risk assessment
= Consistent, thorough, high-quality responses
๐ก What Makes mycontext Unique?
-
Universal Transformation Engine
- Input: Raw questions/tasks
- Process: Research-backed templates + RAG + optimization
- Output: Perfect, portable contexts
-
Works with EVERYTHING
- โ LangGraph, CrewAI, AutoGen (agent frameworks)
- โ LangChain, LlamaIndex, Haystack (RAG frameworks)
- โ OpenAI, Anthropic, Google (direct LLM APIs)
- โ OpenCE (context engineering backends)
- โ Custom APIs, internal tools
- โ Even human analysts!
-
Research-Backed Templates
- Based on "Context Engineering" book (IBM Zurich Research)
- Cognitive tools from scientific research
- Not hand-crafted prompts - engineered systems
-
Three User Levels
- General users: Use templates (no coding)
- Professionals: Customize patterns (light Python)
- Developers: Build production systems (full SDK)
-
API-Ready Architecture
- Universal export formats (JSON, messages, markdown)
- RESTful API coming soon
- Cloud platform in development
๐ Quick Start
Installation
# Core SDK
pip install mycontext
# With OpenAI
pip install mycontext[openai]
# With all providers (OpenAI, Anthropic, Google)
pip install mycontext[all]
30-Second Example
from mycontext.templates.free import QuestionAnalyzer
# Transform question into perfect context
analyzer = QuestionAnalyzer()
context = analyzer.build_context(
question="Should I invest in solar panels?",
context="California home, $200/mo electric bill"
)
# Use it anywhere!
# โ Export for OpenAI
messages = context.to_messages()
# โ Export for LangGraph
langchain_format = context.to_langchain()
# โ Export as JSON for API
json_data = context.to_json()
# โ Show to humans
print(context.to_markdown())
That's it! One transformation โ Use anywhere.
๐ฏ Core Features
1. Universal Context Transformation
Transform raw questions into structured, optimized contexts:
from mycontext import Context, Guidance, Directive
# Build a perfect context
context = Context(
guidance=Guidance(
role="Expert Financial Advisor",
rules=[
"Provide evidence-based analysis",
"Consider risk factors",
"Include calculations"
],
style="analytical, balanced"
),
directive=Directive("Should I invest in solar panels?")
)
# Export to any format
context.to_messages() # โ OpenAI, Anthropic, Google
context.to_langchain() # โ LangChain, LangGraph
context.to_json() # โ APIs, databases
context.to_markdown() # โ Humans, documentation
2. Research-Backed Templates
Pre-built cognitive tools from the "Context Engineering" book:
from mycontext.templates.free import (
QuestionAnalyzer, # Systematic question analysis
StepByStepReasoner, # Methodical problem solving
CodeReviewer, # Expert code review
ConceptExplainer, # Clear explanations
ContentOutliner # Structured content planning
)
# Use like a function - no prompt engineering needed
analyzer = QuestionAnalyzer()
result = analyzer.execute(
provider="openai",
question="Should we migrate to microservices?"
)
3. RAG Integration (Knowledge Grounding)
Enrich contexts with relevant knowledge:
from mycontext.intelligence.rag import create_retriever
# Create retriever with semantic chunking
retriever = create_retriever(
documents=["doc1.pdf", "doc2.md", ...],
embedder="openai",
chunk_strategy="semantic",
vector_store="faiss"
)
# Retrieve and build context
docs = retriever.retrieve("How do we handle auth?", k=3)
knowledge_context = retriever.build_context(docs)
# Add to any context
context = Context(
guidance=Guidance(role="Expert"),
knowledge=knowledge_context
)
4. Session Management (Prevents Context Rot)
Multi-turn conversations without unbounded growth:
from mycontext import Session, FileArchive
# Create managed session
session = Session(
max_tokens=4000, # Token budget
pruning_strategy="sliding" # Or "importance", "summary"
)
# Automatically manages context
session.add_user_message("What is context rot?")
session.add_assistant_message("Context rot is...")
session.add_user_message("How to prevent it?") # Auto-prunes if needed
# Persist to disk
archive = FileArchive("./sessions")
archive.save_session(session, tags=["context-engineering"])
5. Production Utilities
Token optimization, cost tracking, validation:
from mycontext.utils import (
TokenOptimizer, # Reduce token usage
CostTracker, # Monitor spending
ContextValidator, # Validate structure
StructuredOutput # Parse responses
)
# Optimize context
optimizer = TokenOptimizer(max_tokens=2000)
optimized = optimizer.optimize(context)
# Track costs
tracker = CostTracker()
tracker.track(result, session_id="user_123")
print(f"Total cost: ${tracker.total_cost()}")
๐ Framework Integration
mycontext works with ANY framework or LLM:
# LangGraph
from langgraph.graph import StateGraph
context = my_context.to_langchain()
graph.add_node("agent", lambda s: use_context(context))
# CrewAI
from crewai import Crew
crew = Crew(agents=[...], context=my_context.to_dict())
# Direct OpenAI
import openai
openai.chat.completions.create(messages=my_context.to_messages())
# Custom API
import requests
requests.post(api_url, json=my_context.to_json())
๐ LangGraph Integration Guide
๐ Documentation & Examples
- ๐ POSITIONING.md - Vision, strategy, competitive analysis
- ๐ LANGGRAPH_INTEGRATION.md - LangGraph integration guide
- ๐ transformation_showcase.ipynb - Interactive demo
- ๐ฆ Templates Documentation - All available templates
- ๐ฏ Examples - Reference implementations
๐บ๏ธ Roadmap
Current (v0.1) โ
- โ Core transformation engine
- โ Universal export formats (messages, JSON, markdown, LangChain)
- โ 5 free templates
- โ RAG with semantic chunking & reranking
- โ Session management
- โ Token optimization
Q1 2026 ๐
- RESTful API
- Cloud platform (mycontext.ai)
- 10 more free templates
- Advanced RAG features
- Deep LangGraph/CrewAI integration
Q2-Q3 2026 ๐
- 50+ premium templates
- Visual context builder
- Team collaboration
- Enterprise features (SSO, teams)
- JavaScript/TypeScript SDK
Q4 2026+ ๐ฏ
- Template marketplace
- Multi-language support
- White-label solutions
- Self-improving contexts (ML)
๐ค Contributing
We love contributions! See CONTRIBUTING.md for guidelines.
Development Setup
# Clone the repo
git clone https://github.com/mycontext-ai/mycontext.git
cd mycontext
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run linting
ruff check .
mypy src/
๐ License
MIT ยฉ 2026 mycontext
๐ Show Your Support
If mycontext helps you build better AI applications:
- โญ Star us on GitHub
- ๐ฌ Join our Discord
- ๐ฆ Follow us on Twitter/X
- ๐ง Subscribe to our Newsletter
Built with โค๏ธ for anyone building with AI.
Transform your questions. Use them anywhere. Build better AI.
Get Started | Discord | GitHub
Project details
Release history Release notifications | RSS feed
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 mycontext_ai-0.1.0.tar.gz.
File metadata
- Download URL: mycontext_ai-0.1.0.tar.gz
- Upload date:
- Size: 83.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
462341f54fad3fc997eaf080767bb9e3ede601bcba2f4abf164e72cd8f9e107d
|
|
| MD5 |
70e3afc99fdc4a83b70815fea7cf24db
|
|
| BLAKE2b-256 |
832e980627370d73716662d11555f6cbbb34985b5365dcfdc7c27b051945159d
|
File details
Details for the file mycontext_ai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mycontext_ai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 100.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c329caaab2459c8aa24cc82dac91049f8ac4953f8bb598e8e15135d8456a67c6
|
|
| MD5 |
a4f6e6f4db4aed247fc94b130945843d
|
|
| BLAKE2b-256 |
1632f7caeeb81152a6bc50eababa71c05495743980d8a4d611fe4ae4f5ce74b7
|