gomyck-tools 1.4.0__py3-none-any.whl → 1.4.1__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.
ctools/ai/env_config.py CHANGED
@@ -17,6 +17,8 @@ class Configuration:
17
17
  """Initialize configuration with environment variables."""
18
18
  if not os.path.exists(dotenv_path): raise FileNotFoundError(f"Could not find .env file at {dotenv_path}")
19
19
  self.env = DotEnv(dotenv_path=dotenv_path)
20
+ for key, value in self.env.dict().items():
21
+ if value: os.environ[key] = value
20
22
 
21
23
  def get_env(self, key: str, default: Optional[Any] = None) -> Any:
22
24
  value = self.env.get(key)
ctools/ai/llm_client.py CHANGED
@@ -3,7 +3,7 @@ import os
3
3
 
4
4
  import httpx
5
5
 
6
- from ctools import sys_log, cjson
6
+ from ctools import sys_log, cjson, call
7
7
  from ctools.ai.llm_exception import LLMException
8
8
 
9
9
  logging.getLogger("httpcore").setLevel(logging.WARNING)
@@ -20,11 +20,17 @@ def process_SSE(line):
20
20
  return "[DONE]"
21
21
  return data
22
22
 
23
- shared_client = httpx.AsyncClient(
24
- base_url=os.getenv("LLM_BASE_URL", "https://api.siliconflow.cn/v1/"),
25
- timeout=httpx.Timeout(connect=10.0, read=60.0, write=10.0, pool=5.0),
26
- limits=httpx.Limits(max_connections=100, max_keepalive_connections=20),
27
- )
23
+ shared_client = None
24
+
25
+ @call.once
26
+ def init_shared_client():
27
+ global shared_client
28
+ shared_client = httpx.AsyncClient(
29
+ base_url=os.getenv("LLM_BASE_URL", "https://api.siliconflow.cn/v1/"),
30
+ timeout=httpx.Timeout(connect=10.0, read=60.0, write=10.0, pool=5.0),
31
+ limits=httpx.Limits(max_connections=100, max_keepalive_connections=20),
32
+ )
33
+ return shared_client
28
34
 
29
35
  class LLMClient:
30
36
  """Manages communication with the LLM provider."""
@@ -51,6 +57,7 @@ class LLMClient:
51
57
  self.top_p = top_p
52
58
  self.top_k = top_k
53
59
  self.frequency_penalty = frequency_penalty
60
+ init_shared_client()
54
61
 
55
62
  async def model_completion(self, messages: list[dict[str, str]]):
56
63
  self.no_think_compatible(messages)
@@ -292,6 +292,7 @@ def is_image_content(content: dict) -> bool:
292
292
  @asynccontextmanager
293
293
  async def init_mcp_clients(mcp_server_config: dict[str, Any]) -> list[MCPClient]:
294
294
  mcp_clients = []
295
+ if not mcp_server_config["mcpServers"]: yield mcp_clients
295
296
  for name, sc in mcp_server_config["mcpServers"].items():
296
297
  try:
297
298
  mc = MCPClient(name, sc)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gomyck-tools
3
- Version: 1.4.0
3
+ Version: 1.4.1
4
4
  Summary: A tools collection for python development by hao474798383
5
5
  Author-email: gomyck <hao474798383@163.com>
6
6
  License-Expression: Apache-2.0
@@ -14,12 +14,12 @@ ctools/similar.py,sha256=7mBbp7JrGGyAgA_hDmCvGJ6hGE1Lh43ocyqPkLGclyc,695
14
14
  ctools/sys_info.py,sha256=T5pcRblNHEmXEvPk2PPvQga7Hh5aDnNN72pt4U176SE,4270
15
15
  ctools/sys_log.py,sha256=T-tgOcrFggSJ2I6pLHhKpj4fvVFk_vbZBOrInKC6y3Q,2789
16
16
  ctools/ai/__init__.py,sha256=gTYAICILq48icnFbg0HCbsQO8PbU02EDOQ0JeMvfqTY,98
17
- ctools/ai/env_config.py,sha256=jBZxeKLNvEPcN7jbS2PYHXiPrxLMCc2SWMAbqO2UuoE,1313
17
+ ctools/ai/env_config.py,sha256=pZ8dG-4-CeMjBdgFHvljY2xMfyBE_0bM961UjIzm6xs,1400
18
18
  ctools/ai/llm_chat.py,sha256=dAFar0A5h3ws_kjx9MlWZAawLPYHIwvfdyO_umJgkpU,8655
19
- ctools/ai/llm_client.py,sha256=iI8kUPn8z0pgTq8mTwnIJm9bOREmSZU5btePinmgGpg,5515
19
+ ctools/ai/llm_client.py,sha256=nQKjQj8WzDqCnMsYag3Td5hYTXep2PthRm6KS7Qyc8U,5661
20
20
  ctools/ai/llm_exception.py,sha256=wsCVl0m53Mk7Xfug1obocAthlX0oEo4dytg1eOhWHPg,389
21
21
  ctools/ai/mcp/__init__.py,sha256=gTYAICILq48icnFbg0HCbsQO8PbU02EDOQ0JeMvfqTY,98
22
- ctools/ai/mcp/mcp_client.py,sha256=eDxiG6ZHa4HX-Sz63ObmxyXIq2WZwUxQt8fSw9COfGc,11589
22
+ ctools/ai/mcp/mcp_client.py,sha256=9T22s8BmerT7FrmRJr2VRhvNaV17Xz-C8jGNp08PYu0,11649
23
23
  ctools/ai/tools/__init__.py,sha256=gPc-ViRgtFlfX7JUbk5wQZ3wkJ5Ylh14CIqPwa83VPs,98
24
24
  ctools/ai/tools/json_extract.py,sha256=bgubZ2RwTo_R1X0CzMnvBWu61hglB1l6oO553645RXc,4842
25
25
  ctools/ai/tools/quick_tools.py,sha256=WeUFDLLHrP6PCs1pM3G_hRS2YSTp5XjCrJ077u06jeo,2369
@@ -75,8 +75,8 @@ ctools/web/ctoken.py,sha256=CdHm6-ykBLh7Lv8ZRMunSW40qMTkRH0ITeMLuG9z1ts,883
75
75
  ctools/web/download_util.py,sha256=EVN3fxwbUE5Q8nurAya5IYialIKBMoFtSOy0uPKyV-E,1951
76
76
  ctools/web/params_util.py,sha256=2vAuwn8OPydv_7BPKypqk4zuerPZqOGcf95wV19H1Ks,824
77
77
  ctools/web/upload_util.py,sha256=xH4Z-sz-s7EVDEz2gKXoP9OZTLc-er5yvsiLqhSDFm8,1076
78
- gomyck_tools-1.4.0.dist-info/licenses/LICENSE,sha256=X25ypfH9E6VTht2hcO8k7LCSdHUcoG_ALQt80jdYZfY,547
79
- gomyck_tools-1.4.0.dist-info/METADATA,sha256=cRhMg8qcxTte7Uy7g8kZAFb9cmaoJR882y5XO5mcqBM,1595
80
- gomyck_tools-1.4.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
81
- gomyck_tools-1.4.0.dist-info/top_level.txt,sha256=-MiIH9FYRVKp1i5_SVRkaI-71WmF1sZSRrNWFU9ls3s,7
82
- gomyck_tools-1.4.0.dist-info/RECORD,,
78
+ gomyck_tools-1.4.1.dist-info/licenses/LICENSE,sha256=X25ypfH9E6VTht2hcO8k7LCSdHUcoG_ALQt80jdYZfY,547
79
+ gomyck_tools-1.4.1.dist-info/METADATA,sha256=CDdnfnwdeNZsLWRZqCrx7cneqAbQgwXraoYDbI4ahg0,1595
80
+ gomyck_tools-1.4.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
81
+ gomyck_tools-1.4.1.dist-info/top_level.txt,sha256=-MiIH9FYRVKp1i5_SVRkaI-71WmF1sZSRrNWFU9ls3s,7
82
+ gomyck_tools-1.4.1.dist-info/RECORD,,