File tree 16 files changed +34
-15
lines changed
16 files changed +34
-15
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ def process_instance(
62
62
reset_logger : bool = True ,
63
63
):
64
64
# Create the agent
65
- agent = Agent .get_cls (metadata .agent_class )(llm = LLM (llm_config = metadata .llm_config ))
65
+ agent = Agent .get_cls (metadata .agent_class )(llm = LLM (config = metadata .llm_config ))
66
66
# Setup the logger properly, so you can run multi-processing to parallelize the evaluation
67
67
eval_output_dir = metadata .eval_output_dir
68
68
if reset_logger :
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ def process_instance(
37
37
reset_logger : bool = True ,
38
38
):
39
39
# Create the agent
40
- agent = Agent .get_cls (metadata .agent_class )(llm = LLM (llm_config = metadata .llm_config ))
40
+ agent = Agent .get_cls (metadata .agent_class )(llm = LLM (config = metadata .llm_config ))
41
41
42
42
inst_id = instance .instance_id
43
43
question = instance .description
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ def process_instance(
87
87
reset_logger : bool = True ,
88
88
):
89
89
# Create the agent
90
- agent = Agent .get_cls (metadata .agent_class )(llm = LLM (llm_config = metadata .llm_config ))
90
+ agent = Agent .get_cls (metadata .agent_class )(llm = LLM (config = metadata .llm_config ))
91
91
instance = BiocoderData (** instance )
92
92
print (instance )
93
93
workspace_dir_name = (
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ def process_instance(
126
126
reset_logger : bool = True ,
127
127
):
128
128
# Create the agent
129
- agent = Agent .get_cls (metadata .agent_class )(llm = LLM (llm_config = metadata .llm_config ))
129
+ agent = Agent .get_cls (metadata .agent_class )(llm = LLM (config = metadata .llm_config ))
130
130
workspace_mount_path = os .path .join (
131
131
config .workspace_mount_path , 'bird_eval_workspace'
132
132
)
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ def process_instance(
31
31
reset_logger : bool = True ,
32
32
):
33
33
# Create the agent
34
- agent = Agent .get_cls (metadata .agent_class )(llm = LLM (llm_config = metadata .llm_config ))
34
+ agent = Agent .get_cls (metadata .agent_class )(llm = LLM (config = metadata .llm_config ))
35
35
env_id = instance .instance_id
36
36
# Setup the logger properly, so you can run multi-processing to parallelize the evaluation
37
37
if reset_logger :
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ def process_instance(
48
48
reset_logger : bool = True ,
49
49
):
50
50
# Create the agent
51
- agent = Agent .get_cls (metadata .agent_class )(llm = LLM (llm_config = metadata .llm_config ))
51
+ agent = Agent .get_cls (metadata .agent_class )(llm = LLM (config = metadata .llm_config ))
52
52
# create process-specific workspace dir
53
53
# we will create a workspace directory for EACH process
54
54
# so that different agent don't interfere with each other.
Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ def process_instance(
120
120
reset_logger : bool = True ,
121
121
):
122
122
# Create the agent
123
- agent = Agent .get_cls (metadata .agent_class )(llm = LLM (llm_config = metadata .llm_config ))
123
+ agent = Agent .get_cls (metadata .agent_class )(llm = LLM (config = metadata .llm_config ))
124
124
old_workspace_mount_path = config .workspace_mount_path
125
125
old_workspace_base = config .workspace_base
126
126
try :
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ def process_instance(
108
108
reset_logger : bool = True ,
109
109
):
110
110
# Create the agent
111
- agent = Agent .get_cls (metadata .agent_class )(llm = LLM (llm_config = metadata .llm_config ))
111
+ agent = Agent .get_cls (metadata .agent_class )(llm = LLM (config = metadata .llm_config ))
112
112
old_workspace_mount_path = config .workspace_mount_path
113
113
old_workspace_base = config .workspace_base
114
114
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ def process_instance(
103
103
reset_logger : bool = True ,
104
104
):
105
105
# Create the agent
106
- agent = Agent .get_cls (metadata .agent_class )(llm = LLM (llm_config = metadata .llm_config ))
106
+ agent = Agent .get_cls (metadata .agent_class )(llm = LLM (config = metadata .llm_config ))
107
107
old_workspace_mount_path = config .workspace_mount_path
108
108
old_workspace_base = config .workspace_base
109
109
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ def process_instance(
41
41
reset_logger : bool = True ,
42
42
):
43
43
# Create the agent
44
- agent = Agent .get_cls (metadata .agent_class )(llm = LLM (llm_config = metadata .llm_config ))
44
+ agent = Agent .get_cls (metadata .agent_class )(llm = LLM (config = metadata .llm_config ))
45
45
env_id = instance .id
46
46
# Setup the logger properly, so you can run multi-processing to parallelize the evaluation
47
47
if reset_logger :
Original file line number Diff line number Diff line change 67
67
68
68
69
69
def process_instance (instance : Any , metadata : EvalMetadata , reset_logger : bool = True ):
70
- agent = Agent .get_cls (metadata .agent_class )(llm = LLM (llm_config = metadata .llm_config ))
70
+ agent = Agent .get_cls (metadata .agent_class )(llm = LLM (config = metadata .llm_config ))
71
71
old_workspace_mount_path = config .workspace_mount_path
72
72
old_workspace_base = config .workspace_base
73
73
try :
Original file line number Diff line number Diff line change @@ -172,7 +172,7 @@ def process_instance(
172
172
reset_logger : bool = True ,
173
173
):
174
174
# Create the agent
175
- agent = Agent .get_cls (metadata .agent_class )(llm = LLM (llm_config = metadata .llm_config ))
175
+ agent = Agent .get_cls (metadata .agent_class )(llm = LLM (config = metadata .llm_config ))
176
176
177
177
workspace_mount_path = os .path .join (config .workspace_mount_path , '_eval_workspace' )
178
178
# create process-specific workspace dir
Original file line number Diff line number Diff line change 35
35
36
36
37
37
def process_instance (instance : Any , metadata : EvalMetadata , reset_logger : bool = True ):
38
- agent = Agent .get_cls (metadata .agent_class )(llm = LLM (llm_config = metadata .llm_config ))
38
+ agent = Agent .get_cls (metadata .agent_class )(llm = LLM (config = metadata .llm_config ))
39
39
# create process-specific workspace dir
40
40
# we will create a workspace directory for EACH process
41
41
# so that different agent don't interfere with each other.
Original file line number Diff line number Diff line change @@ -29,6 +29,14 @@ class EvalMetadata(BaseModel):
29
29
data_split : str | None = None
30
30
details : dict [str , Any ] | None = None
31
31
32
+ def model_dump_json (self , * args , ** kwargs ):
33
+ dumped = super ().model_dump_json (* args , ** kwargs )
34
+ dumped_dict = json .loads (dumped )
35
+ logger .debug (f'Dumped metadata: { dumped_dict } ' )
36
+ # avoid leaking sensitive information
37
+ dumped_dict ['llm_config' ] = self .llm_config .to_safe_dict ()
38
+ return json .dumps (dumped_dict )
39
+
32
40
33
41
def codeact_user_response (
34
42
state : State ,
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ def process_instance(
42
42
reset_logger : bool = True ,
43
43
):
44
44
# Create the agent
45
- agent = Agent .get_cls (metadata .agent_class )(llm = LLM (llm_config = metadata .llm_config ))
45
+ agent = Agent .get_cls (metadata .agent_class )(llm = LLM (config = metadata .llm_config ))
46
46
env_id = instance .id
47
47
# Setup the logger properly, so you can run multi-processing to parallelize the evaluation
48
48
if reset_logger :
Original file line number Diff line number Diff line change 17
17
load_dotenv ()
18
18
19
19
20
+ LLM_SENSITIVE_FIELDS = ['api_key' , 'aws_access_key_id' , 'aws_secret_access_key' ]
21
+
22
+
20
23
@dataclass
21
24
class LLMConfig :
22
25
"""Configuration for the LLM model.
@@ -86,7 +89,7 @@ def __str__(self):
86
89
attr_name = f .name
87
90
attr_value = getattr (self , f .name )
88
91
89
- if attr_name in [ 'api_key' , 'aws_access_key_id' , 'aws_secret_access_key' ] :
92
+ if attr_name in LLM_SENSITIVE_FIELDS :
90
93
attr_value = '******' if attr_value else None
91
94
92
95
attr_str .append (f'{ attr_name } ={ repr (attr_value )} ' )
@@ -96,6 +99,14 @@ def __str__(self):
96
99
def __repr__ (self ):
97
100
return self .__str__ ()
98
101
102
+ def to_safe_dict (self ):
103
+ """Return a dict with the sensitive fields replaced with ******."""
104
+ ret = self .__dict__ .copy ()
105
+ for k , v in ret .items ():
106
+ if k in LLM_SENSITIVE_FIELDS :
107
+ ret [k ] = '******' if v else None
108
+ return ret
109
+
99
110
100
111
@dataclass
101
112
class AgentConfig :
You can’t perform that action at this time.
0 commit comments