-
Notifications
You must be signed in to change notification settings - Fork 653
/
Copy pathagent.py
55 lines (40 loc) · 1.41 KB
/
agent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from typing import Dict, Optional
from abstracts.agent import AgentStoreABC
from models.agent import Agent, AgentData, AgentQuota
class AgentStore(AgentStoreABC):
"""Implementation of agent data storage operations.
This class provides concrete implementations for storing and retrieving
agent-related data.
Args:
agent_id: ID of the agent
"""
def __init__(self, agent_id: str) -> None:
"""Initialize the agent store.
Args:
agent_id: ID of the agent
"""
super().__init__(agent_id)
async def get_config(self) -> Optional[Agent]:
"""Get agent configuration.
Returns:
Agent configuration if found, None otherwise
"""
return await Agent.get(self.agent_id)
async def get_data(self) -> Optional[AgentData]:
"""Get additional agent data.
Returns:
Agent data if found, None otherwise
"""
return await AgentData.get(self.agent_id)
async def set_data(self, data: Dict) -> None:
"""Update agent data.
Args:
data: Dictionary containing fields to update
"""
await AgentData.patch(self.agent_id, data)
async def get_quota(self) -> Optional[AgentQuota]:
"""Get agent quota information.
Returns:
Agent quota if found, None otherwise
"""
return await AgentQuota.get(self.agent_id)