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¤

Handles the chat interaction with the user by processing the input through a language model.

Parameters:

Name Type Description Default
user_input

The input provided by the user.

required
template

A template string for formatting the prompt. Defaults to this string: 'Question: {user_input}; Answer: Let's think step by step. Provide answer in markdown format.'

None

Returns:

Type Description
str

language model's response

Source code in norfab\workers\agent_worker.py
113
114
115
116
117
118
119
120
121
122
123
124
125
126
def chat(self, user_input, template=None) -> str:
    """
    Handles the chat interaction with the user by processing the input through a language model.

    :param user_input: The input provided by the user.
    :param template: A template string for formatting the prompt. Defaults to
        this string: 'Question: {user_input}; Answer: Let's think step by step.
        Provide answer in markdown format.'
    :returns: language model's response
    """
    if self.llm_flavour == "ollama":
        return self._chat_ollama(user_input, template)
    else:
        raise Exception(f"Unsupported llm flavour {self.llm_flavour}")