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¤

NorFab Task that handles the chat interaction with the user by processing the input through a language model.

Parameters:

Name Type Description Default
user_input str

The input provided by the user.

required
template str

A template string for formatting the prompt. Defaults to

None

Returns:

Name Type Description
str str

Language model's response.

Raises:

Type Description
Exception

If the llm_flavour is unsupported.

Source code in norfab\workers\agent_worker.py
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
def chat(self, user_input, template=None) -> str:
    """
    NorFab Task that handles the chat interaction with the user by processing the input through a language model.

    Args:
        user_input (str): The input provided by the user.
        template (str, optional): A template string for formatting the prompt. Defaults to

    Returns:
        str: Language model's response.

    Raises:
        Exception: If the llm_flavour is unsupported.
    """
    if self.llm_flavour == "ollama":
        return self._chat_ollama(user_input, template)
    else:
        raise Exception(f"Unsupported llm flavour {self.llm_flavour}")