33from __future__ import annotations
44
55from dataclasses import dataclass , field
6- from typing import Any , Optional
6+ from typing import TYPE_CHECKING , Any
77
8- from .client import AsyncHawkClient , HawkClient
9- from .streaming import AsyncStreamReader , StreamReader
108from .tools import Tool , chat_with_tools , chat_with_tools_async
11- from .types import ChatResponse
9+
10+ if TYPE_CHECKING :
11+ from .client import AsyncHawkClient , HawkClient
12+ from .streaming import AsyncStreamReader , StreamReader
13+ from .types import ChatResponse
1214
1315
1416@dataclass
@@ -26,12 +28,12 @@ class AgentConfig:
2628 """
2729
2830 name : str = "hawk-agent"
29- model : Optional [ str ] = None
30- system_prompt : Optional [ str ] = None
31+ model : str | None = None
32+ system_prompt : str | None = None
3133 tools : list [Tool ] = field (default_factory = list )
3234 max_rounds : int = 10
33- temperature : Optional [ float ] = None
34- top_p : Optional [ float ] = None
35+ temperature : float | None = None
36+ top_p : float | None = None
3537
3638
3739class Agent :
@@ -51,15 +53,15 @@ class Agent:
5153 def __init__ (
5254 self ,
5355 client : HawkClient ,
54- config : Optional [ AgentConfig ] = None ,
56+ config : AgentConfig | None = None ,
5557 ) -> None :
5658 self ._client = client
5759 self ._config = config or AgentConfig ()
58- self ._session_id : Optional [ str ] = None
60+ self ._session_id : str | None = None
5961 self ._history : list [dict [str , str ]] = []
6062
6163 @property
62- def session_id (self ) -> Optional [ str ] :
64+ def session_id (self ) -> str | None :
6365 """Current session ID, if one has been established."""
6466 return self ._session_id
6567
@@ -132,15 +134,15 @@ class AsyncAgent:
132134 def __init__ (
133135 self ,
134136 client : AsyncHawkClient ,
135- config : Optional [ AgentConfig ] = None ,
137+ config : AgentConfig | None = None ,
136138 ) -> None :
137139 self ._client = client
138140 self ._config = config or AgentConfig ()
139- self ._session_id : Optional [ str ] = None
141+ self ._session_id : str | None = None
140142 self ._history : list [dict [str , str ]] = []
141143
142144 @property
143- def session_id (self ) -> Optional [ str ] :
145+ def session_id (self ) -> str | None :
144146 """Current session ID."""
145147 return self ._session_id
146148
0 commit comments