API Documentation - Burme-Coder-Max
Overview
burme-coder-max is a Myanmar AI coding agent that provides programming assistance in Burmese language with code examples.
Core Module API
CoderAgent
Main AI agent for generating coding responses.
from core.agent import CoderAgent
agent = CoderAgent(
model: str = "gpt-4", # AI model to use
temperature: float = 0.7, # Response creativity
max_tokens: int = 2048, # Max response length
knowledge_dir: Optional[str] = None # Knowledge base directory
)
Methods
| Method | Description | Returns |
|---|---|---|
generate_response(instruction, context) |
Generate code response | Dict with session_id, response, timestamp |
set_system_prompt(prompt) |
Set custom system prompt | None |
get_trajectory() |
Get conversation for training | Dict |
save_trajectory(path) |
Save trajectory to file | None |
reset() |
Reset agent state | None |
Response Format
{
"session_id": str,
"instruction": str,
"response": str,
"timestamp": float,
"model": str
}
CodeExecutor
Execute code in various languages.
from core.executor import CodeExecutor
executor = CodeExecutor(
timeout: int = 30, # Execution timeout in seconds
sandbox: bool = True # Enable sandbox mode
)
Methods
| Method | Description | Returns |
|---|---|---|
execute(code, language) |
Execute code | ExecutionResult |
validate_syntax(code, language) |
Check syntax | Tuple[bool, Optional[str]] |
ExecutionResult
@dataclass
class ExecutionResult:
success: bool # Execution success
output: str # Execution output
error: Optional[str] # Error message
execution_time: float # Time taken
ResponseValidator
Validate AI generated responses.
from core.validator import ResponseValidator
validator = ResponseValidator()
Methods
| Method | Description | Returns |
|---|---|---|
validate(response, instruction) |
Validate single response | ValidationResult |
validate_multiple(responses, instruction) |
Validate multiple | List[ValidationResult] |
ResponseQuality
class ResponseQuality(Enum):
EXCELLENT = "excellent"
GOOD = "good"
ADEQUATE = "adequate"
POOR = "poor"
INVALID = "invalid"
Knowledge Module API
LocalKB
Local knowledge base for markdown files.
from knowledge import LocalKB
kb = LocalKB(base_dir: Optional[str] = None)
Methods
| Method | Description | Returns |
|---|---|---|
search(query, category) |
Search knowledge | List[Dict] |
get_content(topic) |
Get topic content | Optional[str] |
get_all_topics() |
List all topics | List[str] |
get_random_entry() |
Get random entry | Optional[Dict] |
Search Result Format
{
"source": str, # File name
"line": int, # Line number
"snippet": str, # Match snippet
"relevance": float # Relevance score (0-1)
}
WebUpdater
Update knowledge from web sources.
from knowledge import WebUpdater
updater = WebUpdater(cache_dir: Optional[str] = None)
Methods
| Method | Description | Returns |
|---|---|---|
fetch_content(source) |
Fetch single source | Optional[str] |
fetch_all() |
Fetch all sources | Dict[str, str] |
update_markdown_files(path, force) |
Update files | List[str] |
scrape_url(url, selectors) |
Scrape URL | Optional[str] |
Animations Module API
Spinner
Loading spinner animation.
from animations import Spinner
with Spinner("Loading..."):
do_something()
ProgressBar
Progress bar for iterations.
from animations import ProgressBar
for i in ProgressBar(range(100), description="Downloading"):
process(i)
TypingEffect
Typewriter-style text animation.
from animations import TypingEffect
effect = TypingEffect("Hello World", delay=0.05)
effect.animate()
ParticleBurst
Celebration particle effect.
from animations import ParticleBurst
burst = ParticleBurst(count=50)
burst.explode()
Thanking Module API
ThankYou
Simple thank you display.
from ui.thanking import ThankYou
ThankYou.show() # Random message
ThankYou.show("Custom message") # Custom message
ThankYou.show_with_emoji("⭐") # With emoji
Appreciation
Detailed appreciation display.
from ui.thanking import Appreciation
Appreciation.show(topic="Python") # With topic
Appreciation.show_banner("Developer") # Banner style
Appreciation.show_stacked(["Python", "JS"]) # Multiple topics
CreditDisplay
Credits and attribution.
from ui.thanking import CreditDisplay
CreditDisplay.show() # Full credits
CreditDisplay.show_simple() # Simple credits
CLI Commands API
ask
burme-coder ask "instruction" [OPTIONS]
Options:
--model TEXT AI model (default: gpt-4)
--verbose Verbose output
--output, -o Output file
interactive
burme-coder interactive
Interactive commands:
exit- Quitclear- Clear historyhistory- Show historyhelp- Show help/search <query>- Search knowledge/model <name>- Switch model/reset- Reset agent
train
burme-coder train --data ./data/trajectories [OPTIONS]
Options:
--epochs INT Number of epochs (default: 10)
--batch-size INT Batch size (default: 4)
eval
burme-coder eval --data ./data/trajectories [--verbose]
Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
OPENAI_API_KEY |
OpenAI API key | - |
ANTHROPIC_API_KEY |
Anthropic API key | - |
ANIMATION_SPEED |
Animation delay | 0.05 |
ANIMATION_COLOR |
Enable colors | true |
CACHE_DIR |
Cache directory | ~/.burme_coder/cache |
CACHE_TTL |
Cache TTL (seconds) | 3600 |
LOG_LEVEL |
Logging level | INFO |
.env File
# Copy from example
cp .env.example .env
# Edit with your settings
nano .env
Error Handling
Common Errors
| Error | Cause | Solution |
|---|---|---|
SyntaxError |
Invalid code syntax | Check code syntax |
TimeoutError |
Execution timeout | Increase timeout |
ImportError |
Missing dependencies | Install requirements |
APIError |
API key invalid | Verify API key |
Error Response Format
{
"error": {
"code": str, # Error code
"message": str, # Error message
"details": dict # Additional details
}
}
Examples
Basic Usage
from core.agent import CoderAgent
from core.validator import ResponseValidator
# Initialize
agent = CoderAgent(model="gpt-4")
validator = ResponseValidator()
# Generate response
response = agent.generate_response("Python decorator hta ya")
# Validate
result = validator.validate(response["response"], "decorator")
print(f"Quality: {result.quality.value}")
With Animations
from core.agent import CoderAgent
from animations import Spinner
with Spinner("Generating response..."):
agent = CoderAgent()
response = agent.generate_response("test")
With Knowledge Base
from core.agent import CoderAgent
from knowledge import LocalKB
kb = LocalKB()
results = kb.search("python decorators")
agent = CoderAgent(knowledge_dir="./data/knowledge")
response = agent.generate_response("decorator")