# 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. ```python 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 ```python { "session_id": str, "instruction": str, "response": str, "timestamp": float, "model": str } ``` --- ### CodeExecutor Execute code in various languages. ```python 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 ```python @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. ```python 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 ```python class ResponseQuality(Enum): EXCELLENT = "excellent" GOOD = "good" ADEQUATE = "adequate" POOR = "poor" INVALID = "invalid" ``` --- ## Knowledge Module API ### LocalKB Local knowledge base for markdown files. ```python 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 ```python { "source": str, # File name "line": int, # Line number "snippet": str, # Match snippet "relevance": float # Relevance score (0-1) } ``` --- ### WebUpdater Update knowledge from web sources. ```python 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. ```python from animations import Spinner with Spinner("Loading..."): do_something() ``` ### ProgressBar Progress bar for iterations. ```code from animations import ProgressBar for i in ProgressBar(range(100), description="Downloading"): process(i) ``` ### TypingEffect Typewriter-style text animation. ```python from animations import TypingEffect effect = TypingEffect("Hello World", delay=0.05) effect.animate() ``` ### ParticleBurst Celebration particle effect. ```python from animations import ParticleBurst burst = ParticleBurst(count=50) burst.explode() ``` --- ## Thanking Module API ### ThankYou Simple thank you display. ```python 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. ```python 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. ```python from ui.thanking import CreditDisplay CreditDisplay.show() # Full credits CreditDisplay.show_simple() # Simple credits ``` --- ## CLI Commands API ### ask ```bash burme-coder ask "instruction" [OPTIONS] Options: --model TEXT AI model (default: gpt-4) --verbose Verbose output --output, -o Output file ``` ### interactive ```bash burme-coder interactive ``` Interactive commands: - `exit` - Quit - `clear` - Clear history - `history` - Show history - `help` - Show help - `/search ` - Search knowledge - `/model ` - Switch model - `/reset` - Reset agent ### train ```bash burme-coder train --data ./data/trajectories [OPTIONS] Options: --epochs INT Number of epochs (default: 10) --batch-size INT Batch size (default: 4) ``` ### eval ```bash 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 ```bash # 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 ```python { "error": { "code": str, # Error code "message": str, # Error message "details": dict # Additional details } } ``` --- ## Examples ### Basic Usage ```python 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 ```python from core.agent import CoderAgent from animations import Spinner with Spinner("Generating response..."): agent = CoderAgent() response = agent.generate_response("test") ``` ### With Knowledge Base ```python 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") ```