gohumanloop 0.0.4__py3-none-any.whl → 0.0.6__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,92 @@ 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
+
290
295
  @abstractmethod
291
296
  async def async_on_humanloop_update(
292
- self,
293
- provider: HumanLoopProvider,
294
- result: HumanLoopResult
295
- ):
297
+ self, provider: HumanLoopProvider, result: HumanLoopResult
298
+ ) -> None:
296
299
  """当请求更新时的回调
297
-
300
+
298
301
  Args:
299
302
  provider: 人机循环提供者实例
300
303
  result: 循环结果
301
304
  """
302
305
  pass
303
-
304
-
306
+
305
307
  @abstractmethod
306
308
  async def async_on_humanloop_timeout(
307
309
  self,
308
310
  provider: HumanLoopProvider,
309
- ):
311
+ ) -> None:
310
312
  """当请求超时时的回调
311
-
313
+
312
314
  Args:
313
315
  provider: 人机循环提供者实例
314
316
  """
315
317
  pass
316
-
317
-
318
+
318
319
  @abstractmethod
319
320
  async def async_on_humanloop_error(
320
- self,
321
- provider: HumanLoopProvider,
322
- error: Exception
323
- ):
321
+ self, provider: HumanLoopProvider, error: Exception
322
+ ) -> None:
324
323
  """当请求发生错误时的回调
325
-
324
+
326
325
  Args:
327
326
  provider: 人机循环提供者实例
328
327
  error: 错误信息
329
328
  """
330
329
  pass
331
-
330
+
332
331
 
333
332
  class HumanLoopManager(ABC):
334
333
  """人机循环管理器的抽象类"""
335
-
334
+
336
335
  @abstractmethod
337
336
  async def async_register_provider(
338
- self,
339
- provider: HumanLoopProvider,
340
- provider_id: Optional[str] = None
337
+ self, provider: HumanLoopProvider, provider_id: Optional[str] = None
341
338
  ) -> str:
342
339
  """注册人机循环提供者
343
-
340
+
344
341
  Args:
345
342
  provider: 人机循环提供者实例
346
343
  provider_id: 提供者标识符(可选)
347
-
344
+
348
345
  Returns:
349
346
  str: 注册成功后的提供者ID
350
347
  """
351
348
  pass
352
-
349
+
353
350
  @abstractmethod
354
351
  def register_provider(
355
- self,
356
- provider: HumanLoopProvider,
357
- provider_id: Optional[str] = None
352
+ self, provider: HumanLoopProvider, provider_id: Optional[str] = None
358
353
  ) -> str:
359
354
  """注册人机循环提供者(同步版本)
360
-
355
+
361
356
  Args:
362
357
  provider: 人机循环提供者实例
363
358
  provider_id: 提供者标识符(可选)
364
-
359
+
365
360
  Returns:
366
361
  str: 注册成功后的提供者ID
367
362
  """
368
363
  pass
369
-
364
+
370
365
  @abstractmethod
371
366
  async def async_request_humanloop(
372
367
  self,
@@ -381,7 +376,7 @@ class HumanLoopManager(ABC):
381
376
  blocking: bool = False,
382
377
  ) -> Union[str, HumanLoopResult]:
383
378
  """请求人机循环
384
-
379
+
385
380
  Args:
386
381
  task_id: 任务标识符
387
382
  conversation_id: 对话ID,用于多轮对话
@@ -392,12 +387,12 @@ class HumanLoopManager(ABC):
392
387
  provider_id: 使用特定提供者的ID(可选)
393
388
  timeout: 请求超时时间(秒)
394
389
  blocking: 是否阻塞等待结果
395
-
390
+
396
391
  Returns:
397
392
  Union[str, HumanLoopResult]: 如果blocking=False,返回请求ID;否则返回循环结果
398
393
  """
399
394
  pass
400
-
395
+
401
396
  @abstractmethod
402
397
  def request_humanloop(
403
398
  self,
@@ -412,7 +407,7 @@ class HumanLoopManager(ABC):
412
407
  blocking: bool = False,
413
408
  ) -> Union[str, HumanLoopResult]:
414
409
  """请求人机循环(同步版本)
415
-
410
+
416
411
  Args:
417
412
  task_id: 任务标识符
418
413
  conversation_id: 对话ID,用于多轮对话
@@ -423,12 +418,12 @@ class HumanLoopManager(ABC):
423
418
  provider_id: 使用特定提供者的ID(可选)
424
419
  timeout: 请求超时时间(秒)
425
420
  blocking: 是否阻塞等待结果
426
-
421
+
427
422
  Returns:
428
423
  Union[str, HumanLoopResult]: 如果blocking=False,返回请求ID;否则返回循环结果
429
424
  """
430
425
  pass
431
-
426
+
432
427
  @abstractmethod
433
428
  async def async_continue_humanloop(
434
429
  self,
@@ -441,7 +436,7 @@ class HumanLoopManager(ABC):
441
436
  blocking: bool = False,
442
437
  ) -> Union[str, HumanLoopResult]:
443
438
  """继续人机循环
444
-
439
+
445
440
  Args:
446
441
  conversation_id: 对话ID,用于多轮对话
447
442
  context: 提供给人类的上下文信息
@@ -450,12 +445,12 @@ class HumanLoopManager(ABC):
450
445
  provider_id: 使用特定提供者的ID(可选)
451
446
  timeout: 请求超时时间(秒)
452
447
  blocking: 是否阻塞等待结果
453
-
448
+
454
449
  Returns:
455
450
  Union[str, HumanLoopResult]: 如果blocking=False,返回请求ID;否则返回循环结果
456
451
  """
457
452
  pass
458
-
453
+
459
454
  @abstractmethod
460
455
  def continue_humanloop(
461
456
  self,
@@ -468,7 +463,7 @@ class HumanLoopManager(ABC):
468
463
  blocking: bool = False,
469
464
  ) -> Union[str, HumanLoopResult]:
470
465
  """继续人机循环(同步版本)
471
-
466
+
472
467
  Args:
473
468
  conversation_id: 对话ID,用于多轮对话
474
469
  context: 提供给人类的上下文信息
@@ -477,241 +472,211 @@ class HumanLoopManager(ABC):
477
472
  provider_id: 使用特定提供者的ID(可选)
478
473
  timeout: 请求超时时间(秒)
479
474
  blocking: 是否阻塞等待结果
480
-
475
+
481
476
  Returns:
482
477
  Union[str, HumanLoopResult]: 如果blocking=False,返回请求ID;否则返回循环结果
483
478
  """
484
479
  pass
485
-
480
+
486
481
  @abstractmethod
487
482
  async def async_check_request_status(
488
- self,
489
- conversation_id: str,
490
- request_id: str,
491
- provider_id: Optional[str] = None
483
+ self, conversation_id: str, request_id: str, provider_id: Optional[str] = None
492
484
  ) -> HumanLoopResult:
493
485
  """检查请求状态
494
-
486
+
495
487
  Args:
496
488
  conversation_id: 对话标识符
497
489
  request_id: 请求标识符
498
490
  provider_id: 使用特定提供者的ID(可选)
499
-
491
+
500
492
  Returns:
501
493
  HumanLoopResult: 包含当前请求状态的结果对象
502
494
  """
503
495
  pass
504
-
496
+
505
497
  @abstractmethod
506
498
  def check_request_status(
507
- self,
508
- conversation_id: str,
509
- request_id: str,
510
- provider_id: Optional[str] = None
499
+ self, conversation_id: str, request_id: str, provider_id: Optional[str] = None
511
500
  ) -> HumanLoopResult:
512
501
  """检查请求状态(同步版本)
513
-
502
+
514
503
  Args:
515
504
  conversation_id: 对话标识符
516
505
  request_id: 请求标识符
517
506
  provider_id: 使用特定提供者的ID(可选)
518
-
507
+
519
508
  Returns:
520
509
  HumanLoopResult: 包含当前请求状态的结果对象
521
510
  """
522
511
  pass
523
-
512
+
524
513
  @abstractmethod
525
514
  async def async_check_conversation_status(
526
- self,
527
- conversation_id: str,
528
- provider_id: Optional[str] = None
515
+ self, conversation_id: str, provider_id: Optional[str] = None
529
516
  ) -> HumanLoopResult:
530
517
  """检查对话状态
531
-
518
+
532
519
  Args:
533
520
  conversation_id: 对话标识符
534
521
  provider_id: 使用特定提供者的ID(可选)
535
-
522
+
536
523
  Returns:
537
524
  HumanLoopResult: 包含对话最新请求的状态
538
525
  """
539
526
  pass
540
-
527
+
541
528
  @abstractmethod
542
529
  def check_conversation_status(
543
- self,
544
- conversation_id: str,
545
- provider_id: Optional[str] = None
530
+ self, conversation_id: str, provider_id: Optional[str] = None
546
531
  ) -> HumanLoopResult:
547
532
  """检查对话状态(同步版本)
548
-
533
+
549
534
  Args:
550
535
  conversation_id: 对话标识符
551
536
  provider_id: 使用特定提供者的ID(可选)
552
-
537
+
553
538
  Returns:
554
539
  HumanLoopResult: 包含对话最新请求的状态
555
540
  """
556
541
  pass
557
-
542
+
558
543
  @abstractmethod
559
544
  async def async_cancel_request(
560
- self,
561
- conversation_id: str,
562
- request_id: str,
563
- provider_id: Optional[str] = None
545
+ self, conversation_id: str, request_id: str, provider_id: Optional[str] = None
564
546
  ) -> bool:
565
547
  """取消特定请求
566
-
548
+
567
549
  Args:
568
550
  conversation_id: 对话标识符
569
551
  request_id: 请求标识符
570
552
  provider_id: 使用特定提供者的ID(可选)
571
-
553
+
572
554
  Returns:
573
555
  bool: 取消是否成功
574
556
  """
575
557
  pass
576
-
558
+
577
559
  @abstractmethod
578
560
  def cancel_request(
579
- self,
580
- conversation_id: str,
581
- request_id: str,
582
- provider_id: Optional[str] = None
561
+ self, conversation_id: str, request_id: str, provider_id: Optional[str] = None
583
562
  ) -> bool:
584
563
  """取消特定请求(同步版本)
585
-
564
+
586
565
  Args:
587
566
  conversation_id: 对话标识符
588
567
  request_id: 请求标识符
589
568
  provider_id: 使用特定提供者的ID(可选)
590
-
569
+
591
570
  Returns:
592
571
  bool: 取消是否成功
593
572
  """
594
573
  pass
595
-
574
+
596
575
  @abstractmethod
597
576
  async def async_cancel_conversation(
598
- self,
599
- conversation_id: str,
600
- provider_id: Optional[str] = None
577
+ self, conversation_id: str, provider_id: Optional[str] = None
601
578
  ) -> bool:
602
579
  """取消整个对话
603
-
580
+
604
581
  Args:
605
582
  conversation_id: 对话标识符
606
583
  provider_id: 使用特定提供者的ID(可选)
607
-
584
+
608
585
  Returns:
609
586
  bool: 取消是否成功
610
587
  """
611
588
  pass
612
-
589
+
613
590
  @abstractmethod
614
591
  def cancel_conversation(
615
- self,
616
- conversation_id: str,
617
- provider_id: Optional[str] = None
592
+ self, conversation_id: str, provider_id: Optional[str] = None
618
593
  ) -> bool:
619
594
  """取消整个对话(同步版本)
620
-
595
+
621
596
  Args:
622
597
  conversation_id: 对话标识符
623
598
  provider_id: 使用特定提供者的ID(可选)
624
-
599
+
625
600
  Returns:
626
601
  bool: 取消是否成功
627
602
  """
628
603
  pass
629
-
604
+
630
605
  @abstractmethod
631
606
  async def async_get_provider(
632
- self,
633
- provider_id: Optional[str] = None
607
+ self, provider_id: Optional[str] = None
634
608
  ) -> HumanLoopProvider:
635
609
  """获取指定的提供者实例
636
-
610
+
637
611
  Args:
638
612
  provider_id: 提供者ID,如果为None则返回默认提供者
639
-
613
+
640
614
  Returns:
641
615
  HumanLoopProvider: 提供者实例
642
-
616
+
643
617
  Raises:
644
618
  ValueError: 如果指定的提供者不存在
645
619
  """
646
620
  pass
647
-
621
+
648
622
  @abstractmethod
649
- def get_provider(
650
- self,
651
- provider_id: Optional[str] = None
652
- ) -> HumanLoopProvider:
623
+ def get_provider(self, provider_id: Optional[str] = None) -> HumanLoopProvider:
653
624
  """获取指定的提供者实例(同步版本)
654
-
625
+
655
626
  Args:
656
627
  provider_id: 提供者ID,如果为None则返回默认提供者
657
-
628
+
658
629
  Returns:
659
630
  HumanLoopProvider: 提供者实例
660
-
631
+
661
632
  Raises:
662
633
  ValueError: 如果指定的提供者不存在
663
634
  """
664
635
  pass
665
-
636
+
666
637
  @abstractmethod
667
638
  async def async_list_providers(self) -> Dict[str, HumanLoopProvider]:
668
639
  """列出所有注册的提供者
669
-
640
+
670
641
  Returns:
671
642
  Dict[str, HumanLoopProvider]: 提供者ID到提供者实例的映射
672
643
  """
673
644
  pass
674
-
645
+
675
646
  @abstractmethod
676
647
  def list_providers(self) -> Dict[str, HumanLoopProvider]:
677
648
  """列出所有注册的提供者(同步版本)
678
-
649
+
679
650
  Returns:
680
651
  Dict[str, HumanLoopProvider]: 提供者ID到提供者实例的映射
681
652
  """
682
653
  pass
683
-
654
+
684
655
  @abstractmethod
685
- async def async_set_default_provider(
686
- self,
687
- provider_id: str
688
- ) -> bool:
656
+ async def async_set_default_provider(self, provider_id: str) -> bool:
689
657
  """设置默认提供者
690
-
658
+
691
659
  Args:
692
660
  provider_id: 提供者ID
693
-
661
+
694
662
  Returns:
695
663
  bool: 设置是否成功
696
-
664
+
697
665
  Raises:
698
666
  ValueError: 如果指定的提供者不存在
699
667
  """
700
668
  pass
701
-
669
+
702
670
  @abstractmethod
703
- def set_default_provider(
704
- self,
705
- provider_id: str
706
- ) -> bool:
671
+ def set_default_provider(self, provider_id: str) -> bool:
707
672
  """设置默认提供者(同步版本)
708
-
673
+
709
674
  Args:
710
675
  provider_id: 提供者ID
711
-
676
+
712
677
  Returns:
713
678
  bool: 设置是否成功
714
-
679
+
715
680
  Raises:
716
681
  ValueError: 如果指定的提供者不存在
717
682
  """
@@ -722,37 +687,38 @@ class HumanLoopManager(ABC):
722
687
  self,
723
688
  task_id: str,
724
689
  conversation_id: str,
725
- ) -> HumanLoopResult:
726
- """检查对话状态
727
-
690
+ ) -> bool:
691
+ """检查对话是否存在
692
+
728
693
  Args:
729
- conversation_id: 对话标识符
694
+ task_id: 任务标识符,用于标识业务任务
695
+ conversation_id: 对话标识符,用于标识具体对话会话
730
696
  Returns:
731
- HumanLoopResult: 包含对话最新请求的状态
697
+ bool: 如果对话存在返回True,否则返回False
732
698
  """
733
699
  pass
734
-
700
+
735
701
  @abstractmethod
736
702
  def check_conversation_exist(
737
703
  self,
738
704
  task_id: str,
739
705
  conversation_id: str,
740
- ) -> HumanLoopResult:
706
+ ) -> bool:
741
707
  """检查对话状态(同步版本)
742
-
708
+
743
709
  Args:
744
710
  conversation_id: 对话标识符
745
711
  Returns:
746
- HumanLoopResult: 包含对话最新请求的状态
712
+ bool: 如果对话存在返回True,否则返回False
747
713
  """
748
714
  pass
749
715
 
750
716
  @abstractmethod
751
- async def async_shutdown(self):
717
+ async def async_shutdown(self) -> None:
752
718
  """关闭管理器(异步方法)"""
753
719
  pass
754
720
 
755
721
  @abstractmethod
756
- def shutdown(self):
722
+ def shutdown(self) -> None:
757
723
  """关闭管理器(同步方法)"""
758
- pass
724
+ pass