eagle0504 commited on
Commit
909543f
1 Parent(s): 0d25c8a

L336 of agent script set max_iterations

Browse files
Files changed (1) hide show
  1. utils/helper.py +4 -4
utils/helper.py CHANGED
@@ -294,7 +294,7 @@ OPENAI_API_KEY = os.environ["OPENAI_API_KEY"]
294
 
295
 
296
  def run_langchain_agent_(
297
- question: str = "What is your question?", interested_tickers: str = "AAPL, META"
298
  ) -> str:
299
  """
300
  Executes a language chain agent to answer questions by using a series of tools.
@@ -317,12 +317,11 @@ def run_langchain_agent_(
317
 
318
  # Creating a prompt template that structures the input question and a step-by-step thinking format
319
  template = """Question: {question};
320
- Information given about interested stock tickers in the financial market: {interested_tickers}
321
  You are a financial advisor and user has a question above regarding related tickers provided.
322
  Let's think step by step.
323
  Answer: """
324
  prompt = PromptTemplate(
325
- template=template, input_variables=["question", "interested_tickers"]
326
  )
327
 
328
  # Building a chain of language model actions based on the prompt template
@@ -333,7 +332,8 @@ def run_langchain_agent_(
333
 
334
  # Initializing the agent with the loaded tools, the language model, default name, and verbosity
335
  agent = initialize_agent(
336
- tools, llm, agent="zero-shot-react-description", verbose=True
 
337
  )
338
 
339
  # Running the agent to process the input question and generate an output
 
294
 
295
 
296
  def run_langchain_agent_(
297
+ question: str = "What is your question?"
298
  ) -> str:
299
  """
300
  Executes a language chain agent to answer questions by using a series of tools.
 
317
 
318
  # Creating a prompt template that structures the input question and a step-by-step thinking format
319
  template = """Question: {question};
 
320
  You are a financial advisor and user has a question above regarding related tickers provided.
321
  Let's think step by step.
322
  Answer: """
323
  prompt = PromptTemplate(
324
+ template=template, input_variables=["question"]
325
  )
326
 
327
  # Building a chain of language model actions based on the prompt template
 
332
 
333
  # Initializing the agent with the loaded tools, the language model, default name, and verbosity
334
  agent = initialize_agent(
335
+ tools, llm, agent="zero-shot-react-description", verbose=True,
336
+ max_iterations=5,
337
  )
338
 
339
  # Running the agent to process the input question and generate an output