forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent.py
More file actions
52 lines (45 loc) · 1.21 KB
/
Copy pathagent.py
File metadata and controls
52 lines (45 loc) · 1.21 KB
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
"""Agents"""
from typing import Optional, List, TypedDict
from abc import ABC, abstractmethod
from .types import Message
from .action import ActionDict
from .types import MetaEvent
class AgentDict(TypedDict):
"""Agent dictionary"""
name: str
description: Optional[str]
class Agent(ABC):
"""Agent class for CopilotKit"""
def __init__(
self,
*,
name: str,
description: Optional[str] = None,
):
self.name = name
self.description = description
@abstractmethod
def execute( # pylint: disable=too-many-arguments
self,
*,
state: dict,
messages: List[Message],
thread_id: Optional[str] = None,
node_name: Optional[str] = None,
actions: Optional[List[ActionDict]] = None,
meta_events: Optional[List[MetaEvent]] = None,
):
"""Execute the agent"""
@abstractmethod
def get_state(
self,
*,
thread_id: str,
):
"""Get agent state"""
def dict_repr(self) -> AgentDict:
"""Dict representation of the action"""
return {
'name': self.name,
'description': self.description or ''
}