Skip to content

Commit

Permalink
- Increased max-iterations to 15 default, and made it a configurable (#…
Browse files Browse the repository at this point in the history
…163)

parameter with --max-iterations.  Was previously hard-coded at 10.
- Fixed arg passing causing pull the wrong tool name
  • Loading branch information
cybermaggedon authored Nov 19, 2024
1 parent 0253281 commit f2c78b7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions trustgraph-flow/trustgraph/agent/react/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@
default_input_queue = agent_request_queue
default_output_queue = agent_response_queue
default_subscriber = module
default_max_iterations = 15

class Processor(ConsumerProducer):

def __init__(self, **params):

additional = params.get("context", None)

self.max_iterations = int(params.get("max_iterations", default_max_iterations))

tools = {}

# Parsing the prompt information to the prompt configuration
Expand Down Expand Up @@ -67,16 +70,17 @@ def __init__(self, **params):
)

if len(ttoks) == 1:

tools[toks[0]] = Tool(
name = ttoks[0],
name = toks[0],
description = "",
implementation = impl,
config = { "input": "query" },
arguments = {},
)
else:
tools[toks[0]] = Tool(
name = ttoks[0],
name = toks[0],
description = "",
implementation = impl,
config = { "input": ttoks[1] },
Expand Down Expand Up @@ -226,7 +230,7 @@ def handle(self, msg):

print(f"Question: {v.question}", flush=True)

if len(history) > 10:
if len(history) >= self.max_iterations:
raise RuntimeError("Too many agent iterations")

print(f"History: {history}", flush=True)
Expand Down Expand Up @@ -394,6 +398,12 @@ def add_args(parser):
help=f'Optional, specifies additional context text for the LLM.'
)

parser.add_argument(
'--max-iterations',
default=default_max_iterations,
help=f'Maximum number of react iterations (default: {default_max_iterations})',
)

def run():

Processor.start(module, __doc__)
Expand Down

0 comments on commit f2c78b7

Please sign in to comment.