Cmuroc27 commited on
Commit
81c9fb6
·
1 Parent(s): 9e6b745

ejecucion

Browse files
Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -30,21 +30,32 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
30
  class BasicAgent:
31
  def __init__(self):
32
  print("BasicAgent initialized.")
 
33
  self.llm = OpenAI(api_key=OPEN_AI, model="gpt-4o-mini")
34
 
35
  self.agent = AlfredAdvancedWorkflow(llm=self.llm)
36
-
 
 
 
 
 
 
 
37
 
38
  def __call__(self, question: str) -> str:
39
  print(f"Agent received question: {question[:50]}...")
40
 
41
  try:
 
 
 
 
 
 
42
  answer = asyncio.run(
43
- asyncio.wait_for(
44
- self.agent.run(question),
45
- timeout=90.0
46
- )
47
- )
48
  print(f" Final answer is : {answer[:60]}...")
49
  return answer
50
 
 
30
  class BasicAgent:
31
  def __init__(self):
32
  print("BasicAgent initialized.")
33
+
34
  self.llm = OpenAI(api_key=OPEN_AI, model="gpt-4o-mini")
35
 
36
  self.agent = AlfredAdvancedWorkflow(llm=self.llm)
37
+ #try:
38
+ # self.loop = asyncio.get_event_loop()
39
+ # if self.loop.is_closed():
40
+ # self.loop = asyncio.new_event_loop()
41
+ # asyncio.set_event_loop(self.loop)
42
+ #except RuntimeError:
43
+ # self.loop = asyncio.new_event_loop()
44
+ # asyncio.set_event_loop(self.loop)
45
 
46
  def __call__(self, question: str) -> str:
47
  print(f"Agent received question: {question[:50]}...")
48
 
49
  try:
50
+ #answer = self.loop.run_until_complete(
51
+ # asyncio.wait_for(
52
+ # self.agent.run(question),
53
+ # timeout=90.0
54
+ # )
55
+ #)
56
  answer = asyncio.run(
57
+ (asyncio.wait_for(self.agent.run(question), timeout=60.0)))
58
+
 
 
 
59
  print(f" Final answer is : {answer[:60]}...")
60
  return answer
61