Deploying Phymes
Deployment on Web, Desktop, and Mobile
The phymes-core
, phymes-agents
, phymes-server
, phymes-app
crates form a full-stack application that can run Agentic AI workflows, Graph algorithms, or Simulate networks at scale using a web, desktop, or mobile interface. Both the frontend and server need to be built in --release
mode for improved performance and security.
Web
First, build the frontend application using dioxus
dx bundle -p phymes-app --platform web --release
Second, build the server with the desired features.
# GPU support and Candle token service
cargo build --package phymes-server --features wsl,gpu,candle --release
# Or OpenAI API
cargo build --package phymes-server --no-default-features --features wsl,openai_api --release
Third, move the server executable to the same directory as the web assets
mv target/release/phymes-server target/dx/phymes-app/release/web/public/
Fourth, run the application and navigate to http://127.0.0.1:4000/
cd target/dx/phymes-app/release/web/public
./phymes-server
Desktop
First, build the frontend application
cargo build -p phymes-app --features desktop --release
Second, build the phymes-server application with the desired features.
# GPU support and Candle token service
cargo build --package phymes-server --features wsl,gpu,candle --release
# Or OpenAI API
cargo build --package phymes-server --no-default-features --features wsl,openai_api --release
Third, launch the phymes-app
executable
./target/release/phymes-app
Fourth, launch the phymes-server
executable
./target/release/phymes-server
Mobile (Android)
First, build the frontend application
# for Android
dx build -p phymes-app --platform android --release
# for iOS
dx build -p phymes-app --platform ios --release
Second, build the phymes-server application with the desired features. Note that Dioxus
# GPU support and Candle token service
cargo build --package phymes-server --features wsl,gpu,candle --release
# Or OpenAI API
cargo build --package phymes-server --no-default-features --features wsl,openai_api --release
Third, launch the phymes-app
executable on a device emulator or on the physical device.
Fourth, launch the phymes-server
executable
./target/release/phymes-server
WASM
First, build the phymes-server application with Candle token services.
cargo build --package phymes-server --no-default-features --features wasip2,candle --target wasm32-wasip2 --release
Second, iteratively query the phymes-server using wasmtime
.
# Sign-in and get our JWT token
wastime --dir=$HOME/.cache phymes-server.wasm --route app/v1/sign_in --basic_auth EMAIL:PASSWORD
# mock response {"email":"EMAIL","jwt":"JWTTOKEN","session_plans":["Chat","DocChat","ToolChat"]}
# Get information about the different subjects
wastime --dir=$HOME/.cache phymes-server.wasm curl --route app/v1/subjects_info --bearer_auth JWTTOKEN --data '{"session_name":"EMAILChat","subject_name":"","format":"Bytes","publish":"None","content":"","metadata":"","stream":false}'
# Chat request
# Be sure to replace EMAIL and JWTTOKEN with your actual email and JWT token!
# Note that the session_name = email + session_plan
wastime --dir=$HOME/.cache phymes-server.wasm curl --route app/v1/chat --bearer_auth JWTTOKEN --data '{"content":"Write a python function to count prime numbers","session_name":"EMAILChat","subject_name":"messages","format":"Bytes","publish":"None","metadata":"","stream":true}'
no_std
All PHYMES crates can be compiled for the wasm32-unknown-unknown target with no_std
for integration with embedded and serverless applications
Deploying with local or remote OpenAI API compatible token service endpoints
OpenAI API compatible token service endpoints are supported for local (e.g., NVIDIA NIMs) or remote (e.g., OpenAI or NVIDIA NIMs). Please see the guide for local NVIDIA NIMs token service deployment.
Before running the phymes-server
, setup the environmental variables as needed to access the local or remote token service endpoint as described in the guide, or specify the endpoint urls in the CandleEmbedConfig
and CandleChatConfig
, respectively.
Debugging the PHYMES deployment
We recommend debugging the application using two terminals: one for phymes-app
and another for phymes-server
. Dioxus provides a great development loop for front-end application development with nifty hot-reloading features, but requires it's own dedicated terminal to run. Tokio provides an industry grade server along with nifty security features. During development (specifically, debug mode), the server permissions are relaxed to enable iterative debugging of the application. The phymes-core
, phymes-ml
, phymes-data
, phymes-agents
, and phymes-server
all use the Tracing crates for tracing and logging functionality. The packages and verbosity of console logging can be specified on the command line using the RUST_LOG
environmental variable.
In the first terminal:
dx serve -p phymes-app --platform web
In the second terminal:
# default log level
cargo run -p phymes-server --features wsl,gpu,candle
# only INFO level logs
RUST_LOG=phymes_server=INFO cargo run -p phymes-server --features wsl,gpu,candle
# DEBUG and INFO level logs for phymes-server, phymes-core, and phymes-ml with BACKTRACE level 1
RUST_BACKTRACE=1 RUST_LOG=phymes_server=DEBUG,INFO,ERROR,phymes_data=DEBUG,INFO,ERROR,phymes_core=DEBUG,INFO,ERROR,phymes_ml=DEBUG,INFO,ERROR cargo run -p phymes-server --features wsl,gpu,candle,hf_hub