Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ OPENAI_API_KEY=
## Gemini (if used, required) ##
GEMINI_API_KEY=

## Open Router (if used, required) ##
OPENROUTER_API_KEY=

## Ollama (if used, optional) ##
# do not change this, it is used by Docker
OLLAMA_HOST=http://host.docker.internal
Expand All @@ -40,3 +43,4 @@ OLLAMA_AUTO_PULL=true
## Additional Services (optional)
SERPER_API_KEY=
JINA_API_KEY=

68 changes: 68 additions & 0 deletions .github/workflows/build_side_container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Create Side Image
on:
push:
branches: ["side"]
paths:
# Source files in each member
- "compute/src/**"
- "p2p/src/**"
- "workflows/src/**"
# Cargo in each member
- "compute/Cargo.toml"
- "p2p/Cargo.toml"
- "workflows/Cargo.toml"
# root-level changes
- "Cargo.lock"
- "Cross.toml"
- "Dockerfile"
- "compose.yml"
# workflow itself
- ".github/workflows/build_side_container.yml"

jobs:
build-and-push:
name: Build and Push
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Get Unix Time
id: timestamp
run: echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT

- name: Get SHA
id: sha
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Get Branch Name
id: branch
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT

- name: Set Image Tag
id: itag
run: echo "itag=${{ steps.branch.outputs.branch }}-${{ steps.sha.outputs.sha }}-${{ steps.timestamp.outputs.timestamp }}" >> $GITHUB_OUTPUT

- name: Build and push
uses: docker/build-push-action@v6
env:
IMAGE_TAG: ${{ steps.itag.outputs.itag }}
with:
platforms: linux/amd64, linux/arm64, linux/arm, linux/arm64v8
push: true
tags: |
firstbatch/dkn-compute-node:unstable
firstbatch/dkn-compute-node:${{ env.IMAGE_TAG }}
116 changes: 116 additions & 0 deletions .github/workflows/build_side_exe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Build and Publish Compute Side Releases

on:
release:
types: [published]

permissions:
contents: write

jobs:
check_release:
if: "contains(github.event.release.tag_name, '-side')" # continue if the tag ends with -side
runs-on: ubuntu-latest
steps:
- name: Echo tag
run: |
echo "tag name: ${{ github.event.release.tag_name }}"
echo "release name: ${{ github.event.release.name }}"

build:
needs: check_release
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- {
runner: macos-latest,
osname: macOS,
arch: amd64,
target: x86_64-apple-darwin,
command: build,
}
- {
runner: macos-latest,
osname: macOS,
arch: arm64,
target: aarch64-apple-darwin,
command: build,
}
- {
runner: ubuntu-latest,
osname: linux,
arch: amd64,
target: x86_64-unknown-linux-gnu,
command: build,
}
- {
runner: ubuntu-latest,
osname: linux,
arch: arm64,
target: aarch64-unknown-linux-gnu,
command: build,
build_args: --no-default-features,
}
- {
runner: windows-latest,
osname: windows,
arch: amd64,
target: x86_64-pc-windows-msvc,
command: build,
extension: ".exe",
}
# - { runner: windows-latest, osname: windows, arch: arm64, target: aarch64-pc-windows-msvc, command: build, extension: ".exe", toolchain: nightly }

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Get the release version from the tag
shell: bash
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Build binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: ${{ matrix.command }}
target: ${{ matrix.target }}
args: "--locked --release ${{ matrix.build_args }}"
strip: true

- name: Prepare Release File
run: |
# move the binary
mv target/${{ matrix.target }}/release/dkn-compute${{ matrix.extension }} ./dkn-compute-binary-${{ matrix.osname }}-${{ matrix.arch }}${{ matrix.extension }}

- name: Upload Launch Artifacts
uses: actions/upload-artifact@v4
with:
name: dkn-compute-binary-${{ matrix.osname }}-${{ matrix.arch }}
path: dkn-compute-binary-${{ matrix.osname }}-${{ matrix.arch }}${{ matrix.extension }}

release:
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all tags and history

- name: Download Launch Artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: ./artifacts

- name: Create release with artifacts
uses: ncipollo/release-action@v1
with:
name: ${{ github.event.release.name }}
tag: ${{ github.event.release.tag_name }}
artifacts: "artifacts/*"
artifactContentType: application/octet-stream
allowUpdates: true
# draft: true
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ endif
###############################################################################
.PHONY: launch # | Run with INFO logs in release mode
launch:
RUST_LOG=none,dkn_compute=info,dkn_workflows=info,dkn_p2p=info cargo run --release
RUST_LOG=none,dkn_compute=info,dkn_workflows=info,dkn_p2p=info,libp2p_gossipsub=info cargo run --release

.PHONY: run # | Run with INFO logs
run:
RUST_LOG=none,dkn_compute=info,dkn_workflows=info,dkn_p2p=info cargo run
RUST_LOG=none,dkn_compute=info,dkn_workflows=info,dkn_p2p=info,libp2p=info cargo run

.PHONY: debug # | Run with DEBUG logs with INFO log-level workflows
debug:
RUST_LOG=warn,dkn_compute=debug,dkn_workflows=debug,dkn_p2p=debug,ollama_workflows=info cargo run
RUST_LOG=warn,dkn_compute=debug,dkn_workflows=debug,dkn_p2p=debug,ollama_workflows=info,libp2p_gossipsub=info cargo run

.PHONY: trace # | Run with TRACE logs
trace:
Expand Down
2 changes: 1 addition & 1 deletion compute/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
};

/// Number of seconds between refreshing the Admin RPC PeerIDs from Dria server.
const RPC_PEER_ID_REFRESH_INTERVAL_SECS: u64 = 30;
const RPC_PEER_ID_REFRESH_INTERVAL_SECS: u64 = 5;

/// **Dria Compute Node**
///
Expand Down
22 changes: 11 additions & 11 deletions compute/src/utils/available_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ use eyre::Result;
use std::{env, fmt::Debug, str::FromStr};

/// Static bootstrap nodes for the Kademlia DHT bootstrap step.
const STATIC_BOOTSTRAP_NODES: [&str; 4] = [
"/ip4/44.206.245.139/tcp/4001/p2p/16Uiu2HAm4q3LZU2T9kgjKK4ysy6KZYKLq8KiXQyae4RHdF7uqSt4",
"/ip4/18.234.39.91/tcp/4001/p2p/16Uiu2HAmJqegPzwuGKWzmb5m3RdSUJ7NhEGWB5jNCd3ca9zdQ9dU",
"/ip4/54.242.44.217/tcp/4001/p2p/16Uiu2HAmR2sAoh9F8jT9AZup9y79Mi6NEFVUbwRvahqtWamfabkz",
"/ip4/52.201.242.227/tcp/4001/p2p/16Uiu2HAmFEUCy1s1gjyHfc8jey4Wd9i5bSDnyFDbWTnbrF2J3KFb",
const STATIC_BOOTSTRAP_NODES: [&str; 0] = [
// "/ip4/44.206.245.139/tcp/4001/p2p/16Uiu2HAm4q3LZU2T9kgjKK4ysy6KZYKLq8KiXQyae4RHdF7uqSt4",
// "/ip4/18.234.39.91/tcp/4001/p2p/16Uiu2HAmJqegPzwuGKWzmb5m3RdSUJ7NhEGWB5jNCd3ca9zdQ9dU",
// "/ip4/54.242.44.217/tcp/4001/p2p/16Uiu2HAmR2sAoh9F8jT9AZup9y79Mi6NEFVUbwRvahqtWamfabkz",
// "/ip4/52.201.242.227/tcp/4001/p2p/16Uiu2HAmFEUCy1s1gjyHfc8jey4Wd9i5bSDnyFDbWTnbrF2J3KFb",
];

/// Static relay nodes for the `P2pCircuit`.
const STATIC_RELAY_NODES: [&str; 4] = [
"/ip4/34.201.33.141/tcp/4001/p2p/16Uiu2HAkuXiV2CQkC9eJgU6cMnJ9SMARa85FZ6miTkvn5fuHNufa",
"/ip4/18.232.93.227/tcp/4001/p2p/16Uiu2HAmHeGKhWkXTweHJTA97qwP81ww1W2ntGaebeZ25ikDhd4z",
"/ip4/54.157.219.194/tcp/4001/p2p/16Uiu2HAm7A5QVSy5FwrXAJdNNsdfNAcaYahEavyjnFouaEi22dcq",
"/ip4/54.88.171.104/tcp/4001/p2p/16Uiu2HAm5WP1J6bZC3aHxd7XCUumMt9txAystmbZSaMS2omHepXa",
const STATIC_RELAY_NODES: [&str; 0] = [
// "/ip4/34.201.33.141/tcp/4001/p2p/16Uiu2HAkuXiV2CQkC9eJgU6cMnJ9SMARa85FZ6miTkvn5fuHNufa",
// "/ip4/18.232.93.227/tcp/4001/p2p/16Uiu2HAmHeGKhWkXTweHJTA97qwP81ww1W2ntGaebeZ25ikDhd4z",
// "/ip4/54.157.219.194/tcp/4001/p2p/16Uiu2HAm7A5QVSy5FwrXAJdNNsdfNAcaYahEavyjnFouaEi22dcq",
// "/ip4/54.88.171.104/tcp/4001/p2p/16Uiu2HAm5WP1J6bZC3aHxd7XCUumMt9txAystmbZSaMS2omHepXa",
];

/// Static RPC Peer IDs for the Admin RPC.
const STATIC_RPC_PEER_IDS: [&str; 0] = [];

/// API URL for refreshing the Admin RPC PeerIDs from Dria server.
const RPC_PEER_ID_REFRESH_API_URL: &str = "https://dkn.dria.co/available-nodes";
const RPC_PEER_ID_REFRESH_API_URL: &str = "https://dkn.dria.co/sdk/available-nodes";

/// Available nodes within the hybrid P2P network.
///
Expand Down
7 changes: 6 additions & 1 deletion compute/src/utils/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::utils::{
use crate::DRIA_COMPUTE_NODE_VERSION;
use base64::{prelude::BASE64_STANDARD, Engine};
use core::fmt;
use dkn_p2p::P2P_IDENTITY_PREFIX;
use ecies::PublicKey;
use eyre::{Context, Result};
use libsecp256k1::{verify, Message, SecretKey, Signature};
Expand All @@ -19,7 +20,10 @@ pub struct DKNMessage {
///
/// NOTE: This can be obtained via TopicHash in GossipSub
pub(crate) topic: String,
/// The version of the Dria Compute Node
/// Identity protocol string of the Dria Compute Node
#[serde(default)]
pub(crate) identity: String,
/// The full crate version of the Dria Compute Node
///
/// NOTE: This can be obtained via Identify protocol version
pub(crate) version: String,
Expand All @@ -46,6 +50,7 @@ impl DKNMessage {
payload: BASE64_STANDARD.encode(data),
topic: topic.to_string(),
version: DRIA_COMPUTE_NODE_VERSION.to_string(),
identity: P2P_IDENTITY_PREFIX.trim_end_matches('/').to_string(),
timestamp: get_current_time_nanos(),
}
}
Expand Down
4 changes: 2 additions & 2 deletions p2p/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ mod client;
pub use client::DriaP2PClient;

/// Prefix for Kademlia protocol, must start with `/`!
pub(crate) const P2P_KADEMLIA_PREFIX: &str = "/dria/kad/";
pub const P2P_KADEMLIA_PREFIX: &str = "/dria-sdk/kad/";

/// Prefix for Identity protocol string.
pub(crate) const P2P_IDENTITY_PREFIX: &str = "dria/";
pub const P2P_IDENTITY_PREFIX: &str = "dria-sdk/";

// re-exports
pub use libp2p;
Expand Down
16 changes: 15 additions & 1 deletion workflows/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
apis::{JinaConfig, SerperConfig},
providers::{GeminiConfig, OllamaConfig, OpenAIConfig},
providers::{GeminiConfig, OllamaConfig, OpenAIConfig, OpenRouterConfig},
split_csv_line, Model, ModelProvider,
};
use eyre::{eyre, Result};
Expand All @@ -19,6 +19,7 @@ pub struct DriaWorkflowsConfig {
/// Gemini configurations, e.g. API key, in case Gemini is used.
/// Otherwise, can be ignored.
pub gemini: GeminiConfig,
pub openrouter: OpenRouterConfig,
/// Serper configurations, e.g. API key, in case Serper is given in environment.
/// Otherwise, can be ignored.
pub serper: SerperConfig,
Expand All @@ -40,6 +41,7 @@ impl DriaWorkflowsConfig {
ollama: OllamaConfig::new(),
openai: OpenAIConfig::new(),
gemini: GeminiConfig::new(),
openrouter: OpenRouterConfig::new(),
serper: SerperConfig::new(),
jina: JinaConfig::new(),
}
Expand Down Expand Up @@ -230,6 +232,18 @@ impl DriaWorkflowsConfig {
);
}

// if OpenRouter is a provider, check that the API key is set
if unique_providers.contains(&ModelProvider::OpenRouter) {
let provider_models = self.get_models_for_provider(ModelProvider::OpenRouter);
good_models.extend(
self.openrouter
.check(provider_models)
.await?
.into_iter()
.map(|m| (ModelProvider::OpenRouter, m)),
);
}

// update good models
if good_models.is_empty() {
Err(eyre!("No good models found, please check logs for errors."))
Expand Down
3 changes: 3 additions & 0 deletions workflows/src/providers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ pub use openai::OpenAIConfig;

mod gemini;
pub use gemini::GeminiConfig;

mod openrouter;
pub use openrouter::OpenRouterConfig;
Loading