pull/393/head
Kye 11 months ago
parent 2c9bad43fb
commit 342e4d7b41

2
.gitignore vendored

@ -15,7 +15,7 @@ Unit Testing Agent_state.json
swarms/__pycache__ swarms/__pycache__
venv venv
.DS_Store .DS_Store
Cargo.lock
.DS_STORE .DS_STORE
Cargo.lock Cargo.lock
swarms/agents/.DS_Store swarms/agents/.DS_Store

@ -1,14 +1,15 @@
[package] [package]
name = "engine" name = "swarms-runtime" # The name of your project
version = "0.1.0" version = "0.1.0" # The current version, adhering to semantic versioning
edition = "2018" edition = "2021" # Specifies which edition of Rust you're using, e.g., 2018 or 2021
authors = ["Your Name <your.email@example.com>"] # Optional: specify the package authors
[lib] license = "MIT" # Optional: the license for your project
name = "engine" description = "A brief description of my project" # Optional: a short description of your project
path = "runtime/concurrent_exec.rs"
crate-type = ["cdylib"]
[dependencies] [dependencies]
pyo3 = { version = "0.15", features = ["extension-module"] } cpython = "0.5"
rayon = "1.5.1" rayon = "1.5"
log = "0.4.14"
[dependencies.pyo3]
version = "0.20.3"
features = ["extension-module", "auto-initialize"]

@ -5,6 +5,7 @@ from swarms import Agent, ConcurrentWorkflow, Task
# model # model
model = MultiOnAgent(multion_api_key="api-key") model = MultiOnAgent(multion_api_key="api-key")
# out = model.run("search for a recipe") # out = model.run("search for a recipe")
agent = Agent( agent = Agent(
agent_name="MultiOnAgent", agent_name="MultiOnAgent",

@ -14,7 +14,6 @@ docs = loader.load()
qdrant_client = qdrant.Qdrant( qdrant_client = qdrant.Qdrant(
host="https://697ea26c-2881-4e17-8af4-817fcb5862e8.europe-west3-0.gcp.cloud.qdrant.io", host="https://697ea26c-2881-4e17-8af4-817fcb5862e8.europe-west3-0.gcp.cloud.qdrant.io",
collection_name="qdrant", collection_name="qdrant",
api_key="BhG2_yINqNU-aKovSEBadn69Zszhbo5uaqdJ6G_qDkdySjAljvuPqQ",
) )
qdrant_client.add_vectors(docs) qdrant_client.add_vectors(docs)

@ -1,12 +1,11 @@
[build-system] [build-system]
requires = ["poetry-core>=1.0.0", "maturin"] requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api" build-backend = "poetry.core.masonry.api"
[tool.poetry] [tool.poetry]
name = "swarms" name = "swarms"
version = "4.1.9" version = "4.2.0"
description = "Swarms - Pytorch" description = "Swarms - Pytorch"
license = "MIT" license = "MIT"
authors = ["Kye Gomez <kye@apac.ai>"] authors = ["Kye Gomez <kye@apac.ai>"]

@ -0,0 +1,59 @@
use pyo3::prelude::*;
use pyo3::types::PyList;
use rayon::prelude::*;
use std::fs;
use std::time::Instant;
// Define the new execute function
fn execute(script_path: &str, threads: usize) -> PyResult<()> {
(0..threads).into_par_iter().for_each(|_| {
Python::with_gil(|py| {
let sys = py.import("sys").unwrap();
let path: &PyList = match sys.getattr("path") {
Ok(path) => match path.downcast() {
Ok(path) => path,
Err(e) => {
eprintln!("Failed to downcast path: {:?}", e);
return;
}
},
Err(e) => {
eprintln!("Failed to get path attribute: {:?}", e);
return;
}
};
if let Err(e) = path.append("lib/python3.11/site-packages") {
eprintln!("Failed to append path: {:?}", e);
}
let script = fs::read_to_string(script_path).unwrap();
py.run(&script, None, None).unwrap();
});
});
Ok(())
}
fn main() -> PyResult<()> {
let args: Vec<String> = std::env::args().collect();
let threads = 20;
if args.len() < 2 {
eprintln!("Usage: {} <path_to_python_script>", args[0]);
std::process::exit(1);
}
let script_path = &args[1];
let start = Instant::now();
// Call the execute function
execute(script_path, threads)?;
let duration = start.elapsed();
match fs::write("/tmp/elapsed.time", format!("booting time: {:?}", duration)) {
Ok(_) => println!("Successfully wrote elapsed time to /tmp/elapsed.time"),
Err(e) => eprintln!("Failed to write elapsed time: {:?}", e),
}
Ok(())
}
Loading…
Cancel
Save