Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
18ae3a7
tests added
nina-kollman Feb 10, 2026
3cf4f78
add implementation
nina-kollman Feb 10, 2026
9c69876
model location
nina-kollman Feb 11, 2026
a386ad4
common guardrail
nina-kollman Feb 11, 2026
d0bf203
redesign
nina-kollman Feb 11, 2026
8643fab
added validation test
nina-kollman Feb 11, 2026
3eed548
provider hash
nina-kollman Feb 11, 2026
6cf07de
input extractor
nina-kollman Feb 11, 2026
f08c7d5
add check
nina-kollman Feb 12, 2026
d4139b0
eval structs
nina-kollman Feb 12, 2026
77c8c97
change client pos
nina-kollman Feb 12, 2026
582decf
guard response
nina-kollman Feb 12, 2026
f82250f
added error
nina-kollman Feb 12, 2026
89b5e47
no guards in completion
nina-kollman Feb 15, 2026
36b1720
cleanup
nina-kollman Feb 15, 2026
accfd5f
merge files
nina-kollman Feb 15, 2026
5c78a56
setup
nina-kollman Feb 15, 2026
c95024c
comments
nina-kollman Feb 15, 2026
c12b0e7
test rename
nina-kollman Feb 15, 2026
c1baabd
Merge branch 'main' of https://github.com/traceloop/hub into nk/guard…
nina-kollman Feb 15, 2026
70a0ff1
format
nina-kollman Feb 15, 2026
f0f461c
add warn
nina-kollman Feb 15, 2026
a001980
add spans
nina-kollman Feb 15, 2026
c123126
add spans
nina-kollman Feb 15, 2026
3950409
lint
nina-kollman Feb 15, 2026
fd1bed2
build fix
nina-kollman Feb 15, 2026
764e64d
test comments
nina-kollman Feb 15, 2026
40db3ab
add evaluator test
nina-kollman Feb 15, 2026
89f0a49
update recording
nina-kollman Feb 15, 2026
cd2381d
ci tests
nina-kollman Feb 15, 2026
99dff3d
add md
nina-kollman Feb 15, 2026
d4efb43
add validation
nina-kollman Feb 16, 2026
3d4743a
added timeout
nina-kollman Feb 16, 2026
72e6a83
add header parsing
nina-kollman Feb 16, 2026
60b0a68
extract prompt
nina-kollman Feb 16, 2026
7edb582
records
nina-kollman Feb 16, 2026
254bacd
ci
nina-kollman Feb 16, 2026
6244dbc
add example
nina-kollman Feb 16, 2026
5ea42d1
init middle
nina-kollman Feb 18, 2026
ddfc09c
dhange
nina-kollman Feb 18, 2026
f5ba8fb
added middle test
nina-kollman Feb 18, 2026
6e2fc92
require api key
nina-kollman Feb 18, 2026
1d86658
more comments
nina-kollman Feb 18, 2026
9654295
comm
nina-kollman Feb 18, 2026
8656726
doc
nina-kollman Feb 18, 2026
f6b83a7
fix tracing
nina-kollman Feb 18, 2026
74dbe1d
test for otel
nina-kollman Feb 18, 2026
f97082d
ci
nina-kollman Feb 18, 2026
fee4963
code simplify
nina-kollman Feb 18, 2026
b973e9e
fix test
nina-kollman Feb 18, 2026
0b33b56
s1
nina-kollman Feb 19, 2026
65e4383
s2
nina-kollman Feb 19, 2026
36b0e1b
s3
nina-kollman Feb 19, 2026
4817abc
ci
nina-kollman Feb 19, 2026
853c8c9
enable pre_call for streaming
nina-kollman Feb 19, 2026
f259218
fix1
nina-kollman Feb 19, 2026
d3b7063
test unsafe fix
nina-kollman Feb 19, 2026
1a90138
fix 3
nina-kollman Feb 19, 2026
efaae44
fix 4
nina-kollman Feb 19, 2026
318f60d
fix build
nina-kollman Feb 22, 2026
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ config.yaml
.vscode/
.DS_Store

# Documentation
docs/
.claude/

prd/
memory-bank/
.cursor/
Expand Down
52 changes: 51 additions & 1 deletion Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ utoipa = { version = "5.0.0", features = ["axum_extras", "chrono", "uuid", "open
utoipa-swagger-ui = { version = "8", features = ["axum"] }
utoipa-scalar = { version = "0.3.0", features = ["axum"] }
log = "0.4"
thiserror = "2"

[lib]
name = "hub_lib"
Expand All @@ -72,6 +73,9 @@ tempfile = "3.8"
testcontainers = "0.20.0"
testcontainers-modules = { version = "0.8.0", features = ["postgres"] }
axum-test = "17"
temp-env = "0.3"
sqlx = { version = "0.8", features = ["runtime-tokio", "postgres", "migrate"] }
tokio = { version = "1.45.0", features = ["full"] }
reqwest = { version = "0.12", features = ["json"] }
opentelemetry = { version = "0.27" }
opentelemetry_sdk = { version = "0.27", features = ["testing"] }
36 changes: 36 additions & 0 deletions config-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ pipelines:
# Default pipeline for chat completions
- name: default
type: chat
guards: # Optional: reference guards by name (defined in guardrails section below)
- pii-check
- injection-check
plugins:
- logging:
level: info # Supported levels: debug, info, warning, error
Expand Down Expand Up @@ -125,3 +128,36 @@ pipelines:
- model-router:
models: # List the models you want to use for embeddings
- textembedding-gecko

guardrails:
providers:
- name: traceloop
api_base: ${TRACELOOP_BASE_URL} # or use direct URL
api_key: ${TRACELOOP_API_KEY} # or use "<your-api-key>"
guards:
# PII Detection - Pre-call guard
- name: pii-check
provider: traceloop
evaluator_slug: pii-detector
mode: pre_call # Runs before the model call
on_failure: block # Options: block, warn
required: true # If true, request fails if guard is unavailable

# Prompt Injection Detection - Pre-call guard
- name: injection-check
provider: traceloop
evaluator_slug: prompt-injection
params:
threshold: 0.8
mode: pre_call
on_failure: block
required: false

# Toxicity Detection - Post-call guard
- name: toxicity-filter
provider: traceloop
evaluator_slug: toxicity-detector
params:
threshold: 0.8
mode: post_call # Runs after the model call
on_failure: block
8 changes: 7 additions & 1 deletion src/config/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::guardrails::types::GuardrailsConfig;
use crate::types::{GatewayConfig, ModelConfig, Pipeline, PipelineType, PluginConfig, Provider};
use serde::Deserialize;
use std::sync::OnceLock;
Expand All @@ -11,6 +12,8 @@ struct YamlCompatiblePipeline {
r#type: PipelineType,
#[serde(with = "serde_yaml::with::singleton_map_recursive")]
plugins: Vec<PluginConfig>,
#[serde(default)]
guards: Vec<String>,
#[serde(default = "default_enabled_true_lib")]
#[allow(dead_code)]
enabled: bool, // Keep for YAML parsing, but won't be mapped to core Pipeline
Expand All @@ -31,6 +34,8 @@ struct YamlRoot {
models: Vec<ModelConfig>,
#[serde(default)]
pipelines: Vec<YamlCompatiblePipeline>,
#[serde(default)]
guardrails: Option<GuardrailsConfig>,
}

fn substitute_env_vars(content: &str) -> Result<String, Box<dyn std::error::Error>> {
Expand Down Expand Up @@ -83,11 +88,12 @@ pub fn load_config(path: &str) -> Result<GatewayConfig, Box<dyn std::error::Erro
name: p_yaml.name,
r#type: p_yaml.r#type,
plugins: p_yaml.plugins,
// p_yaml.enabled is parsed from YAML but not stored in core Pipeline struct
guards: p_yaml.guards,
}
})
.collect(),
general: None,
guardrails: yaml_root.guardrails,
};
let _ = TRACE_CONTENT_ENABLED.set(
gateway_config
Expand Down
Loading