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__
venv
.DS_Store
Cargo.lock
.DS_STORE
Cargo.lock
swarms/agents/.DS_Store

@ -1,14 +1,15 @@
[package]
name = "engine"
version = "0.1.0"
edition = "2018"
[lib]
name = "engine"
path = "runtime/concurrent_exec.rs"
crate-type = ["cdylib"]
name = "swarms-runtime" # The name of your project
version = "0.1.0" # The current version, adhering to semantic versioning
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
license = "MIT" # Optional: the license for your project
description = "A brief description of my project" # Optional: a short description of your project
[dependencies]
pyo3 = { version = "0.15", features = ["extension-module"] }
rayon = "1.5.1"
log = "0.4.14"
cpython = "0.5"
rayon = "1.5"
[dependencies.pyo3]
version = "0.20.3"
features = ["extension-module", "auto-initialize"]

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

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

@ -1,12 +1,11 @@
[build-system]
requires = ["poetry-core>=1.0.0", "maturin"]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "swarms"
version = "4.1.9"
version = "4.2.0"
description = "Swarms - Pytorch"
license = "MIT"
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