gohumanloop 0.0.2__py3-none-any.whl → 0.0.3__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.
- gohumanloop/adapters/langgraph_adapter.py +39 -41
- gohumanloop/core/interface.py +342 -21
- gohumanloop/core/manager.py +302 -39
- gohumanloop/manager/ghl_manager.py +22 -22
- gohumanloop/providers/api_provider.py +18 -18
- gohumanloop/providers/base.py +239 -9
- gohumanloop/providers/email_provider.py +15 -15
- gohumanloop/providers/terminal_provider.py +12 -13
- gohumanloop/utils/utils.py +30 -3
- {gohumanloop-0.0.2.dist-info → gohumanloop-0.0.3.dist-info}/METADATA +1 -1
- {gohumanloop-0.0.2.dist-info → gohumanloop-0.0.3.dist-info}/RECORD +15 -15
- {gohumanloop-0.0.2.dist-info → gohumanloop-0.0.3.dist-info}/WHEEL +1 -1
- {gohumanloop-0.0.2.dist-info → gohumanloop-0.0.3.dist-info}/entry_points.txt +0 -0
- {gohumanloop-0.0.2.dist-info → gohumanloop-0.0.3.dist-info}/licenses/LICENSE +0 -0
- {gohumanloop-0.0.2.dist-info → gohumanloop-0.0.3.dist-info}/top_level.txt +0 -0
gohumanloop/core/interface.py
CHANGED
@@ -65,7 +65,7 @@ class HumanLoopProvider(Protocol):
|
|
65
65
|
name: str # 提供者名称
|
66
66
|
|
67
67
|
@abstractmethod
|
68
|
-
async def
|
68
|
+
async def async_request_humanloop(
|
69
69
|
self,
|
70
70
|
task_id: str,
|
71
71
|
conversation_id: str,
|
@@ -88,9 +88,34 @@ class HumanLoopProvider(Protocol):
|
|
88
88
|
HumanLoopResult: 包含请求ID和初始状态的结果对象
|
89
89
|
"""
|
90
90
|
pass
|
91
|
+
|
92
|
+
@abstractmethod
|
93
|
+
def request_humanloop(
|
94
|
+
self,
|
95
|
+
task_id: str,
|
96
|
+
conversation_id: str,
|
97
|
+
loop_type: HumanLoopType,
|
98
|
+
context: Dict[str, Any],
|
99
|
+
metadata: Optional[Dict[str, Any]] = None,
|
100
|
+
timeout: Optional[int] = None
|
101
|
+
) -> HumanLoopResult:
|
102
|
+
"""请求人机循环(同步版本)
|
103
|
+
|
104
|
+
Args:
|
105
|
+
task_id: 任务标识符
|
106
|
+
conversation_id: 对话ID,用于多轮对话
|
107
|
+
loop_type: 循环类型
|
108
|
+
context: 提供给人类的上下文信息
|
109
|
+
metadata: 附加元数据
|
110
|
+
timeout: 请求超时时间(秒)
|
111
|
+
|
112
|
+
Returns:
|
113
|
+
HumanLoopResult: 包含请求ID和初始状态的结果对象
|
114
|
+
"""
|
115
|
+
pass
|
91
116
|
|
92
117
|
@abstractmethod
|
93
|
-
async def
|
118
|
+
async def async_check_request_status(
|
94
119
|
self,
|
95
120
|
conversation_id: str,
|
96
121
|
request_id: str
|
@@ -105,8 +130,26 @@ class HumanLoopProvider(Protocol):
|
|
105
130
|
HumanLoopResult: 包含当前请求状态的结果对象,包括状态、响应数据等信息
|
106
131
|
"""
|
107
132
|
pass
|
133
|
+
|
134
|
+
@abstractmethod
|
135
|
+
def check_request_status(
|
136
|
+
self,
|
137
|
+
conversation_id: str,
|
138
|
+
request_id: str
|
139
|
+
) -> HumanLoopResult:
|
140
|
+
"""检查请求状态(同步版本)
|
141
|
+
|
142
|
+
Args:
|
143
|
+
conversation_id: 对话标识符,用于关联多轮对话
|
144
|
+
request_id: 请求标识符,用于标识具体的交互请求
|
145
|
+
|
146
|
+
Returns:
|
147
|
+
HumanLoopResult: 包含当前请求状态的结果对象,包括状态、响应数据等信息
|
148
|
+
"""
|
149
|
+
pass
|
150
|
+
|
108
151
|
@abstractmethod
|
109
|
-
async def
|
152
|
+
async def async_check_conversation_status(
|
110
153
|
self,
|
111
154
|
conversation_id: str
|
112
155
|
) -> HumanLoopResult:
|
@@ -121,7 +164,22 @@ class HumanLoopProvider(Protocol):
|
|
121
164
|
pass
|
122
165
|
|
123
166
|
@abstractmethod
|
124
|
-
|
167
|
+
def check_conversation_status(
|
168
|
+
self,
|
169
|
+
conversation_id: str
|
170
|
+
) -> HumanLoopResult:
|
171
|
+
"""检查对话状态(同步版本)
|
172
|
+
|
173
|
+
Args:
|
174
|
+
conversation_id: 对话标识符
|
175
|
+
|
176
|
+
Returns:
|
177
|
+
HumanLoopResult: 包含对话最新请求的状态
|
178
|
+
"""
|
179
|
+
pass
|
180
|
+
|
181
|
+
@abstractmethod
|
182
|
+
async def async_cancel_request(
|
125
183
|
self,
|
126
184
|
conversation_id: str,
|
127
185
|
request_id: str
|
@@ -136,9 +194,26 @@ class HumanLoopProvider(Protocol):
|
|
136
194
|
bool: 取消是否成功,True表示取消成功,False表示取消失败
|
137
195
|
"""
|
138
196
|
pass
|
197
|
+
|
198
|
+
@abstractmethod
|
199
|
+
def cancel_request(
|
200
|
+
self,
|
201
|
+
conversation_id: str,
|
202
|
+
request_id: str
|
203
|
+
) -> bool:
|
204
|
+
"""取消人机循环请求(同步版本)
|
205
|
+
|
206
|
+
Args:
|
207
|
+
conversation_id: 对话标识符,用于关联多轮对话
|
208
|
+
request_id: 请求标识符,用于标识具体的交互请求
|
209
|
+
|
210
|
+
Returns:
|
211
|
+
bool: 取消是否成功,True表示取消成功,False表示取消失败
|
212
|
+
"""
|
213
|
+
pass
|
139
214
|
|
140
215
|
@abstractmethod
|
141
|
-
async def
|
216
|
+
async def async_cancel_conversation(
|
142
217
|
self,
|
143
218
|
conversation_id: str
|
144
219
|
) -> bool:
|
@@ -151,9 +226,24 @@ class HumanLoopProvider(Protocol):
|
|
151
226
|
bool: 取消是否成功
|
152
227
|
"""
|
153
228
|
pass
|
229
|
+
|
230
|
+
@abstractmethod
|
231
|
+
def cancel_conversation(
|
232
|
+
self,
|
233
|
+
conversation_id: str
|
234
|
+
) -> bool:
|
235
|
+
"""取消整个对话(同步版本)
|
236
|
+
|
237
|
+
Args:
|
238
|
+
conversation_id: 对话标识符
|
239
|
+
|
240
|
+
Returns:
|
241
|
+
bool: 取消是否成功
|
242
|
+
"""
|
243
|
+
pass
|
154
244
|
|
155
245
|
@abstractmethod
|
156
|
-
async def
|
246
|
+
async def async_continue_humanloop(
|
157
247
|
self,
|
158
248
|
conversation_id: str,
|
159
249
|
context: Dict[str, Any],
|
@@ -172,12 +262,33 @@ class HumanLoopProvider(Protocol):
|
|
172
262
|
HumanLoopResult: 包含请求ID和状态的结果对象
|
173
263
|
"""
|
174
264
|
pass
|
265
|
+
|
266
|
+
@abstractmethod
|
267
|
+
def continue_humanloop(
|
268
|
+
self,
|
269
|
+
conversation_id: str,
|
270
|
+
context: Dict[str, Any],
|
271
|
+
metadata: Optional[Dict[str, Any]] = None,
|
272
|
+
timeout: Optional[int] = None,
|
273
|
+
) -> HumanLoopResult:
|
274
|
+
"""继续人机循环(同步版本)
|
275
|
+
|
276
|
+
Args:
|
277
|
+
conversation_id: 对话ID,用于多轮对话
|
278
|
+
context: 提供给人类的上下文信息
|
279
|
+
metadata: 附加元数据
|
280
|
+
timeout: 请求超时时间(秒)
|
281
|
+
|
282
|
+
Returns:
|
283
|
+
HumanLoopResult: 包含请求ID和状态的结果对象
|
284
|
+
"""
|
285
|
+
pass
|
175
286
|
|
176
287
|
class HumanLoopCallback(ABC):
|
177
288
|
"""人机循环回调的抽象类"""
|
178
289
|
|
179
290
|
@abstractmethod
|
180
|
-
async def
|
291
|
+
async def async_on_humanloop_update(
|
181
292
|
self,
|
182
293
|
provider: HumanLoopProvider,
|
183
294
|
result: HumanLoopResult
|
@@ -190,8 +301,9 @@ class HumanLoopCallback(ABC):
|
|
190
301
|
"""
|
191
302
|
pass
|
192
303
|
|
304
|
+
|
193
305
|
@abstractmethod
|
194
|
-
async def
|
306
|
+
async def async_on_humanloop_timeout(
|
195
307
|
self,
|
196
308
|
provider: HumanLoopProvider,
|
197
309
|
):
|
@@ -201,9 +313,10 @@ class HumanLoopCallback(ABC):
|
|
201
313
|
provider: 人机循环提供者实例
|
202
314
|
"""
|
203
315
|
pass
|
316
|
+
|
204
317
|
|
205
318
|
@abstractmethod
|
206
|
-
async def
|
319
|
+
async def async_on_humanloop_error(
|
207
320
|
self,
|
208
321
|
provider: HumanLoopProvider,
|
209
322
|
error: Exception
|
@@ -215,12 +328,13 @@ class HumanLoopCallback(ABC):
|
|
215
328
|
error: 错误信息
|
216
329
|
"""
|
217
330
|
pass
|
331
|
+
|
218
332
|
|
219
333
|
class HumanLoopManager(ABC):
|
220
334
|
"""人机循环管理器的抽象类"""
|
221
335
|
|
222
336
|
@abstractmethod
|
223
|
-
async def
|
337
|
+
async def async_register_provider(
|
224
338
|
self,
|
225
339
|
provider: HumanLoopProvider,
|
226
340
|
provider_id: Optional[str] = None
|
@@ -237,7 +351,24 @@ class HumanLoopManager(ABC):
|
|
237
351
|
pass
|
238
352
|
|
239
353
|
@abstractmethod
|
240
|
-
|
354
|
+
def register_provider(
|
355
|
+
self,
|
356
|
+
provider: HumanLoopProvider,
|
357
|
+
provider_id: Optional[str] = None
|
358
|
+
) -> str:
|
359
|
+
"""注册人机循环提供者(同步版本)
|
360
|
+
|
361
|
+
Args:
|
362
|
+
provider: 人机循环提供者实例
|
363
|
+
provider_id: 提供者标识符(可选)
|
364
|
+
|
365
|
+
Returns:
|
366
|
+
str: 注册成功后的提供者ID
|
367
|
+
"""
|
368
|
+
pass
|
369
|
+
|
370
|
+
@abstractmethod
|
371
|
+
async def async_request_humanloop(
|
241
372
|
self,
|
242
373
|
task_id: str,
|
243
374
|
conversation_id: str,
|
@@ -266,9 +397,40 @@ class HumanLoopManager(ABC):
|
|
266
397
|
Union[str, HumanLoopResult]: 如果blocking=False,返回请求ID;否则返回循环结果
|
267
398
|
"""
|
268
399
|
pass
|
400
|
+
|
401
|
+
@abstractmethod
|
402
|
+
def request_humanloop(
|
403
|
+
self,
|
404
|
+
task_id: str,
|
405
|
+
conversation_id: str,
|
406
|
+
loop_type: HumanLoopType,
|
407
|
+
context: Dict[str, Any],
|
408
|
+
callback: Optional[HumanLoopCallback] = None,
|
409
|
+
metadata: Optional[Dict[str, Any]] = None,
|
410
|
+
provider_id: Optional[str] = None,
|
411
|
+
timeout: Optional[int] = None,
|
412
|
+
blocking: bool = False,
|
413
|
+
) -> Union[str, HumanLoopResult]:
|
414
|
+
"""请求人机循环(同步版本)
|
415
|
+
|
416
|
+
Args:
|
417
|
+
task_id: 任务标识符
|
418
|
+
conversation_id: 对话ID,用于多轮对话
|
419
|
+
loop_type: 循环类型
|
420
|
+
context: 提供给人类的上下文信息
|
421
|
+
callback: 回调对象(可选)
|
422
|
+
metadata: 附加元数据
|
423
|
+
provider_id: 使用特定提供者的ID(可选)
|
424
|
+
timeout: 请求超时时间(秒)
|
425
|
+
blocking: 是否阻塞等待结果
|
426
|
+
|
427
|
+
Returns:
|
428
|
+
Union[str, HumanLoopResult]: 如果blocking=False,返回请求ID;否则返回循环结果
|
429
|
+
"""
|
430
|
+
pass
|
269
431
|
|
270
432
|
@abstractmethod
|
271
|
-
async def
|
433
|
+
async def async_continue_humanloop(
|
272
434
|
self,
|
273
435
|
conversation_id: str,
|
274
436
|
context: Dict[str, Any],
|
@@ -293,9 +455,36 @@ class HumanLoopManager(ABC):
|
|
293
455
|
Union[str, HumanLoopResult]: 如果blocking=False,返回请求ID;否则返回循环结果
|
294
456
|
"""
|
295
457
|
pass
|
458
|
+
|
459
|
+
@abstractmethod
|
460
|
+
def continue_humanloop(
|
461
|
+
self,
|
462
|
+
conversation_id: str,
|
463
|
+
context: Dict[str, Any],
|
464
|
+
callback: Optional[HumanLoopCallback] = None,
|
465
|
+
metadata: Optional[Dict[str, Any]] = None,
|
466
|
+
provider_id: Optional[str] = None,
|
467
|
+
timeout: Optional[int] = None,
|
468
|
+
blocking: bool = False,
|
469
|
+
) -> Union[str, HumanLoopResult]:
|
470
|
+
"""继续人机循环(同步版本)
|
471
|
+
|
472
|
+
Args:
|
473
|
+
conversation_id: 对话ID,用于多轮对话
|
474
|
+
context: 提供给人类的上下文信息
|
475
|
+
callback: 回调对象(可选)
|
476
|
+
metadata: 附加元数据
|
477
|
+
provider_id: 使用特定提供者的ID(可选)
|
478
|
+
timeout: 请求超时时间(秒)
|
479
|
+
blocking: 是否阻塞等待结果
|
480
|
+
|
481
|
+
Returns:
|
482
|
+
Union[str, HumanLoopResult]: 如果blocking=False,返回请求ID;否则返回循环结果
|
483
|
+
"""
|
484
|
+
pass
|
296
485
|
|
297
486
|
@abstractmethod
|
298
|
-
async def
|
487
|
+
async def async_check_request_status(
|
299
488
|
self,
|
300
489
|
conversation_id: str,
|
301
490
|
request_id: str,
|
@@ -312,9 +501,28 @@ class HumanLoopManager(ABC):
|
|
312
501
|
HumanLoopResult: 包含当前请求状态的结果对象
|
313
502
|
"""
|
314
503
|
pass
|
504
|
+
|
505
|
+
@abstractmethod
|
506
|
+
def check_request_status(
|
507
|
+
self,
|
508
|
+
conversation_id: str,
|
509
|
+
request_id: str,
|
510
|
+
provider_id: Optional[str] = None
|
511
|
+
) -> HumanLoopResult:
|
512
|
+
"""检查请求状态(同步版本)
|
513
|
+
|
514
|
+
Args:
|
515
|
+
conversation_id: 对话标识符
|
516
|
+
request_id: 请求标识符
|
517
|
+
provider_id: 使用特定提供者的ID(可选)
|
518
|
+
|
519
|
+
Returns:
|
520
|
+
HumanLoopResult: 包含当前请求状态的结果对象
|
521
|
+
"""
|
522
|
+
pass
|
315
523
|
|
316
524
|
@abstractmethod
|
317
|
-
async def
|
525
|
+
async def async_check_conversation_status(
|
318
526
|
self,
|
319
527
|
conversation_id: str,
|
320
528
|
provider_id: Optional[str] = None
|
@@ -329,9 +537,26 @@ class HumanLoopManager(ABC):
|
|
329
537
|
HumanLoopResult: 包含对话最新请求的状态
|
330
538
|
"""
|
331
539
|
pass
|
540
|
+
|
541
|
+
@abstractmethod
|
542
|
+
def check_conversation_status(
|
543
|
+
self,
|
544
|
+
conversation_id: str,
|
545
|
+
provider_id: Optional[str] = None
|
546
|
+
) -> HumanLoopResult:
|
547
|
+
"""检查对话状态(同步版本)
|
548
|
+
|
549
|
+
Args:
|
550
|
+
conversation_id: 对话标识符
|
551
|
+
provider_id: 使用特定提供者的ID(可选)
|
552
|
+
|
553
|
+
Returns:
|
554
|
+
HumanLoopResult: 包含对话最新请求的状态
|
555
|
+
"""
|
556
|
+
pass
|
332
557
|
|
333
558
|
@abstractmethod
|
334
|
-
async def
|
559
|
+
async def async_cancel_request(
|
335
560
|
self,
|
336
561
|
conversation_id: str,
|
337
562
|
request_id: str,
|
@@ -348,9 +573,28 @@ class HumanLoopManager(ABC):
|
|
348
573
|
bool: 取消是否成功
|
349
574
|
"""
|
350
575
|
pass
|
576
|
+
|
577
|
+
@abstractmethod
|
578
|
+
def cancel_request(
|
579
|
+
self,
|
580
|
+
conversation_id: str,
|
581
|
+
request_id: str,
|
582
|
+
provider_id: Optional[str] = None
|
583
|
+
) -> bool:
|
584
|
+
"""取消特定请求(同步版本)
|
585
|
+
|
586
|
+
Args:
|
587
|
+
conversation_id: 对话标识符
|
588
|
+
request_id: 请求标识符
|
589
|
+
provider_id: 使用特定提供者的ID(可选)
|
590
|
+
|
591
|
+
Returns:
|
592
|
+
bool: 取消是否成功
|
593
|
+
"""
|
594
|
+
pass
|
351
595
|
|
352
596
|
@abstractmethod
|
353
|
-
async def
|
597
|
+
async def async_cancel_conversation(
|
354
598
|
self,
|
355
599
|
conversation_id: str,
|
356
600
|
provider_id: Optional[str] = None
|
@@ -365,9 +609,26 @@ class HumanLoopManager(ABC):
|
|
365
609
|
bool: 取消是否成功
|
366
610
|
"""
|
367
611
|
pass
|
612
|
+
|
613
|
+
@abstractmethod
|
614
|
+
def cancel_conversation(
|
615
|
+
self,
|
616
|
+
conversation_id: str,
|
617
|
+
provider_id: Optional[str] = None
|
618
|
+
) -> bool:
|
619
|
+
"""取消整个对话(同步版本)
|
620
|
+
|
621
|
+
Args:
|
622
|
+
conversation_id: 对话标识符
|
623
|
+
provider_id: 使用特定提供者的ID(可选)
|
624
|
+
|
625
|
+
Returns:
|
626
|
+
bool: 取消是否成功
|
627
|
+
"""
|
628
|
+
pass
|
368
629
|
|
369
630
|
@abstractmethod
|
370
|
-
async def
|
631
|
+
async def async_get_provider(
|
371
632
|
self,
|
372
633
|
provider_id: Optional[str] = None
|
373
634
|
) -> HumanLoopProvider:
|
@@ -383,18 +644,45 @@ class HumanLoopManager(ABC):
|
|
383
644
|
ValueError: 如果指定的提供者不存在
|
384
645
|
"""
|
385
646
|
pass
|
647
|
+
|
648
|
+
@abstractmethod
|
649
|
+
def get_provider(
|
650
|
+
self,
|
651
|
+
provider_id: Optional[str] = None
|
652
|
+
) -> HumanLoopProvider:
|
653
|
+
"""获取指定的提供者实例(同步版本)
|
654
|
+
|
655
|
+
Args:
|
656
|
+
provider_id: 提供者ID,如果为None则返回默认提供者
|
657
|
+
|
658
|
+
Returns:
|
659
|
+
HumanLoopProvider: 提供者实例
|
660
|
+
|
661
|
+
Raises:
|
662
|
+
ValueError: 如果指定的提供者不存在
|
663
|
+
"""
|
664
|
+
pass
|
386
665
|
|
387
666
|
@abstractmethod
|
388
|
-
async def
|
667
|
+
async def async_list_providers(self) -> Dict[str, HumanLoopProvider]:
|
389
668
|
"""列出所有注册的提供者
|
390
669
|
|
391
670
|
Returns:
|
392
671
|
Dict[str, HumanLoopProvider]: 提供者ID到提供者实例的映射
|
393
672
|
"""
|
394
673
|
pass
|
674
|
+
|
675
|
+
@abstractmethod
|
676
|
+
def list_providers(self) -> Dict[str, HumanLoopProvider]:
|
677
|
+
"""列出所有注册的提供者(同步版本)
|
678
|
+
|
679
|
+
Returns:
|
680
|
+
Dict[str, HumanLoopProvider]: 提供者ID到提供者实例的映射
|
681
|
+
"""
|
682
|
+
pass
|
395
683
|
|
396
684
|
@abstractmethod
|
397
|
-
async def
|
685
|
+
async def async_set_default_provider(
|
398
686
|
self,
|
399
687
|
provider_id: str
|
400
688
|
) -> bool:
|
@@ -410,9 +698,27 @@ class HumanLoopManager(ABC):
|
|
410
698
|
ValueError: 如果指定的提供者不存在
|
411
699
|
"""
|
412
700
|
pass
|
701
|
+
|
702
|
+
@abstractmethod
|
703
|
+
def set_default_provider(
|
704
|
+
self,
|
705
|
+
provider_id: str
|
706
|
+
) -> bool:
|
707
|
+
"""设置默认提供者(同步版本)
|
708
|
+
|
709
|
+
Args:
|
710
|
+
provider_id: 提供者ID
|
711
|
+
|
712
|
+
Returns:
|
713
|
+
bool: 设置是否成功
|
714
|
+
|
715
|
+
Raises:
|
716
|
+
ValueError: 如果指定的提供者不存在
|
717
|
+
"""
|
718
|
+
pass
|
413
719
|
|
414
720
|
@abstractmethod
|
415
|
-
async def
|
721
|
+
async def async_check_conversation_exist(
|
416
722
|
self,
|
417
723
|
task_id: str,
|
418
724
|
conversation_id: str,
|
@@ -425,9 +731,24 @@ class HumanLoopManager(ABC):
|
|
425
731
|
HumanLoopResult: 包含对话最新请求的状态
|
426
732
|
"""
|
427
733
|
pass
|
734
|
+
|
735
|
+
@abstractmethod
|
736
|
+
def check_conversation_exist(
|
737
|
+
self,
|
738
|
+
task_id: str,
|
739
|
+
conversation_id: str,
|
740
|
+
) -> HumanLoopResult:
|
741
|
+
"""检查对话状态(同步版本)
|
742
|
+
|
743
|
+
Args:
|
744
|
+
conversation_id: 对话标识符
|
745
|
+
Returns:
|
746
|
+
HumanLoopResult: 包含对话最新请求的状态
|
747
|
+
"""
|
748
|
+
pass
|
428
749
|
|
429
750
|
@abstractmethod
|
430
|
-
async def
|
751
|
+
async def async_shutdown(self):
|
431
752
|
"""关闭管理器(异步方法)"""
|
432
753
|
pass
|
433
754
|
|