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.py
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
@Task(fastapi={"methods": ["POST"]})
def run_task(
    self, job, instructions: str, agent: Union[str, dict] = "norfab"
) -> Result:
    ret = Result()

    job.event("Creating agent")
    agent = create_agent(
        model=self.llm,
        tools=[],
        system_prompt="You are a helpful assistant",
    )

    job.event("Agent created, thinking ...")
    ret.result = agent.invoke(
        {"messages": [{"role": "user", "content": instructions}]}
    )

    return ret