Skip to content

Commit d94a9b7

Browse files
authored
Merge branch 'master' into caglacelik/tps-reporter
2 parents 29e2d84 + d6ff15d commit d94a9b7

File tree

10 files changed

+224
-62
lines changed

10 files changed

+224
-62
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ OPENAI_API_KEY=
2828
## Gemini (if used, required) ##
2929
GEMINI_API_KEY=
3030

31+
## Open Router (if used, required) ##
32+
OPENROUTER_API_KEY=
33+
3134
## Ollama (if used, optional) ##
3235
# do not change this, it is used by Docker
3336
OLLAMA_HOST=http://host.docker.internal

Cargo.lock

Lines changed: 43 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ default-members = ["compute"]
77

88
[workspace.package]
99
edition = "2021"
10-
version = "0.2.21"
10+
version = "0.2.22"
1111
license = "Apache-2.0"
1212
readme = "README.md"
1313

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=$BUILDPLATFORM rust:1.75 as builder
1+
FROM --platform=$BUILDPLATFORM rust:1.75 AS builder
22

33
# https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
44
#

compute/src/utils/message.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ pub struct DKNMessage {
2323
///
2424
/// NOTE: This can be obtained via Identify protocol version
2525
pub(crate) version: String,
26+
/// Identity protocol string of the Dria Compute Node
27+
#[serde(default)]
28+
pub(crate) identity: String,
2629
/// The timestamp of the message, in nanoseconds
2730
///
2831
/// NOTE: This can be obtained via DataTransform in GossipSub
@@ -46,6 +49,9 @@ impl DKNMessage {
4649
payload: BASE64_STANDARD.encode(data),
4750
topic: topic.to_string(),
4851
version: DRIA_COMPUTE_NODE_VERSION.to_string(),
52+
identity: dkn_p2p::P2P_IDENTITY_PREFIX
53+
.trim_end_matches('/')
54+
.to_string(),
4955
timestamp: get_current_time_nanos(),
5056
}
5157
}

p2p/src/client.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ impl DriaP2PClient {
254254
log::warn!("Local node is listening on {}", address);
255255
}
256256
SwarmEvent::ExternalAddrConfirmed { address } => {
257+
// this is usually the external address via relay
257258
log::info!("External address confirmed: {}", address);
258259
}
259260
event => log::trace!("Unhandled Swarm Event: {:?}", event),
@@ -275,6 +276,13 @@ impl DriaP2PClient {
275276
info.protocol_version,
276277
self.identity_protocol
277278
);
279+
280+
// blacklist peers with different protocol
281+
self.swarm
282+
.behaviour_mut()
283+
.gossipsub
284+
.blacklist_peer(&peer_id);
285+
278286
return;
279287
}
280288

p2p/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ mod client;
77
pub use client::DriaP2PClient;
88

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

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

1515
// re-exports
1616
pub use libp2p;

workflows/src/config.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
22
apis::{JinaConfig, SerperConfig},
3-
providers::{GeminiConfig, OllamaConfig, OpenAIConfig},
3+
providers::{GeminiConfig, OllamaConfig, OpenAIConfig, OpenRouterConfig},
44
split_csv_line, Model, ModelProvider,
55
};
66
use eyre::{eyre, Result};
@@ -19,6 +19,9 @@ pub struct DriaWorkflowsConfig {
1919
/// Gemini configurations, e.g. API key, in case Gemini is used.
2020
/// Otherwise, can be ignored.
2121
pub gemini: GeminiConfig,
22+
/// OpenRouter configurations, e.g. API key, in case OpenRouter is used.
23+
/// Otherwise, can be ignored.
24+
pub openrouter: OpenRouterConfig,
2225
/// Serper configurations, e.g. API key, in case Serper is given in environment.
2326
/// Otherwise, can be ignored.
2427
pub serper: SerperConfig,
@@ -39,6 +42,7 @@ impl DriaWorkflowsConfig {
3942
models: models_and_providers,
4043
ollama: OllamaConfig::new(),
4144
openai: OpenAIConfig::new(),
45+
openrouter: OpenRouterConfig::new(),
4246
gemini: GeminiConfig::new(),
4347
serper: SerperConfig::new(),
4448
jina: JinaConfig::new(),
@@ -230,6 +234,18 @@ impl DriaWorkflowsConfig {
230234
);
231235
}
232236

237+
// if OpenRouter is a provider, check that the API key is set
238+
if unique_providers.contains(&ModelProvider::OpenRouter) {
239+
let provider_models = self.get_models_for_provider(ModelProvider::OpenRouter);
240+
good_models.extend(
241+
self.openrouter
242+
.check(provider_models)
243+
.await?
244+
.into_iter()
245+
.map(|m| (ModelProvider::OpenRouter, m)),
246+
);
247+
}
248+
233249
// update good models
234250
if good_models.is_empty() {
235251
Err(eyre!("No good models found, please check logs for errors."))

workflows/src/providers/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ pub use openai::OpenAIConfig;
66

77
mod gemini;
88
pub use gemini::GeminiConfig;
9+
10+
mod openrouter;
11+
pub use openrouter::OpenRouterConfig;

0 commit comments

Comments
 (0)