3
3
4
4
import typer
5
5
from dotenv import load_dotenv
6
+ from langchain_core .runnables .config import RunnableConfig
6
7
7
8
from template_langgraph .agents .chat_with_tools_agent .agent import graph as chat_with_tools_agent_graph
8
9
from template_langgraph .agents .image_classifier_agent .agent import graph as image_classifier_agent_graph
@@ -92,6 +93,12 @@ def run(
92
93
"-q" ,
93
94
help = "Question to ask the agent" ,
94
95
),
96
+ recursion_limit : int = typer .Option (
97
+ 10 ,
98
+ "--recursion-limit" ,
99
+ "-r" ,
100
+ help = "Recursion limit for the agent" ,
101
+ ),
95
102
verbose : bool = typer .Option (
96
103
False ,
97
104
"--verbose" ,
@@ -116,7 +123,10 @@ def run(
116
123
"content" : question ,
117
124
}
118
125
],
119
- }
126
+ },
127
+ config = RunnableConfig (
128
+ recursion_limit = recursion_limit ,
129
+ ),
120
130
):
121
131
logger .info ("-" * 20 )
122
132
logger .info (f"Event: { event } " )
@@ -142,6 +152,12 @@ def news_summarizer_agent(
142
152
"-o" ,
143
153
help = "Path to the output Markdown file" ,
144
154
),
155
+ recursion_limit : int = typer .Option (
156
+ 10 ,
157
+ "--recursion-limit" ,
158
+ "-r" ,
159
+ help = "Recursion limit for the agent" ,
160
+ ),
145
161
verbose : bool = typer .Option (
146
162
False ,
147
163
"--verbose" ,
@@ -162,7 +178,10 @@ def news_summarizer_agent(
162
178
urls = urls .split ("," ) if urls else [],
163
179
),
164
180
articles = [],
165
- )
181
+ ),
182
+ config = RunnableConfig (
183
+ recursion_limit = recursion_limit ,
184
+ ),
166
185
):
167
186
logger .info ("-" * 20 )
168
187
logger .info (f"Event: { event } " )
@@ -189,6 +208,12 @@ def image_classifier_agent(
189
208
"-f" ,
190
209
help = "Comma-separated list of file paths to classify" ,
191
210
),
211
+ recursion_limit : int = typer .Option (
212
+ 10 ,
213
+ "--recursion-limit" ,
214
+ "-r" ,
215
+ help = "Recursion limit for the agent" ,
216
+ ),
192
217
verbose : bool = typer .Option (
193
218
False ,
194
219
"--verbose" ,
@@ -214,7 +239,10 @@ def image_classifier_agent(
214
239
file_paths = file_paths .split ("," ) if file_paths else [],
215
240
),
216
241
results = [],
217
- )
242
+ ),
243
+ config = RunnableConfig (
244
+ recursion_limit = recursion_limit ,
245
+ ),
218
246
):
219
247
logger .info ("-" * 20 )
220
248
logger .info (f"Event: { event } " )
0 commit comments