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
31
32
33
34
def __init__(self, **kwargs):
    """
    Creates a new Agent.

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

    # Ensure backwards compatibility
    if "max_iterations" in kwargs:
        kwargs["max_steps"] = kwargs.pop("max_iterations")

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

    # Tools dictionary
    self.tools = self.process.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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.model.parameters(maxlength)

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