From 1907374a9d026850d21c04da415edbedf3c10936 Mon Sep 17 00:00:00 2001 From: Dewmal Date: Sat, 25 Jan 2025 07:13:41 +0530 Subject: [PATCH] Update doc --- .../examples/network_agent/network_agent.md | 90 ++++++ .../ceylon/examples/task_manager/README.md | 272 +++++++++++++--- docs/examples/single-item-auction.md | 306 +++++++++++------- docs/index.md | 132 +++----- docs/technolgy.md | 102 ++++++ docs/tutorials.md | 114 +++++++ 6 files changed, 746 insertions(+), 270 deletions(-) create mode 100644 bindings/ceylon/examples/network_agent/network_agent.md create mode 100644 docs/technolgy.md create mode 100644 docs/tutorials.md diff --git a/bindings/ceylon/examples/network_agent/network_agent.md b/bindings/ceylon/examples/network_agent/network_agent.md new file mode 100644 index 0000000..a308714 --- /dev/null +++ b/bindings/ceylon/examples/network_agent/network_agent.md @@ -0,0 +1,90 @@ +# Server-Worker Network Setup Guide + +## System Components + +### 1. Server (server.py) + +```python +from ceylon import Admin + +app = Admin(name="admin", port=8888, role="admin") + + +@app.on_run() +async def run_worker(inputs: bytes): + while True: + await app.broadcast_message("Hello World from Server") +``` + +The server broadcasts messages continuously to all connected workers. + +### 2. Worker (worker_agent.py) + +```python +from ceylon import Worker + +worker = Worker(name="worker", port=8888, role="worker") + + +@worker.on(str) +async def on_message(agent_id: str, data: str, time: int): + print(f"Received message from {agent_id}: {data} at {time}") +``` + +The worker listens for and processes messages from the server. + +### 3. Configuration (.ceylon_network) + +``` +WORKSPACE_ID=default +WORKSPACE_IP=127.0.0.1 +WORKSPACE_PEER=12D3KooWMrqMLuYL3vExw7qaBJRzjN43kkkZwqSxUog7oaQCmnFE +WORKSPACE_PORT=8888 +``` + +## Setup Instructions + +1. Start the Server: + ```bash + python server.py + ``` + - Server creates .ceylon_network file with connection details + - WORKSPACE_PEER is auto-generated unique identifier + +2. Start Worker(s): + ```bash + python worker_agent.py + ``` + - Worker reads .ceylon_network file + - Connects to server using WORKSPACE_PEER + +## Remote Connection Setup + +1. Copy .ceylon_network to remote machine +2. Update WORKSPACE_IP if needed +3. Run worker_agent.py on remote machine + +## Network Configuration + +- Default port: 8888 +- Local IP: 127.0.0.1 +- For remote connections: + - Update WORKSPACE_IP to server's IP + - Ensure port 8888 is accessible + +## Common Issues + +1. Connection Failures + - Verify .ceylon_network file exists + - Check WORKSPACE_IP and port accessibility + - Ensure WORKSPACE_PEER matches server + +2. Network Constraints + - Configure firewalls to allow port 8888 + - Use correct IP for non-local connections + +## Security Notes + +- WORKSPACE_PEER acts as unique identifier +- Keep .ceylon_network secure for controlled access +- Update configuration for production environments \ No newline at end of file diff --git a/bindings/ceylon/examples/task_manager/README.md b/bindings/ceylon/examples/task_manager/README.md index 00d291d..5c55ba6 100644 --- a/bindings/ceylon/examples/task_manager/README.md +++ b/bindings/ceylon/examples/task_manager/README.md @@ -1,91 +1,259 @@ # Task Management System Tutorial -A distributed system for automatically assigning tasks to workers based on skill requirements. +## Introduction +This tutorial walks through building a distributed task management system using Ceylon. The system assigns tasks to workers based on skill levels and monitors completion success. -## Use Case +## Prerequisites +- Python 3.7+ +- Ceylon framework +- Basic understanding of async programming -This system simulates a skill-based task assignment scenario where: -- Tasks have different difficulty levels -- Workers have varying skill levels -- Tasks are automatically assigned to available workers -- Task completion success depends on worker skill vs task difficulty +## Part 1: Data Models -## Quick Start +### Task Definition +```python +@dataclass +class Task: + id: int + description: str + difficulty: int +``` + +Tasks have three key attributes: +- `id`: Unique identifier +- `description`: Task details +- `difficulty`: Required skill level (1-10) + +### Message Types +```python +@dataclass +class TaskAssignment: + task: Task + +@dataclass +class TaskResult: + task_id: int + worker: str + success: bool +``` + +These classes handle: +- Task assignments to workers +- Results reporting back to manager + +## Part 2: Worker Implementation + +```python +class WorkerAgent(BaseAgent): + def __init__(self, name: str, skill_level: int, + workspace_id=DEFAULT_WORKSPACE_ID, + admin_peer=""): + self.name = name + self.skill_level = skill_level + self.has_task = False + super().__init__( + name=name, + workspace_id=workspace_id, + admin_peer=admin_peer, + mode=PeerMode.CLIENT + ) +``` + +Key worker features: +1. Skill level determines task success probability +2. Track task assignment status +3. Connect to task manager via admin_peer + +### Task Handling +```python +@on(TaskAssignment) +async def handle_task(self, data: TaskAssignment, time: int, agent: AgentDetail): + if self.has_task: + return + + self.has_task = True + await asyncio.sleep(data.task.difficulty) # Simulate work + success = self.skill_level >= data.task.difficulty + + result = TaskResult( + task_id=data.task.id, + worker=self.name, + success=success + ) + await self.broadcast(pickle.dumps(result)) +``` + +This method: +1. Checks if worker is available +2. Simulates work duration based on difficulty +3. Determines success based on skill level +4. Reports result back to manager + +## Part 3: Task Manager Implementation + +```python +class TaskManager(BaseAgent): + def __init__(self, tasks: List[Task], expected_workers: int, + name="task_manager", port=8000): + super().__init__( + name=name, + port=port, + mode=PeerMode.ADMIN, + role="task_manager" + ) + self.tasks = tasks + self.expected_workers = expected_workers + self.task_results = [] + self.tasks_assigned = False +``` + +Manager responsibilities: +1. Track available tasks +2. Monitor connected workers +3. Collect and process results +### Connection Handling ```python -import asyncio -from task_manager import TaskManager, WorkerAgent, Task +@on_connect("*") +async def handle_connection(self, topic: str, agent: AgentDetail): + connected_count = len(await self.get_connected_agents()) + if connected_count == self.expected_workers and not self.tasks_assigned: + await self.assign_tasks() +``` + +Starts task assignment when all workers connect. + +### Task Assignment +```python +async def assign_tasks(self): + if self.tasks_assigned: + return + + self.tasks_assigned = True + connected_workers = await self.get_connected_agents() + for task, worker in zip(self.tasks, connected_workers): + await self.broadcast(pickle.dumps(TaskAssignment(task=task))) +``` + +Distribution logic: +1. Checks if tasks already assigned +2. Gets connected worker list +3. Pairs tasks with workers +4. Broadcasts assignments + +### Result Processing +```python +@on(TaskResult) +async def handle_result(self, data: TaskResult, time: int, agent: AgentDetail): + self.task_results.append(data) + if len(self.task_results) == len(self.tasks): + print("All tasks completed") + for result in self.task_results: + print(f"Task {result.task_id} assigned to {result.worker} - " + f"{'Success' if result.success else 'Failure'}") + await self.end_task_management() +``` + +Tracks completion and calculates success rate. + +## Part 4: System Setup +```python async def main(): - # Create tasks with varying difficulty + # Define tasks tasks = [ Task(id=1, description="Simple calculation", difficulty=2), Task(id=2, description="Data analysis", difficulty=5), Task(id=3, description="ML model training", difficulty=8), ] - # Initialize task manager + # Create manager task_manager = TaskManager(tasks, expected_workers=3) admin_details = task_manager.details() - # Create workers with different skill levels + # Create workers with varying skills workers = [ WorkerAgent("Junior", skill_level=3, admin_peer=admin_details.id), WorkerAgent("Intermediate", skill_level=6, admin_peer=admin_details.id), WorkerAgent("Senior", skill_level=9, admin_peer=admin_details.id), ] - # Start the system + # Start system await task_manager.start_agent(b"", workers) - -asyncio.run(main()) ``` -## System Flow - -1. **Task Manager Initialization** - ```python - task_manager = TaskManager(tasks, expected_workers=3) - ``` - -2. **Worker Registration** - ```python - WorkerAgent("Junior", skill_level=3, admin_peer=admin_details.id) - ``` +## Running the System -3. **Task Assignment** - ```python - @on_connect("*") - async def handle_connection(self, topic: str, agent: AgentDetail): - if connected_count == self.expected_workers: - await self.assign_tasks() - ``` +1. Create task list with varying difficulties +2. Initialize task manager +3. Create workers with appropriate skill levels +4. Launch system with manager and workers -4. **Task Execution** - ```python - @on(TaskAssignment) - async def handle_task(self, data: TaskAssignment, time: int, agent: AgentDetail): - success = self.skill_level >= data.task.difficulty - ``` +## Example Output +``` +All tasks completed +Task 1 assigned to Junior - Success +Task 2 assigned to Intermediate - Success +Task 3 assigned to Senior - Success +Success rate: 100.00% +``` -## Customization +## Customization Options -Add task priorities: +### Priority-based Tasks ```python @dataclass -class Task: - id: int - description: str - difficulty: int - priority: int = 1 +class PriorityTask(Task): + priority: int + + def get_processing_time(self): + return self.difficulty * (1/self.priority) ``` -Implement worker specialization: +### Specialized Workers ```python -class WorkerAgent(BaseAgent): - def __init__(self, name: str, skill_level: int, specialties: List[str]): +class SpecializedWorker(WorkerAgent): + def __init__(self, name, skill_level, specialties): + super().__init__(name, skill_level) self.specialties = specialties + + async def handle_task(self, data: TaskAssignment): + specialty_bonus = 2 if data.task.type in self.specialties else 0 + success = (self.skill_level + specialty_bonus) >= data.task.difficulty + # Rest of implementation... ``` -## License -Apache License, Version 2.0 \ No newline at end of file +## Best Practices + +1. Task Design + - Set appropriate difficulty levels + - Balance task distribution + - Consider task dependencies + +2. Worker Configuration + - Match skill levels to task range + - Provide adequate worker count + - Consider specializations + +3. Error Handling + - Handle worker disconnections + - Implement task timeouts + - Plan for task failures + +## Troubleshooting + +Common issues and solutions: +1. Workers not connecting + - Check admin_peer ID + - Verify network configuration + - Ensure port availability + +2. Task assignment failures + - Verify task format + - Check worker availability + - Monitor connection status + +3. Performance issues + - Adjust task difficulty + - Balance worker load + - Monitor system resources \ No newline at end of file diff --git a/docs/examples/single-item-auction.md b/docs/examples/single-item-auction.md index efbafa7..8c6f60d 100644 --- a/docs/examples/single-item-auction.md +++ b/docs/examples/single-item-auction.md @@ -1,165 +1,221 @@ -## Single Item Auction +# Meeting Scheduler Code Explanation -## Introduction +## 1. Data Models -This guide demonstrates how to build a real-time single-item auction system using the Ceylon framework. The system enables multiple bidders to compete for an item while an auctioneer manages the bidding process using Ceylon's agent-based architecture. - -## System Overview - -The auction system consists of two main components: - -1. **Auctioneer (Admin Agent)**: Controls the auction flow by: - - Managing bidder connections - - Broadcasting auction start - - Collecting and processing bids - - Determining and announcing the winner - -2. **Bidders (Worker Agents)**: Participate in the auction by: - - Connecting to the auction system - - Placing bids within their budget - - Receiving auction results - -## Prerequisites - -- Python 3.7 or higher -- Ceylon framework (`pip install ceylon`) -- Basic understanding of: - - Asynchronous programming in Python - - Agent-based architectures - - The Ceylon framework - -## Implementation Details - -### Data Models - -The system uses dataclasses for message passing between agents: +### TimeSlot +```python +@dataclass +class TimeSlot: + date: str + start_time: int + end_time: int + + @property + def duration(self): + return self.end_time - self.start_time +``` +- Uses Python's dataclass for automatic initialization +- Stores date as string and times as integers +- Calculates duration dynamically as property +### Meeting ```python @dataclass -class Item: +class Meeting: name: str - starting_price: float + date: str + duration: int + minimum_participants: int +``` +- Defines meeting requirements +- Specifies minimum number of required participants +- Sets meeting duration in hours -@dataclass -class Bid: - bidder: str - amount: float +### Message Classes +```python +@d[.ceylon_network](../../bindings/ceylon/examples/network_agent/.ceylon_network)ataclass +class AvailabilityRequest: + time_slot: TimeSlot @dataclass -class AuctionStart: - item: Item +class AvailabilityResponse: + owner: str + time_slot: TimeSlot + accepted: bool +``` +- `AvailabilityRequest`: Sent to check participant availability +- `AvailabilityResponse`: Participant's response indicating acceptance -@dataclass -class AuctionResult: - winner: str - winning_bid: float +## 2. Participant Agent -@dataclass -class AuctionEnd: - pass +```python +class Participant(Worker): + def __init__(self, name: str, available_times: list[TimeSlot]): + super().__init__(name=name, role="participant") + self.available_times = available_times + + @staticmethod + def is_overlap(slot1: TimeSlot, slot2: TimeSlot, duration: int) -> bool: + latest_start = max(slot1.start_time, slot2.start_time) + earliest_end = min(slot1.end_time, slot2.end_time) + return earliest_end - latest_start >= duration + + @on(AvailabilityRequest) + async def handle_availability_request(self, data: AvailabilityRequest, + time: int, agent: AgentDetail): + is_available = any(self.is_overlap(slot, data.time_slot, + data.time_slot.duration) + for slot in self.available_times) + await self.broadcast_message(AvailabilityResponse( + owner=self.details().name, + time_slot=data.time_slot, + accepted=is_available + )) ``` -### Auctioneer Implementation +Key aspects: +1. Inherits from Ceylon's Worker class +2. Maintains list of available time slots +3. `is_overlap()` checks if two time slots overlap with sufficient duration +4. Uses `@on` decorator to handle availability requests +5. Broadcasts response to all agents -The Auctioneer extends Ceylon's `Admin` class and manages the auction lifecycle: +## 3. Coordinator Agent ```python -class Auctioneer(Admin): - def __init__(self, item: Item, expected_bidders: int, name="auctioneer", port=8888): +class Coordinator(Admin): + def __init__(self, name: str, port: int): super().__init__(name=name, port=port) - self.item = item - self.expected_bidders = expected_bidders - self.bids = [] - self.auction_ended = False + self.meeting_request = None + self.agreed_slots = {} + self.next_time_slot = None + +admin = Coordinator(name="admin", port=8888) + +@admin.on_run() +async def handle_run(inputs: Meeting): + admin.meeting_request = inputs + print("Meeting Schedule request:", admin.meeting_request) + +@admin.on_connect("*") +async def handle_connection(topic: str, agent: AgentDetail): + start_time = 8 + admin.next_time_slot = TimeSlot( + admin.meeting_request.date, + start_time, + start_time + admin.meeting_request.duration + ) + await admin.broadcast_message(AvailabilityRequest( + time_slot=admin.next_time_slot)) ``` -Key features: -- Tracks connected bidders -- Broadcasts auction start when all bidders connect -- Processes incoming bids -- Determines and announces the winner -- Manages auction completion - -### Bidder Implementation - -Bidders extend Ceylon's `Worker` class and handle auction participation: +Key functionality: +1. Inherits from Ceylon's Admin class +2. Maintains state of scheduling process +3. Initializes with starting time slot when agents connect +4. Tracks agreed time slots and next time slot to try +### Response Handler ```python -class Bidder(Worker): - def __init__(self, name: str, budget: float, workspace_id=DEFAULT_WORKSPACE_ID, - admin_peer="", admin_port=8888): - super().__init__(name=name, workspace_id=workspace_id, - admin_peer=admin_peer, admin_port=admin_port) - self.budget = budget - self.has_bid = False +@admin.on(AvailabilityResponse) +async def handle_availability_response(data: AvailabilityResponse, + time: int, agent: AgentDetail): + if not data.accepted: + current_slot = data.time_slot + next_slot = TimeSlot( + admin.meeting_request.date, + current_slot.start_time + 1, + current_slot.start_time + 1 + admin.meeting_request.duration + ) + if next_slot.end_time > admin.next_time_slot.end_time: + admin.next_time_slot = next_slot + await admin.broadcast_message( + AvailabilityRequest(time_slot=admin.next_time_slot)) + return + + time_slot_key = str(data.time_slot) + slots = admin.agreed_slots.get(time_slot_key, []) + if data.owner not in slots: + slots.append(data.owner) + admin.agreed_slots[time_slot_key] = slots + if len(slots) >= admin.meeting_request.minimum_participants: + print(f"Meeting scheduled with {slots} participants at {data.time_slot}") + await admin.stop() ``` -Key features: -- Maintains bidder budget -- Implements bidding strategy -- Processes auction messages -- Handles win/loss results +Response handling logic: +1. For rejections: + - Creates next time slot + - Broadcasts new availability request if needed +2. For acceptances: + - Tracks accepting participant + - Checks if minimum participants reached + - Stops process when meeting can be scheduled -## Running the System - -To start the auction system: +## 4. Main Function ```python async def main(): - # Create auction item - item = Item("Rare Painting", 1000.0) - - # Initialize auctioneer - auctioneer = Auctioneer(item, expected_bidders=3) - admin_details = auctioneer.details() - - # Create bidders - bidders = [ - Bidder("Alice", 1500.0, admin_peer=admin_details.id), - Bidder("Bob", 1200.0, admin_peer=admin_details.id), - Bidder("Charlie", 2000.0, admin_peer=admin_details.id) + participants = [ + Participant("Alice", [ + TimeSlot("2024-07-21", 9, 12), + TimeSlot("2024-07-21", 14, 18) + ]), + Participant("Bob", [ + TimeSlot("2024-07-21", 10, 13), + TimeSlot("2024-07-21", 15, 17) + ]), + Participant("Charlie", [ + TimeSlot("2024-07-21", 11, 14), + TimeSlot("2024-07-21", 16, 18) + ]), ] - # Run the auction - await auctioneer.arun_admin(b"", bidders) - -if __name__ == "__main__": - asyncio.run(main()) + meeting = Meeting( + name="Meeting 1", + duration=1, + date="2024-07-21", + minimum_participants=3 + ) + + await admin.start_agent( + inputs=pickle.dumps(meeting), + workers=participants + ) ``` -## System Features +Main function flow: +1. Creates participant agents with availability windows +2. Defines meeting requirements +3. Starts scheduling process by launching admin agent +4. Uses pickle for serializing meeting data -- **Real-time Bidding**: Immediate bid processing and updates -- **Automatic Winner Selection**: Highest bid wins automatically -- **Budget Management**: Bidders cannot exceed their budget -- **Graceful Completion**: Clean shutdown after auction ends -- **Error Handling**: Robust message processing with error logging +## Key Design Patterns -## Advanced Features +1. **Observer Pattern** + - Uses Ceylon's `@on` decorators for event handling + - Agents respond to specific message types -The current implementation includes: -- Random bidding strategy with multipliers -- Budget constraints -- Automatic auction completion -- Logging with loguru +2. **Asynchronous Programming** + - Built on Python's asyncio + - Non-blocking message handling -## Future Enhancements +3. **State Management** + - Coordinator maintains scheduling state + - Participants track own availability -Consider these potential improvements: -1. Multiple round support -2. Time-based auction endings -3. Different auction types (Dutch, Silent, etc.) -4. Reserve prices and minimum bid increments -5. Proxy bidding support -6. Real-time bid updates to all participants -7. Transaction history and audit logs -8. Automated testing suite +4. **Message-Passing Architecture** + - Communication via serialized messages + - Broadcast and direct messaging support -## Contributing +## Error Handling -Feel free to submit issues and enhancement requests. Contributions are welcome! +1. Time slot validation through overlap checking +2. Graceful handling of rejection responses +3. State tracking prevents duplicate acceptances ---- +## Performance Considerations -Copyright 2024-Present, Syigen Ltd. and Syigen Private Limited. All rights reserved. -Licensed under the Apache License, Version 2.0 (See LICENSE or http://www.apache.org/licenses/LICENSE-2.0). \ No newline at end of file +1. Uses efficient time slot comparison algorithm +2. Minimizes message passing through broadcast patterns +3. Asynchronous operations prevent blocking \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 47e4f2f..7bcdb40 100644 --- a/docs/index.md +++ b/docs/index.md @@ -5,115 +5,61 @@ [//]: # (![PyPI - Version](https://img.shields.io/pypi/v/ceylon.svg) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ceylon.svg) ![PyPI Downloads](https://img.shields.io/pypi/dm/ceylon)) -## Introduction - -Welcome to Ceylon: A Multi-Agent System (MAS) designed to orchestrate complex task flows among multiple AI agents. -Ceylon manages and automates interactions between agents, each with specific roles and responsibilities, enabling -powerful collaborative AI solutions. By empowering collaboration and simplifying complexity, Ceylon opens up new -possibilities in AI-driven task automation and problem-solving. +Ceylon is a distributed Multi-Agent System (MAS) built on modern P2P architecture, designed to orchestrate complex task flows among multiple AI agents. It leverages libp2p for robust peer-to-peer communication and Rust for performance-critical components. ![Ceylon Architecture](https://github.com/ceylonai/ceylon/blob/master/contents/images/img.png?raw=True) ## 🚀 Key Features -- **Agent Management**: Easily define and manage agents with specific roles and tools. -- **Task Automation**: Automate task flow based on agent input and predefined sequences. -- **Scalability**: Handle multiple agents and complex workflows with ease. -- **Customization**: Highly adaptable to fit diverse use cases. -- **Distributed Architecture**: Developed as a robust distributed system. -- **Efficient Message Propagation**: Utilizes a powerful framework for reliable inter-agent communication. -- **Interoperability and Performance**: Ensures seamless operation across different programming languages while - providing memory safety and high performance. -- **Chief Agent Leadership**: Centralized task management and execution flow. -- **Parallel or Sequential Execution**: Adapt to your task's needs. -- **Customizable I/O**: Define inputs and outputs tailored to your requirements. -- **Versatile Deployment**: Run as a server or standalone application. +- **Agent Management**: Easily define and manage agents with specific roles and tools +- **Task Automation**: Automate task flow based on agent input and predefined sequences +- **Scalability**: Handle multiple agents and complex workflows with ease +- **Customization**: Highly adaptable to fit diverse use cases +- **Distributed Architecture**: Developed as a robust distributed system +- **Efficient Message Propagation**: Utilizes a powerful framework for reliable inter-agent communication +- **Interoperability and Performance**: Ensures seamless operation across different programming languages while providing memory safety and high performance +- **Chief Agent Leadership**: Centralized task management and execution flow +- **Parallel or Sequential Execution**: Adapt to your task's needs +- **Customizable I/O**: Define inputs and outputs tailored to your requirements +- **Versatile Deployment**: Run as a server or standalone application ## 🌟 Why Ceylon? -Ceylon pushes the boundaries of what's possible in task automation and AI collaboration. It's not just another -framework; it's a new paradigm for solving complex problems. - -- **Achieve the Impossible**: Tackle tasks that traditional single-agent or monolithic systems can't handle. -- **Flexible Architecture**: Easily adapt to various use cases, from customer support to market analysis. -- **Scalable Performance**: Distribute workload across multiple agents for improved efficiency. -- **Rich Interaction**: Agents share information, creating a truly collaborative AI ecosystem. - -## 🛠️ Use Cases - -- Automated customer support systems -- Intelligent meeting schedulers -- Real-time stock market analysis -- AI-driven content creation pipelines -- Complex data processing and decision-making systems - -## 📚 Tutorials and Examples - -Ceylon provides a range of tutorials and examples to help you get started and make the most of the framework: - -### Tutorials - -- [Collaborative AI Workflow: Using Ceylon Framework for Streamlined Article Creation](https://medium.com/ceylonai/collaborative-ai-workflow-using-ceylon-framework-for-streamlined-article-creation-81bbd7ee7c01) -- [A Meeting Scheduler with Ceylon - Multi Agent System](https://medium.com/ceylonai/a-meeting-scheduler-with-ceylon-multi-agent-system-a7aa5a906f36) - -### Example Projects - -- **Meeting Scheduler - **: [Colab Script](https://colab.research.google.com/drive/1C-E9BN992k5sZYeJWnVrsWA5_ryaaT8m?usp=sharing) - [Read more](bindings/ceylon/examples/time_scheduling) - - **Single Item Auction - **: [Colab Script](https://colab.research.google.com/drive/12o76s4CyGvOpUaACDYIaYmJgJE1hC81Y#scrollTo=_4dqqO616ifQ) - [Read more](bindings/ceylon/examples/auction) +Ceylon pushes the boundaries of what's possible in task automation and AI collaboration. It's not just another framework; it's a new paradigm for solving complex problems. -### More Examples +- **Achieve the Impossible**: Tackle tasks that traditional single-agent or monolithic systems can't handle +- **Flexible Architecture**: Easily adapt to various use cases, from customer support to market analysis +- **Scalable Performance**: Distribute workload across multiple agents for improved efficiency +- **Rich Interaction**: Agents share information, creating a truly collaborative AI ecosystem -- **Task Manager**: [Read more](bindings/ceylon/examples/task_manager) -- **Auction System**: [Read more](bindings/ceylon/examples/auction) -- **Time Scheduling**: [Read more](bindings/ceylon/examples/time_scheduling) +## Technology Stack -## 🚦 Getting Started +### Core Infrastructure +- **Communication Layer**: libp2p Rust implementation +- **Runtime Environment**: Async-capable Python with Rust bindings +- **Message Protocol**: Binary-serialized protocol buffers +- **State Management**: Distributed state with eventual consistency -To get started with Ceylon, refer to our detailed [Getting Started Guide](./docs/advance_agents). This guide walks you -through setting up a basic multi-agent system with easy-to-follow steps. +### Performance Features +- Zero-copy message passing +- Lock-free concurrency +- Optimized async I/O +- Minimal memory footprint -## 🚧 Roadmap +## System Requirements +- Python 3.8+ +- Rust toolchain (for building from source) +- 2GB RAM minimum +- Network connectivity for P2P communication -- [X] Agent Stack -- [X] Python SDK First Version Release -- [ ] Java/Kotlin SDK First Version Release -- [ ] NodeJS SDK First Version Release -- [ ] JS/TS SDK First Version Release -- [ ] LLM Agents -- [ ] Web Agent -- [ ] Task Manager -- [ ] Agent Registry +## Contact & License -## 🤝 Contributing +- Support: [support@ceylon.ai](mailto:support@ceylon.ai) +- License: Apache-2.0 ([LICENSE](LICENSE)) -We welcome contributions! Please read our [contributing guidelines](CONTRIBUTING.md) before submitting a pull request. +## Architecture Note -## 📄 License - -Ceylon is released under the Apache-2.0 license. See the [LICENSE](LICENSE) file for details. - -## 📞 Contact - -For questions or support, please contact us at [support@ceylon.ai](mailto:support@ceylon.ai). - -## NOTE - -**This project implements a peer-to-peer (P2P) networking solution designed for software agent communication, entirely -independent of any blockchain technology. Our system utilizes libp2p Rust implementation for enabling cross-network -communication between software agents, following distributed networking principles similar to BitTorrent. While libp2p -is also used in some blockchain projects, our implementation does not incorporate, rely on, or interact with any -blockchain or cryptocurrency technologies. Each agent in our network functions as an autonomous software component, -processing data and communicating through our P2P implementation powered by libp2p.** +Ceylon implements a pure P2P networking solution using libp2p Rust implementation. While using similar distributed networking principles as BitTorrent, it operates independently of any blockchain technology. The system provides autonomous agent communication through a high-performance P2P network layer. --- - -Built with ☕ by the Ceylon Team. Star us on GitHub if you find this interesting! - ---- - -Copyright 2024-Present, Syigen Ltd. and Syigen Private Limited. All rights reserved. -Licensed under the Apache License, Version 2.0 (See LICENSE or http://www.apache.org/licenses/LICENSE-2.0). \ No newline at end of file +Copyright 2024-Present, Syigen Ltd. and Syigen Private Limited. All rights reserved. \ No newline at end of file diff --git a/docs/technolgy.md b/docs/technolgy.md new file mode 100644 index 0000000..c5b1153 --- /dev/null +++ b/docs/technolgy.md @@ -0,0 +1,102 @@ +# Technical Details + +## Core Architecture + +### Network Layer +- **libp2p Implementation** + - Multi-transport: TCP, WebSocket, QUIC + - Built-in NAT traversal + - TLS and noise encryption protocols + - Yamux multiplexing + - DNS resolution support + +- **P2P Architecture** + - Gossipsub protocol for pub/sub + - Rendezvous protocol for peer discovery + - Identity management with Ed25519 keys + - Mesh network topology optimization + - Configurable heartbeat intervals + +### Node Types +- **Admin Node** + - Rendezvous server capabilities + - Centralized peer registration + - Topic management + - Connection monitoring + +- **Client Node** + - Auto-discovery of admin nodes + - Dynamic topic subscription + - Connection state management + - Automatic reconnection + +### Message System +- **Message Types** + - Direct peer-to-peer + - Topic-based broadcast + - System events + - Binary payload support + +- **Performance Features** + - 512MB maximum message size + - Configurable buffer sizes (1MB default) + - Message deduplication + - Flow control with backpressure + - Zero-copy optimization + +### Peer Behavior +- **Core Features** + - Role-based access control + - Event-driven architecture + - Customizable peer modes + - Connection pooling + +- **Network Behavior** + - Ping/Pong health checks + - Peer identification + - Connection metrics + - State synchronization + +## Implementation Details + +### Protocol Stack +- **Transport Layer** + - QUIC for low latency + - WebSocket for web compatibility + - TCP for fallback support + +- **Security Layer** + - TLS 1.3 encryption + - Noise protocol framework + - Ed25519 signatures + - Peer authentication + +### Operational Features +- **Connection Management** + - 60-second idle timeout + - Automatic peer discovery + - Dynamic address resolution + - Multi-address support + +- **State Management** + - Distributed topic registry + - Peer connection tracking + - Message history management + - Event logging + +## Development Status + +### Production Ready +- Core P2P networking +- Message routing +- Python SDK +- Basic monitoring + +### In Development +- Additional language SDKs +- Web interface +- Enhanced security features +- Scalability improvements + +--- +Copyright 2024-Present, Syigen Ltd. and Syigen Private Limited. All rights reserved. \ No newline at end of file diff --git a/docs/tutorials.md b/docs/tutorials.md new file mode 100644 index 0000000..984761e --- /dev/null +++ b/docs/tutorials.md @@ -0,0 +1,114 @@ +# Ceylon Implementation Guide + +## Quick Start Examples + +### Meeting Scheduler + +```python +from ceylon import Admin, Worker +from ceylon.base.support import on, on_run, on_connect + + +class Scheduler(Admin): + def __init__(self, meeting): + super().__init__(name="scheduler", port=8000) + self.meeting = meeting + + @on_connect("*") + async def handle_connection(self, topic: str, agent: AgentDetail): + await self.broadcast_message(AvailabilityRequest()) + + +async def main(): + scheduler = Scheduler(meeting) + await scheduler.start_agent(b"", workers) +``` + +[Full Code](examples/meeting-sechdular.md) | [Interactive Demo](https://colab.research.google.com/drive/1C-E9BN992k5sZYeJWnVrsWA5_ryaaT8m) + +### Auction System + +```python +class Auctioneer(Admin): + async def handle_bid(self, bid: Bid): + if bid.amount > self.highest_bid: + self.highest_bid = bid.amount + await self.broadcast_message(CurrentPrice(bid.amount)) +``` + +[Full Code](examples/auction) | [Interactive Demo](https://colab.research.google.com/drive/12o76s4CyGvOpUaACDYIaYmJgJE1hC81Y) + +## Implementation Patterns + +### Admin-Worker Pattern + +```python +# Admin node setup +admin = Admin(name="admin", port=8888) +admin_details = admin.details() + +# Worker node setup +worker = Worker(name="worker", + admin_peer=admin_details.id, + role="worker") + +await admin.start_agent(b"", [worker]) +``` + +### Message Handling + +```python +@on(MessageType) +async def handle_message(self, message: bytes): + # Process message + response = process(message) + await self.broadcast_message(response) +``` + +### Event Processing + +```python +@on_connect("*") +async def handle_connect(self, topic: str, agent: AgentDetail): + # Handle new connection + await self.send_message(agent.id, welcome_message) +``` + +## Advanced Topics + +### Custom Agent Behaviors + +- Role-based permissions +- State management +- Error handling +- Resource cleanup + +### Scaling Considerations + +- Buffer sizing +- Connection pooling +- Load balancing +- Error recovery + +### Security Best Practices + +- TLS encryption +- Authentication +- Access control +- Audit logging + +## Additional Resources + +### Tutorials + +- [Article Creation Workflow](https://medium.com/ceylonai/collaborative-ai-workflow-using-ceylon-framework-for-streamlined-article-creation-81bbd7ee7c01) +- [Meeting Scheduler Guide](https://medium.com/ceylonai/a-meeting-scheduler-with-ceylon-multi-agent-system-a7aa5a906f36) + +### Example Projects + +- [Task Manager](examples/task_manager) +- [Time Scheduler](examples/time_scheduling) +- [Auction System](examples/auction) + +--- +Copyright 2024-Present, Syigen Ltd. and Syigen Private Limited. \ No newline at end of file