Skip to content
Open

Gd #1

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 .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Force panic=abort for Windows so the guardrail_ffi wrapper and prebuilt .lib
# don't both define rust_eh_personality (avoids LNK2005 when linking graphbit.dll).
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "panic=abort"]
17 changes: 17 additions & 0 deletions .github/workflows/build-artifacts-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
build-wheels:
name: Build Wheel - ${{ matrix.platform.runner }} - ${{ matrix.platform.target }}
runs-on: ${{ matrix.platform.runner }}
env:
# So Cargo passes -C panic=abort to every crate on Windows; avoids LNK2005 rust_eh_personality.
RUSTFLAGS: ${{ matrix.platform.runner == 'windows-latest' && '-C panic=abort' || '' }}

strategy:
fail-fast: false
Expand Down Expand Up @@ -95,7 +98,21 @@ jobs:
${{ runner.os }}-cargo-build-
${{ runner.os }}-cargo-

- name: Set RUSTFLAGS for Windows (panic=abort to avoid LNK2005)
if: runner.os == 'Windows'
run: echo "RUSTFLAGS=-C panic=abort" >> $env:GITHUB_ENV
shell: pwsh

# On Windows, clear target/ so guardrail_ffi is rebuilt with RUSTFLAGS (avoids stale cache with rust_eh_personality).
- name: Clear target on Windows for clean build
if: runner.os == 'Windows'
run: Remove-Item -Recurse -Force target -ErrorAction SilentlyContinue
shell: pwsh

- name: Build wheels
env:
# So Cargo passes -C panic=abort to every crate (including guardrail_ffi); avoids LNK2005 on Windows.
RUSTFLAGS: ${{ runner.os == 'Windows' && '-C panic=abort' || '' }}
uses: messense/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
Expand Down
10 changes: 10 additions & 0 deletions Cargo.lock

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

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ version.workspace = true
[profile.bench]
debug = false
incremental = false
lto = "fat"
lto = false
opt-level = 3

# Workspace profiles (applied to all members)
Expand All @@ -55,7 +55,8 @@ overflow-checks = true
codegen-units = 1
debug = false
incremental = false
lto = "fat"
# LTO disabled: prebuilt libguardrail_ffi.a has no bitcode; fat LTO would fail at link.
lto = false
opt-level = 3
panic = "abort"
strip = "symbols"
Expand All @@ -64,7 +65,8 @@ strip = "symbols"
[profile.release-python]
codegen-units = 1
inherits = "release"
lto = "fat"
# LTO follows release (false) so we can link prebuilt libguardrail_ffi.a
lto = false
opt-level = "s" # Optimize for size (important for Python extensions)
panic = "abort"
strip = "symbols"
Expand All @@ -80,6 +82,7 @@ jemallocator.workspace = true
[workspace]
members = [
"core",
"guardrail_ffi",
"python"
]
resolver = "2"
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export ANTHROPIC_API_KEY=your_anthropic_api_key_here
```python
import os

from graphbit import LlmConfig, Executor, Workflow, Node, tool
from graphbit import LlmConfig, Executor, Workflow, Node, tool, GuardRailPolicyConfig

# Initialize and configure
config = LlmConfig.openai(os.getenv("OPENAI_API_KEY"), "gpt-4o-mini")
Expand Down Expand Up @@ -200,7 +200,9 @@ id1 = workflow.add_node(smart_agent)
id2 = workflow.add_node(processor)
workflow.connect(id1, id2)

# Run (optionally with a guardrail policy for PII masking/mapping)
result = executor.execute(workflow)
# Or with policy: result = executor.execute(workflow, policy=GuardRailPolicyConfig.from_json('{"guardrail_policy": {"pii_rules": [...]}}'))
print(f"Workflow completed: {result.is_success()}")
print("\nSmart Agent Output: \n", result.get_node_output("Smart Agent"))
print("\nData Processor Output: \n", result.get_node_output("Data Processor"))
Expand Down
2 changes: 2 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[dependencies]
pyo3 = {workspace = true, optional = true}
# GuardRail: prebuilt libguardrail_ffi.a only (see vendor/guardrail/README.md).
guardrail_ffi = { path = "../guardrail_ffi" }
anyhow.workspace = true
async-trait.workspace = true
calamine.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ pub use types::{
pub use validation::ValidationResult;
pub use workflow::{Workflow, WorkflowBuilder, WorkflowExecutor};

// Re-export guardrail types (from prebuilt libguardrail_ffi.a via guardrail_ffi crate)
pub use guardrail_ffi::{DecodeContext, EncodeContext, EncodeResult, DecodeResult, Enforcer, GuardRail, GuardRailConfig};

/// Version information
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

Expand Down
Loading