Bandook01 commited on
Commit
1c0f385
·
1 Parent(s): f649075

remove reset

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -77,10 +77,13 @@ class BasicAgent:
77
  print("✅ BasicAgent initialized.")
78
 
79
  async def answer_once(self, prompt: str) -> str:
80
- """Ask one question, then clear the dialogue so tokens never pile up."""
81
- reply = await self.agent.run(prompt)
82
- self.agent.reset() # <<< flush conversation context
83
- return reply
 
 
 
84
 
85
  async def __call__(self, input_text: str):
86
  # Use run() within async context
 
77
  print("✅ BasicAgent initialized.")
78
 
79
  async def answer_once(self, prompt: str) -> str:
80
+ """Run the agent in a blank context so tokens never pile up."""
81
+ # Safety: trim monster inputs
82
+ # prompt = prompt[:32000] # 2 k tokens head-room
83
+ ctx = Context(self.agent) # no prior messages
84
+ resp = await self.agent.run(user_msg=prompt, ctx=ctx)
85
+ # run() sometimes returns dict, sometimes str
86
+ return resp if isinstance(resp, str) else resp.get("response", str(resp))
87
 
88
  async def __call__(self, input_text: str):
89
  # Use run() within async context