gohumanloop 0.0.1__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/__init__.py +17 -0
- gohumanloop/adapters/langgraph_adapter.py +817 -0
- gohumanloop/cli/__init__.py +0 -0
- gohumanloop/cli/main.py +29 -0
- gohumanloop/core/__init__.py +0 -0
- gohumanloop/core/interface.py +758 -0
- gohumanloop/core/manager.py +839 -0
- gohumanloop/manager/__init__.py +0 -0
- gohumanloop/manager/ghl_manager.py +532 -0
- gohumanloop/models/__init__.py +0 -0
- gohumanloop/models/api_model.py +54 -0
- gohumanloop/models/glh_model.py +23 -0
- gohumanloop/providers/__init__.py +0 -0
- gohumanloop/providers/api_provider.py +628 -0
- gohumanloop/providers/base.py +658 -0
- gohumanloop/providers/email_provider.py +1019 -0
- gohumanloop/providers/ghl_provider.py +64 -0
- gohumanloop/providers/terminal_provider.py +301 -0
- gohumanloop/utils/__init__.py +1 -0
- gohumanloop/utils/context_formatter.py +59 -0
- gohumanloop/utils/threadsafedict.py +243 -0
- gohumanloop/utils/utils.py +67 -0
- {gohumanloop-0.0.1.dist-info → gohumanloop-0.0.3.dist-info}/METADATA +2 -1
- gohumanloop-0.0.3.dist-info/RECORD +30 -0
- {gohumanloop-0.0.1.dist-info → gohumanloop-0.0.3.dist-info}/WHEEL +1 -1
- gohumanloop-0.0.1.dist-info/RECORD +0 -8
- {gohumanloop-0.0.1.dist-info → gohumanloop-0.0.3.dist-info}/entry_points.txt +0 -0
- {gohumanloop-0.0.1.dist-info → gohumanloop-0.0.3.dist-info}/licenses/LICENSE +0 -0
- {gohumanloop-0.0.1.dist-info → gohumanloop-0.0.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,758 @@
|
|
1
|
+
from abc import ABC, abstractmethod
|
2
|
+
from typing import Any, Dict, Optional, Protocol, runtime_checkable, List, Union, Callable, Awaitable
|
3
|
+
from enum import Enum
|
4
|
+
from dataclasses import dataclass, field
|
5
|
+
from datetime import datetime
|
6
|
+
|
7
|
+
class HumanLoopStatus(Enum):
|
8
|
+
"""Enumeration of human-in-the-loop states"""
|
9
|
+
PENDING = "pending"
|
10
|
+
APPROVED = "approved"
|
11
|
+
REJECTED = "rejected"
|
12
|
+
EXPIRED = "expired"
|
13
|
+
ERROR = "error"
|
14
|
+
COMPLETED = "completed" # For completing non-approval interactions
|
15
|
+
INPROGRESS = "inprogress" # Intermediate state for multi-turn dialogues, indicating ongoing conversation
|
16
|
+
CANCELLED = "cancelled" # For cancelled requests
|
17
|
+
|
18
|
+
class HumanLoopType(Enum):
|
19
|
+
"""Enumeration of human-in-the-loop types"""
|
20
|
+
APPROVAL = "approval" # Approval type
|
21
|
+
INFORMATION = "information" # Information gathering type
|
22
|
+
CONVERSATION = "conversation" # Conversation type
|
23
|
+
|
24
|
+
"""
|
25
|
+
## Relationship between task_id, conversation_id and request_id
|
26
|
+
1. Hierarchical relationship:
|
27
|
+
|
28
|
+
- task_id is at the highest level, representing business tasks
|
29
|
+
- conversation_id is at the middle level, representing a complete dialogue session
|
30
|
+
- request_id is at the lowest level, representing a single interaction request
|
31
|
+
2. Mapping relationship:
|
32
|
+
|
33
|
+
- One task_id may correspond to multiple conversation_ids (a task may require multiple conversations)
|
34
|
+
- One conversation_id may correspond to multiple request_ids (a conversation may contain multiple rounds of interaction)
|
35
|
+
"""
|
36
|
+
@dataclass
|
37
|
+
class HumanLoopRequest:
|
38
|
+
"""人机循环请求的数据模型 / Human loop request data model"""
|
39
|
+
task_id: str # 任务ID / Task identifier
|
40
|
+
conversation_id: str# 用于关联多轮对话 / Used to associate multi-turn conversations
|
41
|
+
loop_type: HumanLoopType # 循环类型 / Loop type
|
42
|
+
context: Dict[str, Any] # 交互上下文信息 / Interaction context information
|
43
|
+
metadata: Dict[str, Any] = field(default_factory=dict) # 元数据信息 / Metadata information
|
44
|
+
request_id: Optional[str] = None # 请求ID / Request identifier
|
45
|
+
timeout: Optional[int] = None # 超时时间(秒) / Timeout duration (seconds)
|
46
|
+
created_at: Optional[datetime] = None # 将在请求创建时设置 / Will be set when request is created
|
47
|
+
|
48
|
+
@dataclass
|
49
|
+
class HumanLoopResult:
|
50
|
+
"""人机循环结果的数据模型 / Human loop result data model"""
|
51
|
+
conversation_id: str # 用于关联多轮对话 / Used to associate multi-turn conversations
|
52
|
+
request_id: str # 请求ID / Request identifier
|
53
|
+
loop_type: HumanLoopType # 循环类型 / Loop type
|
54
|
+
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
|
57
|
+
responded_by: Optional[str] = None # 响应者 / Responder
|
58
|
+
responded_at: Optional[str] = None # 响应时间 / Response time
|
59
|
+
error: Optional[str] = None # 错误信息 / Error message
|
60
|
+
|
61
|
+
@runtime_checkable
|
62
|
+
class HumanLoopProvider(Protocol):
|
63
|
+
"""Human-in-the-loop Provider Protocol"""
|
64
|
+
|
65
|
+
name: str # 提供者名称
|
66
|
+
|
67
|
+
@abstractmethod
|
68
|
+
async def async_request_humanloop(
|
69
|
+
self,
|
70
|
+
task_id: str,
|
71
|
+
conversation_id: str,
|
72
|
+
loop_type: HumanLoopType,
|
73
|
+
context: Dict[str, Any],
|
74
|
+
metadata: Optional[Dict[str, Any]] = None,
|
75
|
+
timeout: Optional[int] = None
|
76
|
+
) -> HumanLoopResult:
|
77
|
+
"""请求人机循环
|
78
|
+
|
79
|
+
Args:
|
80
|
+
task_id: 任务标识符
|
81
|
+
conversation_id: 对话ID,用于多轮对话
|
82
|
+
loop_type: 循环类型
|
83
|
+
context: 提供给人类的上下文信息
|
84
|
+
metadata: 附加元数据
|
85
|
+
timeout: 请求超时时间(秒)
|
86
|
+
|
87
|
+
Returns:
|
88
|
+
HumanLoopResult: 包含请求ID和初始状态的结果对象
|
89
|
+
"""
|
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
|
116
|
+
|
117
|
+
@abstractmethod
|
118
|
+
async def async_check_request_status(
|
119
|
+
self,
|
120
|
+
conversation_id: str,
|
121
|
+
request_id: str
|
122
|
+
) -> HumanLoopResult:
|
123
|
+
"""检查请求状态
|
124
|
+
|
125
|
+
Args:
|
126
|
+
conversation_id: 对话标识符,用于关联多轮对话
|
127
|
+
request_id: 请求标识符,用于标识具体的交互请求
|
128
|
+
|
129
|
+
Returns:
|
130
|
+
HumanLoopResult: 包含当前请求状态的结果对象,包括状态、响应数据等信息
|
131
|
+
"""
|
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
|
+
|
151
|
+
@abstractmethod
|
152
|
+
async def async_check_conversation_status(
|
153
|
+
self,
|
154
|
+
conversation_id: str
|
155
|
+
) -> HumanLoopResult:
|
156
|
+
"""检查对话状态
|
157
|
+
|
158
|
+
Args:
|
159
|
+
conversation_id: 对话标识符
|
160
|
+
|
161
|
+
Returns:
|
162
|
+
HumanLoopResult: 包含对话最新请求的状态
|
163
|
+
"""
|
164
|
+
pass
|
165
|
+
|
166
|
+
@abstractmethod
|
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(
|
183
|
+
self,
|
184
|
+
conversation_id: str,
|
185
|
+
request_id: str
|
186
|
+
) -> bool:
|
187
|
+
"""取消人机循环请求
|
188
|
+
|
189
|
+
Args:
|
190
|
+
conversation_id: 对话标识符,用于关联多轮对话
|
191
|
+
request_id: 请求标识符,用于标识具体的交互请求
|
192
|
+
|
193
|
+
Returns:
|
194
|
+
bool: 取消是否成功,True表示取消成功,False表示取消失败
|
195
|
+
"""
|
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
|
214
|
+
|
215
|
+
@abstractmethod
|
216
|
+
async def async_cancel_conversation(
|
217
|
+
self,
|
218
|
+
conversation_id: str
|
219
|
+
) -> bool:
|
220
|
+
"""取消整个对话
|
221
|
+
|
222
|
+
Args:
|
223
|
+
conversation_id: 对话标识符
|
224
|
+
|
225
|
+
Returns:
|
226
|
+
bool: 取消是否成功
|
227
|
+
"""
|
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
|
244
|
+
|
245
|
+
@abstractmethod
|
246
|
+
async def async_continue_humanloop(
|
247
|
+
self,
|
248
|
+
conversation_id: str,
|
249
|
+
context: Dict[str, Any],
|
250
|
+
metadata: Optional[Dict[str, Any]] = None,
|
251
|
+
timeout: Optional[int] = None,
|
252
|
+
) -> HumanLoopResult:
|
253
|
+
"""继续人机循环
|
254
|
+
|
255
|
+
Args:
|
256
|
+
conversation_id: 对话ID,用于多轮对话
|
257
|
+
context: 提供给人类的上下文信息
|
258
|
+
metadata: 附加元数据
|
259
|
+
timeout: 请求超时时间(秒)
|
260
|
+
|
261
|
+
Returns:
|
262
|
+
HumanLoopResult: 包含请求ID和状态的结果对象
|
263
|
+
"""
|
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
|
286
|
+
|
287
|
+
class HumanLoopCallback(ABC):
|
288
|
+
"""人机循环回调的抽象类"""
|
289
|
+
|
290
|
+
@abstractmethod
|
291
|
+
async def async_on_humanloop_update(
|
292
|
+
self,
|
293
|
+
provider: HumanLoopProvider,
|
294
|
+
result: HumanLoopResult
|
295
|
+
):
|
296
|
+
"""当请求更新时的回调
|
297
|
+
|
298
|
+
Args:
|
299
|
+
provider: 人机循环提供者实例
|
300
|
+
result: 循环结果
|
301
|
+
"""
|
302
|
+
pass
|
303
|
+
|
304
|
+
|
305
|
+
@abstractmethod
|
306
|
+
async def async_on_humanloop_timeout(
|
307
|
+
self,
|
308
|
+
provider: HumanLoopProvider,
|
309
|
+
):
|
310
|
+
"""当请求超时时的回调
|
311
|
+
|
312
|
+
Args:
|
313
|
+
provider: 人机循环提供者实例
|
314
|
+
"""
|
315
|
+
pass
|
316
|
+
|
317
|
+
|
318
|
+
@abstractmethod
|
319
|
+
async def async_on_humanloop_error(
|
320
|
+
self,
|
321
|
+
provider: HumanLoopProvider,
|
322
|
+
error: Exception
|
323
|
+
):
|
324
|
+
"""当请求发生错误时的回调
|
325
|
+
|
326
|
+
Args:
|
327
|
+
provider: 人机循环提供者实例
|
328
|
+
error: 错误信息
|
329
|
+
"""
|
330
|
+
pass
|
331
|
+
|
332
|
+
|
333
|
+
class HumanLoopManager(ABC):
|
334
|
+
"""人机循环管理器的抽象类"""
|
335
|
+
|
336
|
+
@abstractmethod
|
337
|
+
async def async_register_provider(
|
338
|
+
self,
|
339
|
+
provider: HumanLoopProvider,
|
340
|
+
provider_id: Optional[str] = None
|
341
|
+
) -> str:
|
342
|
+
"""注册人机循环提供者
|
343
|
+
|
344
|
+
Args:
|
345
|
+
provider: 人机循环提供者实例
|
346
|
+
provider_id: 提供者标识符(可选)
|
347
|
+
|
348
|
+
Returns:
|
349
|
+
str: 注册成功后的提供者ID
|
350
|
+
"""
|
351
|
+
pass
|
352
|
+
|
353
|
+
@abstractmethod
|
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(
|
372
|
+
self,
|
373
|
+
task_id: str,
|
374
|
+
conversation_id: str,
|
375
|
+
loop_type: HumanLoopType,
|
376
|
+
context: Dict[str, Any],
|
377
|
+
callback: Optional[HumanLoopCallback] = None,
|
378
|
+
metadata: Optional[Dict[str, Any]] = None,
|
379
|
+
provider_id: Optional[str] = None,
|
380
|
+
timeout: Optional[int] = None,
|
381
|
+
blocking: bool = False,
|
382
|
+
) -> Union[str, HumanLoopResult]:
|
383
|
+
"""请求人机循环
|
384
|
+
|
385
|
+
Args:
|
386
|
+
task_id: 任务标识符
|
387
|
+
conversation_id: 对话ID,用于多轮对话
|
388
|
+
loop_type: 循环类型
|
389
|
+
context: 提供给人类的上下文信息
|
390
|
+
callback: 回调对象(可选)
|
391
|
+
metadata: 附加元数据
|
392
|
+
provider_id: 使用特定提供者的ID(可选)
|
393
|
+
timeout: 请求超时时间(秒)
|
394
|
+
blocking: 是否阻塞等待结果
|
395
|
+
|
396
|
+
Returns:
|
397
|
+
Union[str, HumanLoopResult]: 如果blocking=False,返回请求ID;否则返回循环结果
|
398
|
+
"""
|
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
|
431
|
+
|
432
|
+
@abstractmethod
|
433
|
+
async def async_continue_humanloop(
|
434
|
+
self,
|
435
|
+
conversation_id: str,
|
436
|
+
context: Dict[str, Any],
|
437
|
+
callback: Optional[HumanLoopCallback] = None,
|
438
|
+
metadata: Optional[Dict[str, Any]] = None,
|
439
|
+
provider_id: Optional[str] = None,
|
440
|
+
timeout: Optional[int] = None,
|
441
|
+
blocking: bool = False,
|
442
|
+
) -> Union[str, HumanLoopResult]:
|
443
|
+
"""继续人机循环
|
444
|
+
|
445
|
+
Args:
|
446
|
+
conversation_id: 对话ID,用于多轮对话
|
447
|
+
context: 提供给人类的上下文信息
|
448
|
+
callback: 回调对象(可选)
|
449
|
+
metadata: 附加元数据
|
450
|
+
provider_id: 使用特定提供者的ID(可选)
|
451
|
+
timeout: 请求超时时间(秒)
|
452
|
+
blocking: 是否阻塞等待结果
|
453
|
+
|
454
|
+
Returns:
|
455
|
+
Union[str, HumanLoopResult]: 如果blocking=False,返回请求ID;否则返回循环结果
|
456
|
+
"""
|
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
|
485
|
+
|
486
|
+
@abstractmethod
|
487
|
+
async def async_check_request_status(
|
488
|
+
self,
|
489
|
+
conversation_id: str,
|
490
|
+
request_id: str,
|
491
|
+
provider_id: Optional[str] = None
|
492
|
+
) -> HumanLoopResult:
|
493
|
+
"""检查请求状态
|
494
|
+
|
495
|
+
Args:
|
496
|
+
conversation_id: 对话标识符
|
497
|
+
request_id: 请求标识符
|
498
|
+
provider_id: 使用特定提供者的ID(可选)
|
499
|
+
|
500
|
+
Returns:
|
501
|
+
HumanLoopResult: 包含当前请求状态的结果对象
|
502
|
+
"""
|
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
|
523
|
+
|
524
|
+
@abstractmethod
|
525
|
+
async def async_check_conversation_status(
|
526
|
+
self,
|
527
|
+
conversation_id: str,
|
528
|
+
provider_id: Optional[str] = None
|
529
|
+
) -> HumanLoopResult:
|
530
|
+
"""检查对话状态
|
531
|
+
|
532
|
+
Args:
|
533
|
+
conversation_id: 对话标识符
|
534
|
+
provider_id: 使用特定提供者的ID(可选)
|
535
|
+
|
536
|
+
Returns:
|
537
|
+
HumanLoopResult: 包含对话最新请求的状态
|
538
|
+
"""
|
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
|
557
|
+
|
558
|
+
@abstractmethod
|
559
|
+
async def async_cancel_request(
|
560
|
+
self,
|
561
|
+
conversation_id: str,
|
562
|
+
request_id: str,
|
563
|
+
provider_id: Optional[str] = None
|
564
|
+
) -> bool:
|
565
|
+
"""取消特定请求
|
566
|
+
|
567
|
+
Args:
|
568
|
+
conversation_id: 对话标识符
|
569
|
+
request_id: 请求标识符
|
570
|
+
provider_id: 使用特定提供者的ID(可选)
|
571
|
+
|
572
|
+
Returns:
|
573
|
+
bool: 取消是否成功
|
574
|
+
"""
|
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
|
595
|
+
|
596
|
+
@abstractmethod
|
597
|
+
async def async_cancel_conversation(
|
598
|
+
self,
|
599
|
+
conversation_id: str,
|
600
|
+
provider_id: Optional[str] = None
|
601
|
+
) -> bool:
|
602
|
+
"""取消整个对话
|
603
|
+
|
604
|
+
Args:
|
605
|
+
conversation_id: 对话标识符
|
606
|
+
provider_id: 使用特定提供者的ID(可选)
|
607
|
+
|
608
|
+
Returns:
|
609
|
+
bool: 取消是否成功
|
610
|
+
"""
|
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
|
629
|
+
|
630
|
+
@abstractmethod
|
631
|
+
async def async_get_provider(
|
632
|
+
self,
|
633
|
+
provider_id: Optional[str] = None
|
634
|
+
) -> HumanLoopProvider:
|
635
|
+
"""获取指定的提供者实例
|
636
|
+
|
637
|
+
Args:
|
638
|
+
provider_id: 提供者ID,如果为None则返回默认提供者
|
639
|
+
|
640
|
+
Returns:
|
641
|
+
HumanLoopProvider: 提供者实例
|
642
|
+
|
643
|
+
Raises:
|
644
|
+
ValueError: 如果指定的提供者不存在
|
645
|
+
"""
|
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
|
665
|
+
|
666
|
+
@abstractmethod
|
667
|
+
async def async_list_providers(self) -> Dict[str, HumanLoopProvider]:
|
668
|
+
"""列出所有注册的提供者
|
669
|
+
|
670
|
+
Returns:
|
671
|
+
Dict[str, HumanLoopProvider]: 提供者ID到提供者实例的映射
|
672
|
+
"""
|
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
|
683
|
+
|
684
|
+
@abstractmethod
|
685
|
+
async def async_set_default_provider(
|
686
|
+
self,
|
687
|
+
provider_id: str
|
688
|
+
) -> bool:
|
689
|
+
"""设置默认提供者
|
690
|
+
|
691
|
+
Args:
|
692
|
+
provider_id: 提供者ID
|
693
|
+
|
694
|
+
Returns:
|
695
|
+
bool: 设置是否成功
|
696
|
+
|
697
|
+
Raises:
|
698
|
+
ValueError: 如果指定的提供者不存在
|
699
|
+
"""
|
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
|
719
|
+
|
720
|
+
@abstractmethod
|
721
|
+
async def async_check_conversation_exist(
|
722
|
+
self,
|
723
|
+
task_id: str,
|
724
|
+
conversation_id: str,
|
725
|
+
) -> HumanLoopResult:
|
726
|
+
"""检查对话状态
|
727
|
+
|
728
|
+
Args:
|
729
|
+
conversation_id: 对话标识符
|
730
|
+
Returns:
|
731
|
+
HumanLoopResult: 包含对话最新请求的状态
|
732
|
+
"""
|
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
|
749
|
+
|
750
|
+
@abstractmethod
|
751
|
+
async def async_shutdown(self):
|
752
|
+
"""关闭管理器(异步方法)"""
|
753
|
+
pass
|
754
|
+
|
755
|
+
@abstractmethod
|
756
|
+
def shutdown(self):
|
757
|
+
"""关闭管理器(同步方法)"""
|
758
|
+
pass
|