44import typing as t
55from abc import ABC , abstractmethod
66
7+ from litellm import ConfigDict
8+ from pydantic import BaseModel
79from loguru import logger
810
911from nerve .models import Usage
1012from nerve .runtime import state
1113from nerve .tools .protocol import get_tool_response , get_tool_schema
1214
1315
14- class WindowStrategy (ABC ):
16+ class WindowStrategy (ABC , BaseModel ):
1517 @abstractmethod
1618 async def get_window (self , history : list [dict [str , t .Any ]]) -> list [dict [str , t .Any ]]:
1719 pass
@@ -20,23 +22,28 @@ async def get_window(self, history: list[dict[str, t.Any]]) -> list[dict[str, t.
2022 def __str__ (self ) -> str :
2123 pass
2224
25+ class GenerationConfig (BaseModel ):
26+ generator_id : str
27+ reasoning_effort : str | None = None
28+ window_strategy : WindowStrategy
29+ tools : list [t .Callable [..., t .Any ]] | None = None
30+
2331
2432class Engine (ABC ):
2533 def __init__ (
2634 self ,
27- generator_id : str ,
28- window_strategy : WindowStrategy ,
29- tools : list [t .Callable [..., t .Any ]] | None = None ,
35+ config : GenerationConfig ,
3036 ):
31- self .generator_id = generator_id
37+ self .config = config
38+ self .generator_id = config .generator_id
3239 self .generator_params : dict [str , t .Any ] = {}
3340
3441 self ._parse_generator_params ()
3542
3643 self .history : list [dict [str , t .Any ]] = []
37- self .window_strategy = window_strategy
44+ self .window_strategy = config . window_strategy
3845
39- self .tools = {fn .__name__ : fn for fn in (tools or [])}
46+ self .tools = {fn .__name__ : fn for fn in (config . tools or [])}
4047 self .tools_schemas = []
4148 for tool_name , tool_fn in self .tools .items ():
4249 if not tool_fn .__doc__ :
0 commit comments