f4f0328c43
Extracted from: https://github.com/temiroff/Blacknode.git Score: 1.0
3.5 KiB
3.5 KiB
name, version, description, inputs, steps, outputs, tags, metadata
| name | version | description | inputs | steps | outputs | tags | metadata | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| research-pipeline | 1.0.0 | Fetch a Wikipedia page, summarise it using an AI agent, and write the summary to a file. |
|
|
|
|
research-pipeline
Fetch a Wikipedia page, summarise it using an AI agent, and write the summary to a file.
Setup
Dependencies:
pip install anthropic>=0.25 docker>=7.1 openai>=1.0
Setup steps:
- Ensure NVIDIA NIM API key is set in the environment or editor UI
- Install required dependencies using
pip install -r requirements.txt
Key Files
examples/research_pipeline.py - Contains the research pipeline workflow
Steps
- Step 1: Import necessary modules from _bootstrap (NIM_MODEL, require_nim_api_key) and blacknode
- Step 2: Require NVIDIA NIM API key using
require_nim_api_key() - Step 3: Create a Graph instance
g - Step 4: Add a Literal node for the URL of the Wikipedia page (
url) - Step 5: Add an HTTPGet node to fetch the content from the URL (
fetcher) and connect it to the Literal node - Step 6: Add an LLMAgent node with system prompt 'You are a technical writer. Summarise the text in 3 bullet points.' and model NIM_MODEL (
summarise), connecting its input to the output offetcher - Step 7: Add a FileWrite node to write the summary to a file named 'summary.txt' (
writer), connecting its input to the output ofsummarise - Step 8: Cook the graph starting from the writer node and print the path where the summary is written
Implementation Details
from _bootstrap import NIM_MODEL, require_nim_api_key
import blacknode as bn
g = bn.Graph()
url = g.node('Literal', value='https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exintro=1&explaintext=1&titles=Houdini_(software)&format=json&formatversion=2&origin=*')
fetcher = g.node('HTTPGet')
summarise = g.node('LLMAgent', system='You are a technical writer. Summarise the text in 3 bullet points.', model=NIM_MODEL)
writer = g.node('FileWrite', path='summary.txt')
url.out('value') >> fetcher.inp('url')
fetcher.out('text') >> summarise.inp('prompt')
summarise.out('text') >> writer.inp('text')
result = g.cook(writer, 'path')
print(f'Summary written to: {result}')
Inputs
- URL of the Wikipedia page
Outputs
- Path to the summary file
Failure Modes
- If the URL is invalid, HTTPGet will fail; if NIM API key is missing, LLMAgent will not function properly
Source
Extracted from: https://github.com/temiroff/Blacknode.git Confidence: 0.95