gohumanloop 0.0.5__py3-none-any.whl → 0.0.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,20 @@
1
1
  from abc import ABC, abstractmethod
2
- from typing import Any, Dict, Optional, Protocol, runtime_checkable, List, Union, Callable, Awaitable
2
+ from typing import (
3
+ Any,
4
+ Dict,
5
+ Optional,
6
+ Protocol,
7
+ runtime_checkable,
8
+ Union,
9
+ )
3
10
  from enum import Enum
4
11
  from dataclasses import dataclass, field
5
12
  from datetime import datetime
6
13
 
14
+
7
15
  class HumanLoopStatus(Enum):
8
16
  """Enumeration of human-in-the-loop states"""
17
+
9
18
  PENDING = "pending"
10
19
  APPROVED = "approved"
11
20
  REJECTED = "rejected"
@@ -15,53 +24,70 @@ class HumanLoopStatus(Enum):
15
24
  INPROGRESS = "inprogress" # Intermediate state for multi-turn dialogues, indicating ongoing conversation
16
25
  CANCELLED = "cancelled" # For cancelled requests
17
26
 
27
+
18
28
  class HumanLoopType(Enum):
19
29
  """Enumeration of human-in-the-loop types"""
30
+
20
31
  APPROVAL = "approval" # Approval type
21
32
  INFORMATION = "information" # Information gathering type
22
33
  CONVERSATION = "conversation" # Conversation type
23
34
 
35
+
24
36
  """
25
37
  ## Relationship between task_id, conversation_id and request_id
26
38
  1. Hierarchical relationship:
27
-
39
+
28
40
  - task_id is at the highest level, representing business tasks
29
41
  - conversation_id is at the middle level, representing a complete dialogue session
30
42
  - request_id is at the lowest level, representing a single interaction request
31
43
  2. Mapping relationship:
32
-
44
+
33
45
  - One task_id may correspond to multiple conversation_ids (a task may require multiple conversations)
34
46
  - One conversation_id may correspond to multiple request_ids (a conversation may contain multiple rounds of interaction)
35
47
  """
48
+
49
+
36
50
  @dataclass
37
51
  class HumanLoopRequest:
38
52
  """人机循环请求的数据模型 / Human loop request data model"""
53
+
39
54
  task_id: str # 任务ID / Task identifier
40
- conversation_id: str# 用于关联多轮对话 / Used to associate multi-turn conversations
55
+ conversation_id: str # 用于关联多轮对话 / Used to associate multi-turn conversations
41
56
  loop_type: HumanLoopType # 循环类型 / Loop type
42
57
  context: Dict[str, Any] # 交互上下文信息 / Interaction context information
43
- metadata: Dict[str, Any] = field(default_factory=dict) # 元数据信息 / Metadata information
58
+ metadata: Dict[str, Any] = field(
59
+ default_factory=dict
60
+ ) # 元数据信息 / Metadata information
44
61
  request_id: Optional[str] = None # 请求ID / Request identifier
45
62
  timeout: Optional[int] = None # 超时时间(秒) / Timeout duration (seconds)
46
- created_at: Optional[datetime] = None # 将在请求创建时设置 / Will be set when request is created
63
+ created_at: Optional[
64
+ datetime
65
+ ] = None # 将在请求创建时设置 / Will be set when request is created
66
+
47
67
 
48
68
  @dataclass
49
69
  class HumanLoopResult:
50
70
  """人机循环结果的数据模型 / Human loop result data model"""
71
+
51
72
  conversation_id: str # 用于关联多轮对话 / Used to associate multi-turn conversations
52
73
  request_id: str # 请求ID / Request identifier
53
74
  loop_type: HumanLoopType # 循环类型 / Loop type
54
75
  status: HumanLoopStatus # 循环状态 / Loop status
55
- response: Dict[str, Any] = field(default_factory=dict) # 人类提供的响应数据 / Response data provided by human
56
- feedback: Dict[str, Any] = field(default_factory=dict) # 反馈信息 / Feedback information
76
+ response: Dict[str, Any] = field(
77
+ default_factory=dict
78
+ ) # 人类提供的响应数据 / Response data provided by human
79
+ feedback: Dict[str, Any] = field(
80
+ default_factory=dict
81
+ ) # 反馈信息 / Feedback information
57
82
  responded_by: Optional[str] = None # 响应者 / Responder
58
83
  responded_at: Optional[str] = None # 响应时间 / Response time
59
84
  error: Optional[str] = None # 错误信息 / Error message
60
85
 
86
+
61
87
  @runtime_checkable
62
88
  class HumanLoopProvider(Protocol):
63
89
  """Human-in-the-loop Provider Protocol"""
64
-
90
+
65
91
  name: str # 提供者名称
66
92
 
67
93
  @abstractmethod
@@ -72,10 +98,10 @@ class HumanLoopProvider(Protocol):
72
98
  loop_type: HumanLoopType,
73
99
  context: Dict[str, Any],
74
100
  metadata: Optional[Dict[str, Any]] = None,
75
- timeout: Optional[int] = None
101
+ timeout: Optional[int] = None,
76
102
  ) -> HumanLoopResult:
77
103
  """请求人机循环
78
-
104
+
79
105
  Args:
80
106
  task_id: 任务标识符
81
107
  conversation_id: 对话ID,用于多轮对话
@@ -83,12 +109,12 @@ class HumanLoopProvider(Protocol):
83
109
  context: 提供给人类的上下文信息
84
110
  metadata: 附加元数据
85
111
  timeout: 请求超时时间(秒)
86
-
112
+
87
113
  Returns:
88
114
  HumanLoopResult: 包含请求ID和初始状态的结果对象
89
115
  """
90
116
  pass
91
-
117
+
92
118
  @abstractmethod
93
119
  def request_humanloop(
94
120
  self,
@@ -97,10 +123,10 @@ class HumanLoopProvider(Protocol):
97
123
  loop_type: HumanLoopType,
98
124
  context: Dict[str, Any],
99
125
  metadata: Optional[Dict[str, Any]] = None,
100
- timeout: Optional[int] = None
126
+ timeout: Optional[int] = None,
101
127
  ) -> HumanLoopResult:
102
128
  """请求人机循环(同步版本)
103
-
129
+
104
130
  Args:
105
131
  task_id: 任务标识符
106
132
  conversation_id: 对话ID,用于多轮对话
@@ -108,7 +134,7 @@ class HumanLoopProvider(Protocol):
108
134
  context: 提供给人类的上下文信息
109
135
  metadata: 附加元数据
110
136
  timeout: 请求超时时间(秒)
111
-
137
+
112
138
  Returns:
113
139
  HumanLoopResult: 包含请求ID和初始状态的结果对象
114
140
  """
@@ -116,132 +142,110 @@ class HumanLoopProvider(Protocol):
116
142
 
117
143
  @abstractmethod
118
144
  async def async_check_request_status(
119
- self,
120
- conversation_id: str,
121
- request_id: str
145
+ self, conversation_id: str, request_id: str
122
146
  ) -> HumanLoopResult:
123
147
  """检查请求状态
124
-
148
+
125
149
  Args:
126
150
  conversation_id: 对话标识符,用于关联多轮对话
127
151
  request_id: 请求标识符,用于标识具体的交互请求
128
-
152
+
129
153
  Returns:
130
154
  HumanLoopResult: 包含当前请求状态的结果对象,包括状态、响应数据等信息
131
155
  """
132
156
  pass
133
-
157
+
134
158
  @abstractmethod
135
159
  def check_request_status(
136
- self,
137
- conversation_id: str,
138
- request_id: str
160
+ self, conversation_id: str, request_id: str
139
161
  ) -> HumanLoopResult:
140
162
  """检查请求状态(同步版本)
141
-
163
+
142
164
  Args:
143
165
  conversation_id: 对话标识符,用于关联多轮对话
144
166
  request_id: 请求标识符,用于标识具体的交互请求
145
-
167
+
146
168
  Returns:
147
169
  HumanLoopResult: 包含当前请求状态的结果对象,包括状态、响应数据等信息
148
170
  """
149
171
  pass
150
-
172
+
151
173
  @abstractmethod
152
174
  async def async_check_conversation_status(
153
- self,
154
- conversation_id: str
175
+ self, conversation_id: str
155
176
  ) -> HumanLoopResult:
156
177
  """检查对话状态
157
-
178
+
158
179
  Args:
159
180
  conversation_id: 对话标识符
160
-
181
+
161
182
  Returns:
162
183
  HumanLoopResult: 包含对话最新请求的状态
163
184
  """
164
185
  pass
165
-
186
+
166
187
  @abstractmethod
167
- def check_conversation_status(
168
- self,
169
- conversation_id: str
170
- ) -> HumanLoopResult:
188
+ def check_conversation_status(self, conversation_id: str) -> HumanLoopResult:
171
189
  """检查对话状态(同步版本)
172
-
190
+
173
191
  Args:
174
192
  conversation_id: 对话标识符
175
-
193
+
176
194
  Returns:
177
195
  HumanLoopResult: 包含对话最新请求的状态
178
196
  """
179
197
  pass
180
-
198
+
181
199
  @abstractmethod
182
- async def async_cancel_request(
183
- self,
184
- conversation_id: str,
185
- request_id: str
186
- ) -> bool:
200
+ async def async_cancel_request(self, conversation_id: str, request_id: str) -> bool:
187
201
  """取消人机循环请求
188
-
202
+
189
203
  Args:
190
204
  conversation_id: 对话标识符,用于关联多轮对话
191
205
  request_id: 请求标识符,用于标识具体的交互请求
192
-
206
+
193
207
  Returns:
194
208
  bool: 取消是否成功,True表示取消成功,False表示取消失败
195
209
  """
196
210
  pass
197
-
211
+
198
212
  @abstractmethod
199
- def cancel_request(
200
- self,
201
- conversation_id: str,
202
- request_id: str
203
- ) -> bool:
213
+ def cancel_request(self, conversation_id: str, request_id: str) -> bool:
204
214
  """取消人机循环请求(同步版本)
205
-
215
+
206
216
  Args:
207
217
  conversation_id: 对话标识符,用于关联多轮对话
208
218
  request_id: 请求标识符,用于标识具体的交互请求
209
-
219
+
210
220
  Returns:
211
221
  bool: 取消是否成功,True表示取消成功,False表示取消失败
212
222
  """
213
223
  pass
214
-
224
+
215
225
  @abstractmethod
216
- async def async_cancel_conversation(
217
- self,
218
- conversation_id: str
219
- ) -> bool:
226
+ async def async_cancel_conversation(self, conversation_id: str) -> bool:
220
227
  """取消整个对话
221
-
228
+
222
229
  Args:
223
230
  conversation_id: 对话标识符
224
-
231
+
225
232
  Returns:
226
233
  bool: 取消是否成功
227
234
  """
228
235
  pass
229
-
236
+
230
237
  @abstractmethod
231
- def cancel_conversation(
232
- self,
233
- conversation_id: str
234
- ) -> bool:
238
+ def cancel_conversation(self, conversation_id: str) -> bool:
235
239
  """取消整个对话(同步版本)
236
-
240
+
237
241
  Args:
238
242
  conversation_id: 对话标识符
239
-
243
+
240
244
  Returns:
241
245
  bool: 取消是否成功
242
246
  """
243
247
  pass
244
-
248
+
245
249
  @abstractmethod
246
250
  async def async_continue_humanloop(
247
251
  self,
@@ -251,18 +255,18 @@ class HumanLoopProvider(Protocol):
251
255
  timeout: Optional[int] = None,
252
256
  ) -> HumanLoopResult:
253
257
  """继续人机循环
254
-
258
+
255
259
  Args:
256
260
  conversation_id: 对话ID,用于多轮对话
257
261
  context: 提供给人类的上下文信息
258
262
  metadata: 附加元数据
259
263
  timeout: 请求超时时间(秒)
260
-
264
+
261
265
  Returns:
262
266
  HumanLoopResult: 包含请求ID和状态的结果对象
263
267
  """
264
268
  pass
265
-
269
+
266
270
  @abstractmethod
267
271
  def continue_humanloop(
268
272
  self,
@@ -272,101 +276,103 @@ class HumanLoopProvider(Protocol):
272
276
  timeout: Optional[int] = None,
273
277
  ) -> HumanLoopResult:
274
278
  """继续人机循环(同步版本)
275
-
279
+
276
280
  Args:
277
281
  conversation_id: 对话ID,用于多轮对话
278
282
  context: 提供给人类的上下文信息
279
283
  metadata: 附加元数据
280
284
  timeout: 请求超时时间(秒)
281
-
285
+
282
286
  Returns:
283
287
  HumanLoopResult: 包含请求ID和状态的结果对象
284
288
  """
285
289
  pass
286
290
 
291
+
287
292
  class HumanLoopCallback(ABC):
288
293
  """人机循环回调的抽象类"""
289
-
294
+
295
+ @abstractmethod
296
+ async def async_on_humanloop_request(
297
+ self, provider: HumanLoopProvider, request: HumanLoopRequest
298
+ ) -> Any:
299
+ """当人机循环请求开始时的回调
300
+
301
+ Args:
302
+ provider: 人机循环提供者实例
303
+ request: 循环请求
304
+ """
305
+ pass
306
+
290
307
  @abstractmethod
291
308
  async def async_on_humanloop_update(
292
- self,
293
- provider: HumanLoopProvider,
294
- result: HumanLoopResult
295
- ):
309
+ self, provider: HumanLoopProvider, result: HumanLoopResult
310
+ ) -> Any:
296
311
  """当请求更新时的回调
297
-
312
+
298
313
  Args:
299
314
  provider: 人机循环提供者实例
300
315
  result: 循环结果
301
316
  """
302
317
  pass
303
-
304
-
318
+
305
319
  @abstractmethod
306
320
  async def async_on_humanloop_timeout(
307
- self,
308
- provider: HumanLoopProvider,
309
- ):
321
+ self, provider: HumanLoopProvider, result: HumanLoopResult
322
+ ) -> Any:
310
323
  """当请求超时时的回调
311
-
324
+
312
325
  Args:
313
326
  provider: 人机循环提供者实例
314
327
  """
315
328
  pass
316
-
317
-
329
+
318
330
  @abstractmethod
319
331
  async def async_on_humanloop_error(
320
- self,
321
- provider: HumanLoopProvider,
322
- error: Exception
323
- ):
332
+ self, provider: HumanLoopProvider, error: Exception
333
+ ) -> Any:
324
334
  """当请求发生错误时的回调
325
-
335
+
326
336
  Args:
327
337
  provider: 人机循环提供者实例
328
338
  error: 错误信息
329
339
  """
330
340
  pass
331
-
341
+
332
342
 
333
343
  class HumanLoopManager(ABC):
334
344
  """人机循环管理器的抽象类"""
335
-
345
+
336
346
  @abstractmethod
337
347
  async def async_register_provider(
338
- self,
339
- provider: HumanLoopProvider,
340
- provider_id: Optional[str] = None
348
+ self, provider: HumanLoopProvider, provider_id: Optional[str] = None
341
349
  ) -> str:
342
350
  """注册人机循环提供者
343
-
351
+
344
352
  Args:
345
353
  provider: 人机循环提供者实例
346
354
  provider_id: 提供者标识符(可选)
347
-
355
+
348
356
  Returns:
349
357
  str: 注册成功后的提供者ID
350
358
  """
351
359
  pass
352
-
360
+
353
361
  @abstractmethod
354
362
  def register_provider(
355
- self,
356
- provider: HumanLoopProvider,
357
- provider_id: Optional[str] = None
363
+ self, provider: HumanLoopProvider, provider_id: Optional[str] = None
358
364
  ) -> str:
359
365
  """注册人机循环提供者(同步版本)
360
-
366
+
361
367
  Args:
362
368
  provider: 人机循环提供者实例
363
369
  provider_id: 提供者标识符(可选)
364
-
370
+
365
371
  Returns:
366
372
  str: 注册成功后的提供者ID
367
373
  """
368
374
  pass
369
-
375
+
370
376
  @abstractmethod
371
377
  async def async_request_humanloop(
372
378
  self,
@@ -381,7 +387,7 @@ class HumanLoopManager(ABC):
381
387
  blocking: bool = False,
382
388
  ) -> Union[str, HumanLoopResult]:
383
389
  """请求人机循环
384
-
390
+
385
391
  Args:
386
392
  task_id: 任务标识符
387
393
  conversation_id: 对话ID,用于多轮对话
@@ -392,12 +398,12 @@ class HumanLoopManager(ABC):
392
398
  provider_id: 使用特定提供者的ID(可选)
393
399
  timeout: 请求超时时间(秒)
394
400
  blocking: 是否阻塞等待结果
395
-
401
+
396
402
  Returns:
397
403
  Union[str, HumanLoopResult]: 如果blocking=False,返回请求ID;否则返回循环结果
398
404
  """
399
405
  pass
400
-
406
+
401
407
  @abstractmethod
402
408
  def request_humanloop(
403
409
  self,
@@ -412,7 +418,7 @@ class HumanLoopManager(ABC):
412
418
  blocking: bool = False,
413
419
  ) -> Union[str, HumanLoopResult]:
414
420
  """请求人机循环(同步版本)
415
-
421
+
416
422
  Args:
417
423
  task_id: 任务标识符
418
424
  conversation_id: 对话ID,用于多轮对话
@@ -423,12 +429,12 @@ class HumanLoopManager(ABC):
423
429
  provider_id: 使用特定提供者的ID(可选)
424
430
  timeout: 请求超时时间(秒)
425
431
  blocking: 是否阻塞等待结果
426
-
432
+
427
433
  Returns:
428
434
  Union[str, HumanLoopResult]: 如果blocking=False,返回请求ID;否则返回循环结果
429
435
  """
430
436
  pass
431
-
437
+
432
438
  @abstractmethod
433
439
  async def async_continue_humanloop(
434
440
  self,
@@ -441,7 +447,7 @@ class HumanLoopManager(ABC):
441
447
  blocking: bool = False,
442
448
  ) -> Union[str, HumanLoopResult]:
443
449
  """继续人机循环
444
-
450
+
445
451
  Args:
446
452
  conversation_id: 对话ID,用于多轮对话
447
453
  context: 提供给人类的上下文信息
@@ -450,12 +456,12 @@ class HumanLoopManager(ABC):
450
456
  provider_id: 使用特定提供者的ID(可选)
451
457
  timeout: 请求超时时间(秒)
452
458
  blocking: 是否阻塞等待结果
453
-
459
+
454
460
  Returns:
455
461
  Union[str, HumanLoopResult]: 如果blocking=False,返回请求ID;否则返回循环结果
456
462
  """
457
463
  pass
458
-
464
+
459
465
  @abstractmethod
460
466
  def continue_humanloop(
461
467
  self,
@@ -468,7 +474,7 @@ class HumanLoopManager(ABC):
468
474
  blocking: bool = False,
469
475
  ) -> Union[str, HumanLoopResult]:
470
476
  """继续人机循环(同步版本)
471
-
477
+
472
478
  Args:
473
479
  conversation_id: 对话ID,用于多轮对话
474
480
  context: 提供给人类的上下文信息
@@ -477,241 +483,211 @@ class HumanLoopManager(ABC):
477
483
  provider_id: 使用特定提供者的ID(可选)
478
484
  timeout: 请求超时时间(秒)
479
485
  blocking: 是否阻塞等待结果
480
-
486
+
481
487
  Returns:
482
488
  Union[str, HumanLoopResult]: 如果blocking=False,返回请求ID;否则返回循环结果
483
489
  """
484
490
  pass
485
-
491
+
486
492
  @abstractmethod
487
493
  async def async_check_request_status(
488
- self,
489
- conversation_id: str,
490
- request_id: str,
491
- provider_id: Optional[str] = None
494
+ self, conversation_id: str, request_id: str, provider_id: Optional[str] = None
492
495
  ) -> HumanLoopResult:
493
496
  """检查请求状态
494
-
497
+
495
498
  Args:
496
499
  conversation_id: 对话标识符
497
500
  request_id: 请求标识符
498
501
  provider_id: 使用特定提供者的ID(可选)
499
-
502
+
500
503
  Returns:
501
504
  HumanLoopResult: 包含当前请求状态的结果对象
502
505
  """
503
506
  pass
504
-
507
+
505
508
  @abstractmethod
506
509
  def check_request_status(
507
- self,
508
- conversation_id: str,
509
- request_id: str,
510
- provider_id: Optional[str] = None
510
+ self, conversation_id: str, request_id: str, provider_id: Optional[str] = None
511
511
  ) -> HumanLoopResult:
512
512
  """检查请求状态(同步版本)
513
-
513
+
514
514
  Args:
515
515
  conversation_id: 对话标识符
516
516
  request_id: 请求标识符
517
517
  provider_id: 使用特定提供者的ID(可选)
518
-
518
+
519
519
  Returns:
520
520
  HumanLoopResult: 包含当前请求状态的结果对象
521
521
  """
522
522
  pass
523
-
523
+
524
524
  @abstractmethod
525
525
  async def async_check_conversation_status(
526
- self,
527
- conversation_id: str,
528
- provider_id: Optional[str] = None
526
+ self, conversation_id: str, provider_id: Optional[str] = None
529
527
  ) -> HumanLoopResult:
530
528
  """检查对话状态
531
-
529
+
532
530
  Args:
533
531
  conversation_id: 对话标识符
534
532
  provider_id: 使用特定提供者的ID(可选)
535
-
533
+
536
534
  Returns:
537
535
  HumanLoopResult: 包含对话最新请求的状态
538
536
  """
539
537
  pass
540
-
538
+
541
539
  @abstractmethod
542
540
  def check_conversation_status(
543
- self,
544
- conversation_id: str,
545
- provider_id: Optional[str] = None
541
+ self, conversation_id: str, provider_id: Optional[str] = None
546
542
  ) -> HumanLoopResult:
547
543
  """检查对话状态(同步版本)
548
-
544
+
549
545
  Args:
550
546
  conversation_id: 对话标识符
551
547
  provider_id: 使用特定提供者的ID(可选)
552
-
548
+
553
549
  Returns:
554
550
  HumanLoopResult: 包含对话最新请求的状态
555
551
  """
556
552
  pass
557
-
553
+
558
554
  @abstractmethod
559
555
  async def async_cancel_request(
560
- self,
561
- conversation_id: str,
562
- request_id: str,
563
- provider_id: Optional[str] = None
556
+ self, conversation_id: str, request_id: str, provider_id: Optional[str] = None
564
557
  ) -> bool:
565
558
  """取消特定请求
566
-
559
+
567
560
  Args:
568
561
  conversation_id: 对话标识符
569
562
  request_id: 请求标识符
570
563
  provider_id: 使用特定提供者的ID(可选)
571
-
564
+
572
565
  Returns:
573
566
  bool: 取消是否成功
574
567
  """
575
568
  pass
576
-
569
+
577
570
  @abstractmethod
578
571
  def cancel_request(
579
- self,
580
- conversation_id: str,
581
- request_id: str,
582
- provider_id: Optional[str] = None
572
+ self, conversation_id: str, request_id: str, provider_id: Optional[str] = None
583
573
  ) -> bool:
584
574
  """取消特定请求(同步版本)
585
-
575
+
586
576
  Args:
587
577
  conversation_id: 对话标识符
588
578
  request_id: 请求标识符
589
579
  provider_id: 使用特定提供者的ID(可选)
590
-
580
+
591
581
  Returns:
592
582
  bool: 取消是否成功
593
583
  """
594
584
  pass
595
-
585
+
596
586
  @abstractmethod
597
587
  async def async_cancel_conversation(
598
- self,
599
- conversation_id: str,
600
- provider_id: Optional[str] = None
588
+ self, conversation_id: str, provider_id: Optional[str] = None
601
589
  ) -> bool:
602
590
  """取消整个对话
603
-
591
+
604
592
  Args:
605
593
  conversation_id: 对话标识符
606
594
  provider_id: 使用特定提供者的ID(可选)
607
-
595
+
608
596
  Returns:
609
597
  bool: 取消是否成功
610
598
  """
611
599
  pass
612
-
600
+
613
601
  @abstractmethod
614
602
  def cancel_conversation(
615
- self,
616
- conversation_id: str,
617
- provider_id: Optional[str] = None
603
+ self, conversation_id: str, provider_id: Optional[str] = None
618
604
  ) -> bool:
619
605
  """取消整个对话(同步版本)
620
-
606
+
621
607
  Args:
622
608
  conversation_id: 对话标识符
623
609
  provider_id: 使用特定提供者的ID(可选)
624
-
610
+
625
611
  Returns:
626
612
  bool: 取消是否成功
627
613
  """
628
614
  pass
629
-
615
+
630
616
  @abstractmethod
631
617
  async def async_get_provider(
632
- self,
633
- provider_id: Optional[str] = None
618
+ self, provider_id: Optional[str] = None
634
619
  ) -> HumanLoopProvider:
635
620
  """获取指定的提供者实例
636
-
621
+
637
622
  Args:
638
623
  provider_id: 提供者ID,如果为None则返回默认提供者
639
-
624
+
640
625
  Returns:
641
626
  HumanLoopProvider: 提供者实例
642
-
627
+
643
628
  Raises:
644
629
  ValueError: 如果指定的提供者不存在
645
630
  """
646
631
  pass
647
-
632
+
648
633
  @abstractmethod
649
- def get_provider(
650
- self,
651
- provider_id: Optional[str] = None
652
- ) -> HumanLoopProvider:
634
+ def get_provider(self, provider_id: Optional[str] = None) -> HumanLoopProvider:
653
635
  """获取指定的提供者实例(同步版本)
654
-
636
+
655
637
  Args:
656
638
  provider_id: 提供者ID,如果为None则返回默认提供者
657
-
639
+
658
640
  Returns:
659
641
  HumanLoopProvider: 提供者实例
660
-
642
+
661
643
  Raises:
662
644
  ValueError: 如果指定的提供者不存在
663
645
  """
664
646
  pass
665
-
647
+
666
648
  @abstractmethod
667
649
  async def async_list_providers(self) -> Dict[str, HumanLoopProvider]:
668
650
  """列出所有注册的提供者
669
-
651
+
670
652
  Returns:
671
653
  Dict[str, HumanLoopProvider]: 提供者ID到提供者实例的映射
672
654
  """
673
655
  pass
674
-
656
+
675
657
  @abstractmethod
676
658
  def list_providers(self) -> Dict[str, HumanLoopProvider]:
677
659
  """列出所有注册的提供者(同步版本)
678
-
660
+
679
661
  Returns:
680
662
  Dict[str, HumanLoopProvider]: 提供者ID到提供者实例的映射
681
663
  """
682
664
  pass
683
-
665
+
684
666
  @abstractmethod
685
- async def async_set_default_provider(
686
- self,
687
- provider_id: str
688
- ) -> bool:
667
+ async def async_set_default_provider(self, provider_id: str) -> bool:
689
668
  """设置默认提供者
690
-
669
+
691
670
  Args:
692
671
  provider_id: 提供者ID
693
-
672
+
694
673
  Returns:
695
674
  bool: 设置是否成功
696
-
675
+
697
676
  Raises:
698
677
  ValueError: 如果指定的提供者不存在
699
678
  """
700
679
  pass
701
-
680
+
702
681
  @abstractmethod
703
- def set_default_provider(
704
- self,
705
- provider_id: str
706
- ) -> bool:
682
+ def set_default_provider(self, provider_id: str) -> bool:
707
683
  """设置默认提供者(同步版本)
708
-
684
+
709
685
  Args:
710
686
  provider_id: 提供者ID
711
-
687
+
712
688
  Returns:
713
689
  bool: 设置是否成功
714
-
690
+
715
691
  Raises:
716
692
  ValueError: 如果指定的提供者不存在
717
693
  """
@@ -722,37 +698,38 @@ class HumanLoopManager(ABC):
722
698
  self,
723
699
  task_id: str,
724
700
  conversation_id: str,
725
- ) -> HumanLoopResult:
726
- """检查对话状态
727
-
701
+ ) -> bool:
702
+ """检查对话是否存在
703
+
728
704
  Args:
729
- conversation_id: 对话标识符
705
+ task_id: 任务标识符,用于标识业务任务
706
+ conversation_id: 对话标识符,用于标识具体对话会话
730
707
  Returns:
731
- HumanLoopResult: 包含对话最新请求的状态
708
+ bool: 如果对话存在返回True,否则返回False
732
709
  """
733
710
  pass
734
-
711
+
735
712
  @abstractmethod
736
713
  def check_conversation_exist(
737
714
  self,
738
715
  task_id: str,
739
716
  conversation_id: str,
740
- ) -> HumanLoopResult:
717
+ ) -> bool:
741
718
  """检查对话状态(同步版本)
742
-
719
+
743
720
  Args:
744
721
  conversation_id: 对话标识符
745
722
  Returns:
746
- HumanLoopResult: 包含对话最新请求的状态
723
+ bool: 如果对话存在返回True,否则返回False
747
724
  """
748
725
  pass
749
726
 
750
727
  @abstractmethod
751
- async def async_shutdown(self):
728
+ async def async_shutdown(self) -> None:
752
729
  """关闭管理器(异步方法)"""
753
730
  pass
754
731
 
755
732
  @abstractmethod
756
- def shutdown(self):
733
+ def shutdown(self) -> None:
757
734
  """关闭管理器(同步方法)"""
758
- pass
735
+ pass