Important
Make sure to clone the repository with the --recursive
option.
This demo app consists of a TikTok reply bot split into four services:
dstack
: Running on the host machine. The rest of services run on Docker.wetware
: Our Wetware platform running on the TDX emulator. The service will be running Wetware processes: WASM guest processes that can only reach outside their Sandbox through Object Capabilities.app
:guest
: The TikTok bot running on Wetware with a TikTok object capability. The app is written in Go and compiled to WASM.host
: A simple Go program that connects to a Wetware node, bootstraps the TikTok object capability, and starts the bot process (guest
) on that node with that capability.
tiktok
: A service receiving TikTok notifications, sending them with some context to a bot, and posting the bot's replies. The service is using TikApi, because the suggested alternative does not provide the notification or tagging functionality described in the document. It's a simple program that wraps TikAPI calls in Object Capability methods and exposes them through a TCP port.ollama
: Ollama server running in a container. The start script downloads phi3:mini by default.llm
: A service exposing the LLM capabilities of Ollama through Cap'n Proto.
We need to set up the simulator to get working. The guide works
with the Python example, but it returns 404
errors for the Go SDK calls.
Perhaps I'm doing something wrong.
Following the simulation instructions from the Go SDK does work.
Make sure you don't have this in your ~/.gitconfig
when running the ./build.sh
step, as it is a common setting to have when working with private Go repos.
[url "git@github.com:"]
insteadOf = https://github.com/
The process is:
git clone [email protected]:Phala-Network/dstack.git
cd dstack/sdk/simulator
# Save this path to and environment variable
echo "export DSTACK_SIMULATOR_DIR=\"$PWD\"" >> ~/.zshrc
echo "export DSTACK_SOCKET=\"\$DSTACK_SIMULATOR_DIR/dstack.sock\"" >> ~/.zshrc
echo "export TAPPD_SOCKET=\"\$DSTACK_SIMULATOR_DIR/tappd.sock\"" >> ~/.zshrc
./build.sh # requires Cargo
./dstack-simulator
Besides the DSTACK_SOCKET
and TAPPD_SOCKET
environment variables, you can use the ones in the .env
to configure the project.
Make sure to source
the .env
file included in this repository, and modify it to have values for the API_KEY
and ACCOUNT_KEY
variables
if not mocking TikTok responses. Here's the sample .env
file:
API_KEY=<tikapi api key>
ACCOUNT_KEY=<tikapi account key>
TIKTOK_MOCK=True
TIKTOK_HOST=0.0.0.0
TIKTOK_PORT=6060
After setting up Dstack, just run:
make build
This will:
- Compile Dstack (in case you hadn't already)
- Build an image with the TikTok object capability server
- Build the Wetware docker image
- Build the bot app, both
host
andguest
programs.
Note: the
make build
command builds the image withdocker
instead ofphala docker
because it let's us set the image author towetware
without logging into docker with the account.
Then run:
make run
This will:
- Start the Dstack simulator
- [container] Start the TikTok object capability server
- [container] Start a Wetware node
- Start the bot app:
- [container] Run the
host
program to bootstrap the TikTok capability, connect to the Wetware node, load the WASM bytecode and start the bot program in the Wetware node. - [wetware] Run the
guest
program in a loop: fetch a mention, grab some context, generate a response, and reply to the mention.
- [container] Run the