isa-model 0.3.3__py3-none-any.whl → 0.3.4__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.
@@ -245,6 +245,35 @@ class LangChainToolAdapter:
245
245
  return f"Error executing LangChain tool {tool.name}: {str(e)}"
246
246
 
247
247
 
248
+ # ============= OpenAI 格式工具适配器 =============
249
+
250
+ class DictToolAdapter:
251
+ """OpenAI 格式工具字典适配器"""
252
+
253
+ def __init__(self):
254
+ self.adapter_name = "dict_tool"
255
+ self.priority = 9 # Higher priority than Python functions
256
+
257
+ def can_handle(self, tool: Any) -> bool:
258
+ """检查是否是 OpenAI 格式的工具字典"""
259
+ return (isinstance(tool, dict) and
260
+ tool.get("type") == "function" and
261
+ "function" in tool and
262
+ isinstance(tool["function"], dict) and
263
+ "name" in tool["function"])
264
+
265
+ def to_openai_schema(self, tool: Any) -> Dict[str, Any]:
266
+ """工具已经是 OpenAI 格式,直接返回"""
267
+ return tool
268
+
269
+ async def execute_tool(self, tool: Any, arguments: Dict[str, Any]) -> Any:
270
+ """执行 OpenAI 格式工具(通常需要外部执行器)"""
271
+ # 对于 OpenAI 格式的工具字典,我们无法直接执行
272
+ # 这种情况下返回一个指示,让调用方处理
273
+ tool_name = tool["function"]["name"]
274
+ return f"Error: Cannot execute dict tool {tool_name} directly. Requires external executor."
275
+
276
+
248
277
  # ============= Python 函数适配器 =============
249
278
 
250
279
  class PythonFunctionAdapter:
@@ -391,10 +420,11 @@ class AdapterManager:
391
420
  StandardMessageAdapter() # 回退适配器
392
421
  ]
393
422
 
394
- # 工具适配器
423
+ # 工具适配器(按优先级排序)
395
424
  self.tool_adapters = [
396
- LangChainToolAdapter(),
397
- PythonFunctionAdapter()
425
+ DictToolAdapter(), # 最高优先级 - OpenAI格式工具
426
+ LangChainToolAdapter(), # 中等优先级 - LangChain工具
427
+ PythonFunctionAdapter() # 最低优先级 - Python函数
398
428
  ]
399
429
 
400
430
  def register_custom_adapter(self, adapter, adapter_type: str):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: isa_model
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Summary: Unified AI model serving framework
5
5
  Author: isA_Model Contributors
6
6
  Classifier: Development Status :: 3 - Alpha
@@ -43,7 +43,7 @@ isa_model/inference/services/embedding/ollama_embed_service.py,sha256=s6LPSh-D06
43
43
  isa_model/inference/services/embedding/openai_embed_service.py,sha256=cjAzmYXlY0XLgwemdlhhUVlDecgzFy2xn3DSycoYvdo,8474
44
44
  isa_model/inference/services/llm/__init__.py,sha256=C6t9w33j3Ap4oGcJal9-htifKe0rxwws_kC3F-_B_Ps,341
45
45
  isa_model/inference/services/llm/base_llm_service.py,sha256=SXxFhH2z1UYqt2ihiuursrKEjiiiC3vWCvRQVETsdVc,5238
46
- isa_model/inference/services/llm/llm_adapter.py,sha256=_NUfFzTD0t0vjcTFBIz7JKA5BCCbjBwIzp8cV3LGZ98,18791
46
+ isa_model/inference/services/llm/llm_adapter.py,sha256=cxvvBpyhyrDxe9xIuEIjAwElAFkEZmGOWtM_wlyidcg,20159
47
47
  isa_model/inference/services/llm/ollama_llm_service.py,sha256=c5xAdbbicskbxhivIQUse-QiUbCElR_Bo88wIA3dZUI,10194
48
48
  isa_model/inference/services/llm/openai_llm_service.py,sha256=e5GmO4YpVUBImQvQTZ26UwiAmHkU1RPl_vIa1dNe_NM,8148
49
49
  isa_model/inference/services/llm/triton_llm_service.py,sha256=ZFo7JoZ799Nvyi8Cz1jfWOa6TUn0hDRJtBrotadMAd4,17673
@@ -85,7 +85,7 @@ isa_model/training/core/config.py,sha256=oqgKpBvtzrN6jwLIQYQ2707lH6nmjrktRiSxp9i
85
85
  isa_model/training/core/dataset.py,sha256=XCFsnf0NUMU1dJpdvo_CAMyvXB-9_RCUEiy8TU50e20,7802
86
86
  isa_model/training/core/trainer.py,sha256=h5TjqjdFr0Fsv5y4-0siy1KmOlqLfliVaUXybvuoeXU,26932
87
87
  isa_model/training/core/utils.py,sha256=Nik0M2ssfNbWqP6fKO0Kfyhzr_H6Q19ioxB-qCYbn5E,8387
88
- isa_model-0.3.3.dist-info/METADATA,sha256=JR7HYP8HN8ZStGhRBuqFz-yH1SGnEE2I8BTU61c5QRU,12226
89
- isa_model-0.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
90
- isa_model-0.3.3.dist-info/top_level.txt,sha256=eHSy_Xb3kNkh2kK11mi1mZh0Wz91AQ5b8k2KFYO-rE8,10
91
- isa_model-0.3.3.dist-info/RECORD,,
88
+ isa_model-0.3.4.dist-info/METADATA,sha256=CDkFSLl4Z0B44AmxdCZBdwP-fNiik5kPu1Vks0iP3bU,12226
89
+ isa_model-0.3.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
90
+ isa_model-0.3.4.dist-info/top_level.txt,sha256=eHSy_Xb3kNkh2kK11mi1mZh0Wz91AQ5b8k2KFYO-rE8,10
91
+ isa_model-0.3.4.dist-info/RECORD,,