Skip to content

Methods

__init__(**kwargs)

Creates a new Agent.

Parameters:

Name Type Description Default
kwargs

arguments to pass to the underlying Agent backend and LLM pipeline instance

{}
Source code in txtai/agent/base.py
18
19
20
21
22
23
24
25
26
27
28
29
30
def __init__(self, **kwargs):
    """
    Creates a new Agent.

    Args:
        kwargs: arguments to pass to the underlying Agent backend and LLM pipeline instance
    """

    # Create agent process runner
    self.process = ProcessFactory.create(kwargs)

    # Tools dictionary
    self.tools = self.process.toolbox.tools

__call__(text, maxlength=8192, stream=False, **kwargs)

Runs an agent loop.

Parameters:

Name Type Description Default
text

instructions to run

required
maxlength

maximum sequence length

8192
stream

stream response if True, defaults to False

False
kwargs

additional keyword arguments

{}

Returns:

Type Description

result

Source code in txtai/agent/base.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def __call__(self, text, maxlength=8192, stream=False, **kwargs):
    """
    Runs an agent loop.

    Args:
        text: instructions to run
        maxlength: maximum sequence length
        stream: stream response if True, defaults to False
        kwargs: additional keyword arguments

    Returns:
        result
    """

    # Process parameters
    self.process.llm_engine.parameters(maxlength)

    # Run agent loop
    return self.process.run(text, stream=stream, **kwargs)