Spaces:
Running
Running
typing
Browse files
main.py
CHANGED
@@ -16,7 +16,7 @@ from fastapi.staticfiles import StaticFiles
|
|
16 |
# --- Imports for poke_env and agents ---
|
17 |
from poke_env.player import Player
|
18 |
from poke_env import AccountConfiguration, ServerConfiguration
|
19 |
-
from poke_env.environment.battle import Battle
|
20 |
|
21 |
# Import the actual agent classes
|
22 |
from agents import OpenAIAgent, GeminiAgent, MistralAgent
|
@@ -50,14 +50,14 @@ if not AVAILABLE_AGENT_NAMES:
|
|
50 |
active_agent_name: Optional[str] = None
|
51 |
active_agent_instance: Optional[Player] = None
|
52 |
active_agent_task: Optional[asyncio.Task] = None
|
53 |
-
current_battle_instance
|
54 |
background_task_handle: Optional[asyncio.Task] = None
|
55 |
|
56 |
# --- Create FastAPI app ---
|
57 |
app = FastAPI(title="Pokemon Battle Livestream")
|
58 |
|
59 |
# --- Helper Functions ---
|
60 |
-
def get_active_battle(agent: Player)
|
61 |
"""Returns the first non-finished battle for an agent."""
|
62 |
if agent and agent._battles:
|
63 |
active_battles = [b for b in agent._battles.values() if not b.finished]
|
|
|
16 |
# --- Imports for poke_env and agents ---
|
17 |
from poke_env.player import Player
|
18 |
from poke_env import AccountConfiguration, ServerConfiguration
|
19 |
+
# from poke_env.environment.battle import Battle
|
20 |
|
21 |
# Import the actual agent classes
|
22 |
from agents import OpenAIAgent, GeminiAgent, MistralAgent
|
|
|
50 |
active_agent_name: Optional[str] = None
|
51 |
active_agent_instance: Optional[Player] = None
|
52 |
active_agent_task: Optional[asyncio.Task] = None
|
53 |
+
current_battle_instance = None
|
54 |
background_task_handle: Optional[asyncio.Task] = None
|
55 |
|
56 |
# --- Create FastAPI app ---
|
57 |
app = FastAPI(title="Pokemon Battle Livestream")
|
58 |
|
59 |
# --- Helper Functions ---
|
60 |
+
def get_active_battle(agent: Player):
|
61 |
"""Returns the first non-finished battle for an agent."""
|
62 |
if agent and agent._battles:
|
63 |
active_battles = [b for b in agent._battles.values() if not b.finished]
|