11
11
from promptflow ._utils .execution_utils import apply_default_value_for_input
12
12
from promptflow ._proxy ._proxy_factory import ProxyFactory
13
13
from promptflow ._utils .logger_utils import bulk_logger
14
- from promptflow ._constants import CONVERSATION_HISTORY_EXPRESSION , CONVERSATION_HISTORY_OUTPUT_KEY , CHAT_ROLE_KEY
14
+ from promptflow ._orchestrator ._constants import (
15
+ CONVERSATION_HISTORY_EXPRESSION ,
16
+ CONVERSATION_HISTORY_OUTPUT_KEY ,
17
+ CHAT_ROLE_KEY
18
+ )
15
19
from promptflow ._orchestrator ._errors import (
16
20
InvalidChatRoleCount ,
17
21
MissingConversationHistoryExpression ,
@@ -84,7 +88,7 @@ def _create_executor_proxy(self, **kwargs) -> List[AbstractExecutorProxy]:
84
88
for chat_role in self ._chat_group_roles :
85
89
executor_proxy = executor_proxy_factory .create_executor_proxy (
86
90
flow_file = chat_role ._flow_file ,
87
- working_dir = chat_role .working_dir ,
91
+ working_dir = chat_role ._working_dir ,
88
92
connections = chat_role ._connections ,
89
93
storage = self ._storage ,
90
94
language = chat_role .check_language_from_yaml (),
@@ -97,7 +101,7 @@ def _create_executor_proxy(self, **kwargs) -> List[AbstractExecutorProxy]:
97
101
init_kwargs = chat_role ._init_kwargs ,
98
102
** kwargs
99
103
)
100
- bulk_logger .info (f"Created executor proxy for role:{ chat_role .role } . name: { chat_role .name } " )
104
+ bulk_logger .info (f"Created executor proxy for role:{ chat_role .role } . name: { chat_role ._name } " )
101
105
executor_proxy_list .append (executor_proxy )
102
106
return executor_proxy_list
103
107
@@ -145,17 +149,17 @@ async def _schedule_line_runs(
145
149
if conversation_history_key is None :
146
150
bulk_logger .error (
147
151
f"Cannot find conversation expression mapping for "
148
- f"chat role: { chat_role .role } . name: { chat_role .name } "
152
+ f"chat role: { chat_role .role } . name: { chat_role ._name } "
149
153
)
150
154
message = (
151
155
f"Cannot find conversation expression mapping for "
152
- f"chat role: { chat_role .role } . name: { chat_role .name } "
156
+ f"chat role: { chat_role .role } . name: { chat_role ._name } "
153
157
f"Please use define { CONVERSATION_HISTORY_EXPRESSION } for a flow input."
154
158
)
155
159
raise MissingConversationHistoryExpression (message = message )
156
160
chat_role_input [conversation_history_key ] = conversation_history
157
161
bulk_logger .info (
158
- f"Start to execute turn { turn } . role: { chat_role .role } . name: { chat_role .name } "
162
+ f"Start to execute turn { turn } . role: { chat_role .role } . name: { chat_role ._name } "
159
163
)
160
164
161
165
current_line_result = await executor_proxy .exec_line_async (chat_role_input , line_index , run_id )
@@ -168,13 +172,13 @@ async def _schedule_line_runs(
168
172
aggregation_inputs )
169
173
bulk_logger .info (
170
174
f"Finish process line result for "
171
- f"line number: { line_index } , turn:{ turn } . role:{ chat_role .role } , name: { chat_role .name } "
175
+ f"line number: { line_index } , turn:{ turn } . role:{ chat_role .role } , name: { chat_role ._name } "
172
176
)
173
177
174
- if any (value == chat_role .stop_signal for value in current_line_result .output .values ()):
178
+ if any (value == chat_role ._stop_signal for value in current_line_result .output .values ()):
175
179
bulk_logger .info (
176
180
f"Stop chat since current turn align with stop signal. "
177
- f"line number: { line_index } , turn:{ turn } . role:{ chat_role .role } , name: { chat_role .name } "
181
+ f"line number: { line_index } , turn:{ turn } . role:{ chat_role .role } , name: { chat_role ._name } "
178
182
)
179
183
break
180
184
@@ -222,19 +226,19 @@ def _process_batch_inputs(self, inputs: Dict[str, Any]):
222
226
if len (conversation_history_mapping ) == 0 :
223
227
bulk_logger .error (
224
228
f"Cannot find conversation expression mapping for "
225
- f"chat role: { chat_role .role } . name: { chat_role .name } "
229
+ f"chat role: { chat_role .role } . name: { chat_role ._name } "
226
230
)
227
231
message = (
228
232
f"Cannot find conversation expression mapping for "
229
- f"chat role: { chat_role .role } . name: { chat_role .name } "
233
+ f"chat role: { chat_role .role } . name: { chat_role ._name } "
230
234
f"Please mapping { CONVERSATION_HISTORY_EXPRESSION } for a flow input."
231
235
)
232
236
raise MissingConversationHistoryExpression (message = message )
233
237
234
238
if len (conversation_history_mapping ) > 1 :
235
239
bulk_logger .error (f"Multiple inputs mapping of { CONVERSATION_HISTORY_EXPRESSION } " )
236
240
message = (
237
- f"chat role: { chat_role .role } . name: { chat_role .name } "
241
+ f"chat role: { chat_role .role } . name: { chat_role ._name } "
238
242
f"only accepts 1 inputs mapping for { CONVERSATION_HISTORY_EXPRESSION } "
239
243
)
240
244
raise MultipleConversationHistoryInputsMapping (message = message )
@@ -245,7 +249,7 @@ def _process_batch_inputs(self, inputs: Dict[str, Any]):
245
249
}
246
250
247
251
batch_input_processor = BatchInputsProcessor (
248
- chat_role .working_dir ,
252
+ chat_role ._working_dir ,
249
253
chat_role ._flow_definition .inputs ,
250
254
self ._max_lines_count )
251
255
batch_input = batch_input_processor ._process_batch_inputs_line (inputs , cleaned_inputs_mapping )
0 commit comments