-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bdfd64f
commit 04b1761
Showing
1 changed file
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,58 @@ | ||
# OpenAgents Node - Python SDK | ||
|
||
|
||
A Python SDK for developing OpenAgents nodes. | ||
A Python SDK for developing OpenAgents nodes. | ||
|
||
|
||
|
||
## Example | ||
|
||
```python | ||
from openagents import JobRunner,OpenAgentsNode,NodeConfig,RunnerConfig | ||
|
||
# Define a runner | ||
class MyRunner (JobRunner): | ||
def __init__(self): | ||
# Set the runner metadata, template and filters | ||
super().__init__(\ | ||
RunnerConfig()\ | ||
.kind(5003)\ | ||
.name("My new Runner")\ | ||
.description("This is a new runner") | ||
# .... See RunnerConfig documentation | ||
) | ||
|
||
|
||
async def canRun(self,job): | ||
# Custom job filtering logic | ||
return True | ||
|
||
async def preRun(self, job): | ||
# Do something before running the job | ||
pass | ||
|
||
async def run(self,job): | ||
# Do something | ||
print("Running job",job.id) | ||
# Finish the job | ||
jobOutput="" | ||
return jobOutput | ||
|
||
async def postRun(self, job): | ||
# Do something after running the job | ||
pass | ||
|
||
#async def loop(self): | ||
# This is called by the main loop NODE_TPS times per second | ||
# Usually you won't need to implement this, but can be useful in some cases | ||
|
||
|
||
|
||
# Initialize the node | ||
myNode = OpenAgentsNode(NodeConfig().name("New node").version("0.0.1").description("This is a new node")) | ||
# Register the runner (you can register multiple runners) | ||
myNode.registerRunner(MyRunner()) | ||
# Start the node | ||
myNode.start() | ||
|
||
``` |