Development & Testing Guide
This document outlines the development discipline, coding standards, and testing strategies for lingo-ai.
๐ฉโ๐ป Coding Standards
- Python Version: Use Python 3.12 or newer.
- Type Safety: All functions and classes must be type-hinted. We use Pydantic for data models.
- Async First: Lingo is built on the asynchronous execution model. Prefer
async/awaitwhenever possible. - Formatting: Use
blackandrufffor code formatting and linting. - Dependency Injection: Use
registry.depends()to manage components like the LLM, the Engine, and the State.
๐งช Testing Strategy
Lingo applications should be tested thoroughly to ensure deterministic behavior and correct integration with the LLM. We recommend using pytest and pytest-asyncio.
Unit Testing Skills & Tools
You can test individual skills and tools by providing mock versions of the Context and Engine.
import pytest
from lingo import Message, Context
from lingo.mock import MockEngine
@pytest.mark.asyncio
async def test_onboarding_skill():
# Setup
ctx = Context()
eng = MockEngine()
eng.add_input("Alice") # Pre-configure the mock engine to respond to an 'ask'
# Execute
await onboarding(ctx, eng)
# Validate
assert "Alice" in ctx.render()
assert any("Welcome" in msg.content for msg in ctx.history)
Integration Testing (The Complete Loop)
For full application tests, you can mock the OpenAI API using the lingo.mock utilities or provide a controlled set of user inputs to the chat() method.
๐ค Contribution Guidelines
We welcome contributions from the community!
- Fork the Repository: Create your own fork and clone it locally.
- Use
uv: Initialize your environment withuv sync. - Create a Branch: Use descriptive branch names (e.g.,
feat/add-new-node-type,fix/issue-123). - Run Tests: Ensure all tests pass before submitting a pull request.
- Submit a PR: Provide a clear description of your changes, including the rationale and any breaking changes.
Git Workflow
We follow the standard GitHub Flow:
- Maintain a clean commit history.
- Use meaningful commit messages (e.g., feat: implement retry node with exponential backoff).
- Link your pull requests to related issues.