Psiska commited on
Commit
66abe20
·
1 Parent(s): a1fa38c

Refactor app.py for chat interface and update agent logic 2

Browse files
Files changed (2) hide show
  1. agent.py +2 -2
  2. app.py +2 -2
agent.py CHANGED
@@ -41,7 +41,7 @@ class BasicAgent:
41
  self.model = HfApiModel(
42
  model_id="https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud",
43
  provider="together",
44
- use_auth_token=True,
45
  )
46
 
47
  # Initialize agent once
@@ -49,7 +49,7 @@ class BasicAgent:
49
  tools=[tls.search_tool, tls.calculate_cargo_travel_time],
50
  model=self.model, # <-- use self.model instead of re-instantiating
51
  additional_authorized_imports=["pandas"],
52
- max_steps=20,
53
  )
54
 
55
  self.chat_history = [] # Optional: for memory support later
 
41
  self.model = HfApiModel(
42
  model_id="https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud",
43
  provider="together",
44
+ use_auth_token=True
45
  )
46
 
47
  # Initialize agent once
 
49
  tools=[tls.search_tool, tls.calculate_cargo_travel_time],
50
  model=self.model, # <-- use self.model instead of re-instantiating
51
  additional_authorized_imports=["pandas"],
52
+ max_steps=20
53
  )
54
 
55
  self.chat_history = [] # Optional: for memory support later
app.py CHANGED
@@ -146,8 +146,8 @@ def test_init_agent_for_chat(text_input, history):
146
  # --- Agent Logic for Chat Interface ---
147
  def handle_chat(message, history):
148
  try:
149
- agent = BasicAgent()
150
- response = agent(message)
151
  return response
152
  except Exception as e:
153
  return f"[ERROR] Agent failed: {str(e)}"
 
146
  # --- Agent Logic for Chat Interface ---
147
  def handle_chat(message, history):
148
  try:
149
+ basicAgent = agent.BasicAgent()
150
+ response = basicAgent(message)
151
  return response
152
  except Exception as e:
153
  return f"[ERROR] Agent failed: {str(e)}"