1+ from __future__ import annotations
2+
13import warnings
24from dataclasses import dataclass , field
3- from typing import Any , Dict , List , Literal , Optional , Union
5+ from typing import Any , Dict , List , Optional , Union
46
7+ from ldai .config .types import LDMessage , ModelConfig , ProviderConfig
58from ldai .tracker import LDAIConfigTracker
69
7-
8- @dataclass
9- class LDMessage :
10- role : Literal ['system' , 'user' , 'assistant' ]
11- content : str
12-
13- def to_dict (self ) -> dict :
14- """
15- Render the given message as a dictionary object.
16- """
17- return {
18- 'role' : self .role ,
19- 'content' : self .content ,
20- }
21-
22-
23- class ModelConfig :
24- """
25- Configuration related to the model.
26- """
27-
28- def __init__ (self , name : str , parameters : Optional [Dict [str , Any ]] = None , custom : Optional [Dict [str , Any ]] = None ):
29- """
30- :param name: The name of the model.
31- :param parameters: Additional model-specific parameters.
32- :param custom: Additional customer provided data.
33- """
34- self ._name = name
35- self ._parameters = parameters
36- self ._custom = custom
37-
38- @property
39- def name (self ) -> str :
40- """
41- The name of the model.
42- """
43- return self ._name
44-
45- def get_parameter (self , key : str ) -> Any :
46- """
47- Retrieve model-specific parameters.
48-
49- Accessing a named, typed attribute (e.g. name) will result in the call
50- being delegated to the appropriate property.
51- """
52- if key == 'name' :
53- return self .name
54-
55- if self ._parameters is None :
56- return None
57-
58- return self ._parameters .get (key )
59-
60- def get_custom (self , key : str ) -> Any :
61- """
62- Retrieve customer provided data.
63- """
64- if self ._custom is None :
65- return None
66-
67- return self ._custom .get (key )
68-
69- def to_dict (self ) -> dict :
70- """
71- Render the given model config as a dictionary object.
72- """
73- return {
74- 'name' : self ._name ,
75- 'parameters' : self ._parameters ,
76- 'custom' : self ._custom ,
77- }
78-
79-
80- class ProviderConfig :
81- """
82- Configuration related to the provider.
83- """
84-
85- def __init__ (self , name : str ):
86- self ._name = name
87-
88- @property
89- def name (self ) -> str :
90- """
91- The name of the provider.
92- """
93- return self ._name
94-
95- def to_dict (self ) -> dict :
96- """
97- Render the given provider config as a dictionary object.
98- """
99- return {
100- 'name' : self ._name ,
101- }
102-
103-
10410# ============================================================================
10511# Judge Types
10612# ============================================================================
10713
14+
10815@dataclass (frozen = True )
10916class JudgeConfiguration :
11017 """
@@ -128,7 +35,7 @@ def to_dict(self) -> dict:
12835 'samplingRate' : self .sampling_rate ,
12936 }
13037
131- judges : List [' JudgeConfiguration.Judge' ]
38+ judges : List [JudgeConfiguration .Judge ]
13239
13340 def to_dict (self ) -> dict :
13441 """
0 commit comments