Skip to content

Agent Service Chat Task¤

Agent Chat Sample Usage¤

NORFAB Agent Chat Shell Reference¤

NorFab shell supports these command options for Agent chat task:

nf#man tree agent
root
└── agent:    AI Agent service
    ├── timeout:    Job timeout
    ├── workers:    Filter worker to target, default 'all'
    ├── show:    Show Agent service parameters
    │   ├── inventory:    show agent inventory data
    │   ├── version:    show agent service version report
    │   └── status:    show agent status
    ├── chat:    Chat with the agent
    └── progress:    Emit execution progress, default 'True'
nf#

* - mandatory/required command argument

Python API Reference¤

Source code in norfab\workers\agent_worker\agent_worker.py
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
@Task(
    input=InvokeInput,
    output=InvokeResult,
    fastapi={"methods": ["POST"]},
    mcp={
        "annotations": {
            "title": "Invoke Agent",
            "readOnlyHint": False,
            "destructiveHint": True,
            "idempotentHint": False,
            "openWorldHint": True,
        }
    },
)
def invoke(
    self,
    job: Job,
    instructions: str,
    name: str = "NorFab",
    verbose_result: bool = False,
) -> Result:
    ret = Result()
    log.info(f"{self.name} - Invoke: Processing instructions with '{name}' agent")
    job.event(f"getting {name} agent ready")

    agent_data = self.get_agent(job, name)

    agent_instance = create_agent(
        name=agent_data["name"],
        model=self.get_llm(**agent_data["llm"]),
        system_prompt=agent_data["system_prompt"],
        tools=agent_data["tools"],
    )

    job.event(f"{name} agent thinking")

    ret.result = agent_instance.invoke(
        {"messages": [{"role": "user", "content": instructions}]}
    )

    if verbose_result is False:
        ret.result = ret.result["messages"][-1].content

    return ret