sycommon-python-lib 0.2.2a2__py3-none-any.whl → 0.2.2a3__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.
sycommon/llm/get_llm.py CHANGED
@@ -7,13 +7,15 @@ from sycommon.llm.usage_token import LLMWithAutoTokenUsage
7
7
  from typing import Any, Optional, Union
8
8
  from langchain_core.language_models import BaseChatModel
9
9
 
10
+ _TIMEOUT_UNSET = object()
11
+
10
12
 
11
13
  def get_llm(
12
14
  model: Optional[str] = None,
13
15
  *,
14
16
  streaming: bool = False,
15
17
  temperature: Optional[float] = None,
16
- timeout: float = 180,
18
+ timeout: Optional[float] = _TIMEOUT_UNSET,
17
19
  max_retries: int = 3,
18
20
  wrap_structured: bool = True,
19
21
  thinking: bool = False,
@@ -26,7 +28,9 @@ def get_llm(
26
28
  model: 模型名称,如果为 None 则使用配置中 default=True 的模型
27
29
  streaming: 是否启用流式输出
28
30
  temperature: 温度参数,如果为 None 则根据 thinking 模式自动设置
29
- timeout: 请求超时时间(秒),默认180秒
31
+ timeout: 请求超时时间(秒),不传则根据 wrap_structured 自动决定:
32
+ - wrap_structured=True(结构化输出):默认 180 秒
33
+ - wrap_structured=False(普通调用):默认不设超时
30
34
  max_retries: 最大重试次数,默认3次
31
35
  wrap_structured: 是否包装为结构化输出实例,默认True
32
36
  - True: 返回 LLMWithAutoTokenUsage,支持 with_structured_output()
@@ -147,6 +151,10 @@ def get_llm(
147
151
  langfuse_callbacks, langfuse = LangfuseInitializer.get()
148
152
  callbacks = [LLMLogger()] + langfuse_callbacks
149
153
 
154
+ # 根据 wrap_structured 决定默认超时
155
+ if timeout is _TIMEOUT_UNSET:
156
+ timeout = 180 if wrap_structured else None
157
+
150
158
  init_params = {
151
159
  "model_provider": llmConfig.provider,
152
160
  "model": llmConfig.model,
@@ -158,7 +166,6 @@ def get_llm(
158
166
  "timeout": timeout,
159
167
  "max_retries": max_retries,
160
168
  "stream_chunk_timeout": None,
161
- # "model_kwargs": {"response_format": {"type": "json_object"}},
162
169
  }
163
170
 
164
171
  # 合并其他透传参数(包括 presence_penalty, extra_body, top_p 等)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sycommon-python-lib
3
- Version: 0.2.2a2
3
+ Version: 0.2.2a3
4
4
  Summary: Add your description here
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -162,7 +162,7 @@ sycommon/heartbeat_process/heartbeat_process_manager.py,sha256=24qUKs8qegdWHqcox
162
162
  sycommon/heartbeat_process/heartbeat_process_worker.py,sha256=duuAEFwda43Y6pZE8tOOspitlyxecaFsg1n1iH9jQDQ,16863
163
163
  sycommon/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
164
164
  sycommon/llm/embedding.py,sha256=Xwmg1HcgbdW7OcpYyzu8k7U-27rC5lzjIqbg221CcyY,19129
165
- sycommon/llm/get_llm.py,sha256=zMZCGfyRjFnImMdwWNy9b11VyBsCX3S0hyf7SE1iF1Q,7085
165
+ sycommon/llm/get_llm.py,sha256=472LbzRH6TGCz2p3MH1UH2BE0PJ33knSKSY6s2JNs70,7378
166
166
  sycommon/llm/llm_logger.py,sha256=LLXiESwDP5f8dB50nFabShVoLKv8UCf2ll69zo1FOso,3365
167
167
  sycommon/llm/llm_tokens.py,sha256=yGEessxfk5wRMrPGyWHhiiIIQFDVT23FSaqnwqHGCoY,4712
168
168
  sycommon/llm/llm_with_token_tracking.py,sha256=flGN3dbsjw1enal-p5Wh2Fq14F9Z9_O84aOd6kdq4kc,12377
@@ -246,8 +246,8 @@ sycommon/tools/syemail.py,sha256=BDFhgf7WDOQeTcjxJEQdu0dQhnHFPO_p3eI0-Ni3LhQ,561
246
246
  sycommon/tools/timing.py,sha256=OiiE7P07lRoMzX9kzb8sZU9cDb0zNnqIlY5pWqHcnkY,2064
247
247
  sycommon/xxljob/__init__.py,sha256=7eoBlQxv-B39IfRSCY2bkqdGYs1QRe1umAWd88VMEEM,86
248
248
  sycommon/xxljob/xxljob_service.py,sha256=JIEJaGXhqrTLcyxlyynSrsHg9bBnDNzX-D4qIWLRPUE,6815
249
- sycommon_python_lib-0.2.2a2.dist-info/METADATA,sha256=GG6m9_Lg7cmVgZo1teSqt1KgyxjicnHCEhT4amnuDPM,7683
250
- sycommon_python_lib-0.2.2a2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
251
- sycommon_python_lib-0.2.2a2.dist-info/entry_points.txt,sha256=gsR4SssKxDWjRU8ggidzNcdMXDPRSKRS7UaGyNP84Qg,92
252
- sycommon_python_lib-0.2.2a2.dist-info/top_level.txt,sha256=RgphKrg7nJyZ7irJqbxFr-5H2LUYTvI7ivoWZH2hcD0,29
253
- sycommon_python_lib-0.2.2a2.dist-info/RECORD,,
249
+ sycommon_python_lib-0.2.2a3.dist-info/METADATA,sha256=JzdlgU0tqIPnpanKWQWPVrHCKAtpd_gq-8noMxPKdRo,7683
250
+ sycommon_python_lib-0.2.2a3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
251
+ sycommon_python_lib-0.2.2a3.dist-info/entry_points.txt,sha256=gsR4SssKxDWjRU8ggidzNcdMXDPRSKRS7UaGyNP84Qg,92
252
+ sycommon_python_lib-0.2.2a3.dist-info/top_level.txt,sha256=RgphKrg7nJyZ7irJqbxFr-5H2LUYTvI7ivoWZH2hcD0,29
253
+ sycommon_python_lib-0.2.2a3.dist-info/RECORD,,