Skip to content

Commit

Permalink
Update readme files
Browse files Browse the repository at this point in the history
  • Loading branch information
dewmal committed Jan 17, 2025
1 parent bbe4356 commit 4c9af11
Show file tree
Hide file tree
Showing 8 changed files with 667 additions and 390 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ Ceylon provides a range of tutorials and examples to help you get started and ma

### Example Projects

- **News Writing Panel**: [Colab Script](https://colab.research.google.com/drive/1ZMy0Iggni6fCQynBlyI1wL4WW4U_Fman?usp=sharing)
- **Meeting Scheduler**: [Colab Script](https://colab.research.google.com/drive/1C-E9BN992k5sZYeJWnVrsWA5_ryaaT8m?usp=sharing)
[Read more](https://github.com/ceylonai/ceylon/blob/master/docs/examples/meeting-sechdular.md)
- **Single Item Auction**: [Colab Script](https://colab.research.google.com/drive/1C-E9BN992k5sZYeJWnVrsWA5_ryaaT8m?usp=sharing)
[Read more](https://github.com/ceylonai/ceylon/blob/master/docs/examples/single-item-auction.md)
- **Task Manager**: [Read more](https://github.com/ceylonai/ceylon/blob/master/docs/examples/task-manager.md)

### More Examples
- **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)
- **Connect Through Network**: [Read more](.https://github.com/ceylonai/ceylon/blob/master/docs/examples/connect-through-network.md)

## 🚦 Getting Started
Expand All @@ -66,9 +69,10 @@ To get started with Ceylon, refer to our detailed [Getting Started Guide](./docs

## 🚧 Roadmap

- [X] LLM Agent Stack
- [X] Job Handling (parallel & sequential)
- [X] Agent Stack
- [X] Python Client Release
- [ ] Web Agent
- [ ] Task Manager
- [ ] Agent Registry

## 🤝 Contributing
Expand Down
74 changes: 44 additions & 30 deletions bindings/ceylon/examples/auction/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,45 @@ The system consists of two main types of agents:
- `Bid`: Represents a bid made by a bidder, including the bidder's name and bid amount.
- `AuctionStart`: Signals the start of the auction with the item details.
- `AuctionResult`: Represents the result of the auction, including the winner and winning bid amount.
- `AuctionEnd`: Signals the end of the auction.
- `AuctionEnd`: Signals the end of the auction, allowing bidders to acknowledge the auction completion.

### Agents

1. **Bidder (Worker)**
- Manages individual budgets and places bids.
- Uses a random bidding strategy to determine bid amounts.
- Methods:
- `on_message`: Handles incoming auction messages and places bids.
- Manages individual budgets and places bids.
- Uses a random bidding strategy with multiplier between 1.0 and 10.0 times the starting price.
- Only bids if budget is higher than the starting price.
- Methods:
- `on_message`: Handles incoming auction messages (AuctionStart, AuctionResult, AuctionEnd) and places bids.
- `run`: Maintains the bidder's event loop.

2. **Auctioneer (Admin)**
- Manages the overall auction process.
- Methods:
- `on_agent_connected`: Tracks connected bidders and starts the auction when all are connected.
- `start_auction`: Initiates the auction by broadcasting the item details.
- `on_message`: Processes incoming bids and ends the auction after each bid.
- `end_auction`: Determines the winner and broadcasts the result.
- Manages the overall auction process.
- Methods:
- `on_agent_connected`: Tracks connected bidders and starts the auction when all are connected.
- `start_auction`: Initiates the auction by broadcasting the item details.
- `on_message`: Processes incoming bids.
- `end_auction`: Determines the winner and broadcasts the result when all bids are received.
- `run`: Maintains the auctioneer's event loop.

## How It Works

1. The Auctioneer waits for all Bidders to connect.
2. Once all Bidders are connected, the Auctioneer starts the auction by broadcasting the item details.
3. Bidders receive the auction start message and place their bids using a random strategy.
4. The Auctioneer receives each bid and immediately ends the auction after processing it.
5. The Auctioneer determines the winner (highest bidder) and broadcasts the result.
6. Bidders receive the result and update their status (won/lost).
1. The Auctioneer is initialized with an item and expected number of bidders.
2. Bidders are created with individual budgets and connected to the Auctioneer.
3. The Auctioneer waits for all Bidders to connect.
4. Once all Bidders are connected, the Auctioneer starts the auction by broadcasting the item details.
5. Bidders receive the auction start message and place their bids using a random multiplier strategy.
6. The Auctioneer collects all bids and ends the auction after receiving bids from all bidders.
7. The Auctioneer determines the winner (highest bidder) and broadcasts the result.
8. Bidders receive the result, update their budgets if they won, and acknowledge the auction end.

## Running the Code

To run the single-item auction simulation:

1. Ensure you have the required dependencies installed:
```
pip install asyncio pydantic ceylon
pip install asyncio loguru ceylon
```

2. Save the code in a file (e.g., `single_item_auction.py`).
Expand All @@ -61,28 +66,37 @@ To run the single-item auction simulation:
python single_item_auction.py
```

4. The script will simulate the auction process and output the results, including connections, bids, and the final
auction result.
## Default Configuration

The default setup includes:

- A "Rare Painting" item with starting price of $1,000
- Three bidders:
- Alice (Budget: $1,500)
- Bob (Budget: $1,200)
- Charlie (Budget: $2,000)
- Random bidding strategy with multipliers between 1.0x and 10.0x the starting price

## Customization

You can customize the simulation by modifying the `main` function:

- Adjust the item's name and starting price.
- Change the number of Bidders and their budgets.
- Modify the bidding strategy in the `Bidder` class for more complex behavior.
- Adjust the item's name and starting price in the Item initialization
- Change the number of bidders and their budgets
- Modify the bidding strategy in the `Bidder.on_message` method
- Adjust the random multiplier range for more conservative or aggressive bidding

## Note

This example uses the Ceylon framework for agent communication. Ensure you have the Ceylon library properly installed
and configured in your environment.
This implementation uses the Ceylon framework for agent communication and the Loguru library for logging. Make sure you have these libraries properly installed in your environment.

## Limitations and Potential Improvements

- The current implementation ends the auction after the first bid, which may not be realistic for most auction
scenarios.
- There's no mechanism for multiple bidding rounds or time-based auction closure.
- The random bidding strategy might result in unrealistic bid amounts.
- Error handling and edge cases (e.g., no bids received) could be improved.
- The auction ends after receiving bids from all bidders, with no support for multiple bidding rounds
- The random bidding strategy is relatively simple and could be enhanced with more sophisticated algorithms
- There's no timeout mechanism for bidders who fail to submit a bid
- Error handling could be improved for edge cases like network failures or disconnected bidders
- The system could be extended to support multiple items or concurrent auctions
- Bidder authentication and bid verification could be added for security

These limitations provide opportunities for extending and improving the system for more realistic auction simulations.
133 changes: 133 additions & 0 deletions bindings/ceylon/examples/task_manager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Distributed Task Management System

This project implements a distributed task management system using the Ceylon framework. It simulates a workforce of
agents with different skill levels performing tasks of varying difficulty.

## Overview

The system consists of two main types of agents:

1. **Workers**: Agents with different skill levels who can perform tasks
2. **Task Manager**: Central coordinator that distributes tasks and monitors completion

The system demonstrates skill-based task execution where success depends on the worker's skill level matching or
exceeding the task's difficulty.

## Components

### Data Classes

- `Task`: Represents a task to be performed
- id: Unique identifier
- description: Task description
- difficulty: Integer value from 1-10 indicating task complexity

- `TaskAssignment`: Message containing a task to be assigned
- task: The Task to be performed

- `TaskResult`: Message containing the outcome of a task
- task_id: ID of the completed task
- worker: Name of the worker who performed the task
- success: Boolean indicating task completion success

### Agents

1. **WorkerAgent (Worker)**
- Represents an individual worker with specific skills
- Properties:
- name: Worker's identifier
- skill_level: Integer (1-10) representing worker's capabilities
- has_task: Boolean tracking if worker is currently assigned a task
- Methods:
- `on_message`: Handles task assignments and simulates task execution
- `run`: Maintains the worker's event loop

2. **TaskManager (Admin)**
- Coordinates task distribution and monitors completion
- Properties:
- tasks: List of tasks to be assigned
- expected_workers: Number of workers expected to connect
- task_results: Collection of completed task results
- tasks_assigned: Boolean tracking if tasks have been distributed
- Methods:
- `on_agent_connected`: Triggers task distribution when all workers connect
- `assign_tasks`: Distributes tasks to connected workers
- `on_message`: Processes task completion results
- `end_task_management`: Summarizes task completion statistics

## How It Works

1. The TaskManager initializes with a list of tasks and expected number of workers
2. Workers connect to the system, each with their own skill level
3. Once all workers are connected, the TaskManager distributes tasks
4. Workers receive tasks and attempt to complete them based on their skill level
- Success occurs if worker's skill_level >= task difficulty
- Task execution time is simulated based on task difficulty
5. Workers report task completion results back to the TaskManager
6. The TaskManager collects all results and generates a completion report

## Running the Code

1. Install required dependencies:
```
pip install asyncio loguru ceylon
```

2. Run the script:
```
python task_manager.py
```

## Default Configuration

The example includes:

- Three tasks of increasing difficulty:
1. Simple calculation (difficulty: 2)
2. Data analysis (difficulty: 5)
3. Machine learning model training (difficulty: 8)
- Three workers with different skill levels:
1. Junior (skill level: 3)
2. Intermediate (skill level: 6)
3. Senior (skill level: 9)

## Output

The system provides detailed logging of:

- Worker initialization and connections
- Task assignments
- Task completions with success/failure status
- Final success rate and detailed results using checkmarks (✓) and crosses (✗)

## Customization

You can customize the simulation by modifying the `main` function:

- Add or remove tasks with different difficulties
- Change the number of workers and their skill levels
- Modify task descriptions and complexities
- Adjust the task execution simulation time

## Note

This implementation uses:

- Ceylon framework for agent communication
- Loguru for enhanced logging
- Pickle for message serialization
- Asyncio for asynchronous execution

## Limitations and Potential Improvements

- Fixed one-to-one task assignment (each worker gets exactly one task)
- No task prioritization or queuing system
- No support for task dependencies or workflows
- Limited to synchronous task completion (no parallel task execution)
- No task reassignment on failure
- No worker load balancing
- No persistent storage of task results
- No error recovery mechanism for failed tasks
- No consideration of worker specializations beyond skill level

These limitations provide opportunities for extending the system for more complex task management scenarios.
Loading

0 comments on commit 4c9af11

Please sign in to comment.