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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
@Task(fastapi={"methods": ["POST"]})
def invoke(
    self,
    job,
    instructions: str,
    name: str = "NorFab",
    verbose_result: bool = False,
) -> Result:
    ret = Result()
    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