7273cbe4ba
Extracted from: https://github.com/temiroff/Blacknode.git Score: 1.0
4.2 KiB
4.2 KiB
name, version, description, inputs, steps, outputs, tags, metadata
| name | version | description | inputs | steps | outputs | tags | metadata | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| graph-based-node-orchestration | 1.0.0 | Build a typed node graph that processes data through a sequence of operations and produces a final result |
|
|
|
|
graph-based-node-orchestration
Build a typed node graph that processes data through a sequence of operations and produces a final result
Setup
Dependencies:
pip install blacknode >= 0.3.0 Python >= 3.11 NVIDIA NIM API key (optional but recommended) Anthropic, OpenAI, or other LLM models
Setup steps:
- Clone the repository and install dependencies: pip install -e .
- Set NVIDIA_API_KEY or other required API keys in .env
- Run the example script: python examples/hello_agent.py
- For production, configure hardware pairing and deploy via the blacknode CLI
Key Files
examples/converted_nvidia_nim.py - Full graph with Model, Text, LLMAgent, Output nodesexamples/hello_agent.py - Minimal agent example connecting Literal → LLMAgent → Printblacknode/core - Graph and node implementation (internal)
Steps
- Import required modules (blacknode as bn, NIM_MODEL) and ensure API keys are available via require_nim_api_key()
- Create a bn.Graph() instance to hold all nodes and their connections
- Define individual nodes with specific input/output parameters (e.g., Text node with 'value' input, LLMAgent node with model parameter, Output node with 'value' output)
- Connect nodes together using edge definitions (from_port -> to_port) to establish data flow
- Execute the graph using g.cook() to run the pipeline and process data through the node chain
- Extract the final result from the output node to complete the workflow
Implementation Details
g = bn.Graph()
model = g.node('Model', **{'value': 'nim:meta/llama-3.1-8b-instruct'})
agent = g.node('LLMAgent', **{model})
result = g.cook(output, 'value')
Inputs
- NIM_MODEL constant (e.g., 'nim:meta/llama-3.1-8b-instruct') for the LLM model
- blacknode package with Graph, Node, and cook functionality
- Python script defining node types with inputs/outputs and connecting them via edges
Outputs
- A fully constructed graph with typed nodes and defined connections
- Executed result (e.g., processed text, summary, or other output) from the final node
- A reusable pattern that can be adapted to different models, hardware, or task types
Failure Modes
- Missing or invalid API key (NIM_API_KEY, OPENAI_API_KEY) causing require_nim_api_key() to fail
- Type mismatch in node connections (e.g., expecting 'value' but receiving 'text') breaking the data flow
- Model not available or unreachable (NIM_MODEL not found) causing the LLMAgent node to fail
- Graph execution error due to incorrect edge configuration or circular dependencies
- Resource exhaustion (e.g., GPU memory) when processing large inputs in the pipeline
Source
Extracted from: https://github.com/temiroff/Blacknode.git Confidence: 0.95