Skip to content

Commit

Permalink
[PACKAGES CLEANUP]
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Nov 27, 2024
1 parent 74b74bd commit fda8d21
Show file tree
Hide file tree
Showing 9 changed files with 573 additions and 34 deletions.
7 changes: 2 additions & 5 deletions docs/swarms/install/workspace_manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ Create a `.env` file in your project's root directory to configure the Swarms fr
- **Purpose**: Defines the directory where all agent states and execution logs are stored
- **Type**: String (path)
- **Default**: `./workspace`
- **Example**:
```bash
WORKSPACE_DIR=/path/to/your/workspace
```
- **Example**: ```bashWORKSPACE_DIR=/path/to/your/workspace```
- **Usage**:
- Stores JSON files containing agent states
- Maintains execution history
Expand Down Expand Up @@ -183,4 +180,4 @@ Common issues and solutions:

- [Swarms Framework Documentation](https://github.com/kyegomez/swarms)
- [Swarms Analytics Dashboard](https://swarms.ai)
- [API Reference](https://swarms.ai/docs/api)
- [API Reference](https://swarms.ai/docs/api)
8 changes: 6 additions & 2 deletions example_async_vs_multithread.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import asyncio
import threading
from swarms import Agent
from swarm_models import OpenAIChat
import time
Expand Down Expand Up @@ -40,18 +39,21 @@
streaming_on=False,
)


# Function to measure time and memory usage
def measure_time_and_memory(func):
def wrapper(*args, **kwargs):
start_time = time.time()
result = func(*args, **kwargs)
end_time = time.time()
memory_usage = psutil.Process().memory_info().rss / 1024 ** 2
memory_usage = psutil.Process().memory_info().rss / 1024**2
print(f"Time taken: {end_time - start_time} seconds")
print(f"Memory used: {memory_usage} MB")
return result

return wrapper


# Function to run the agent asynchronously
@measure_time_and_memory
async def run_agent_async():
Expand All @@ -61,11 +63,13 @@ async def run_agent_async():
)
)


# Function to run the agent on another thread
@measure_time_and_memory
def run_agent_thread():
asyncio.run(run_agent_async())


# Run the agent asynchronously and on another thread to test the speed
asyncio.run(run_agent_async())
run_agent_thread()
Loading

0 comments on commit fda8d21

Please sign in to comment.