LightAgent 0.2.81__tar.gz → 0.2.85__tar.gz
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.
- {lightagent-0.2.81 → lightagent-0.2.85}/LightAgent/la_core.py +26 -11
- {lightagent-0.2.81 → lightagent-0.2.85}/PKG-INFO +1 -1
- {lightagent-0.2.81 → lightagent-0.2.85}/pyproject.toml +1 -1
- {lightagent-0.2.81 → lightagent-0.2.85}/LICENSE +0 -0
- {lightagent-0.2.81 → lightagent-0.2.85}/LightAgent/__init__.py +0 -0
- {lightagent-0.2.81 → lightagent-0.2.85}/README.de.md +0 -0
- {lightagent-0.2.81 → lightagent-0.2.85}/README.es.md +0 -0
- {lightagent-0.2.81 → lightagent-0.2.85}/README.fr.md +0 -0
- {lightagent-0.2.81 → lightagent-0.2.85}/README.ja.md +0 -0
- {lightagent-0.2.81 → lightagent-0.2.85}/README.ko.md +0 -0
- {lightagent-0.2.81 → lightagent-0.2.85}/README.md +0 -0
- {lightagent-0.2.81 → lightagent-0.2.85}/README.pt.md +0 -0
- {lightagent-0.2.81 → lightagent-0.2.85}/README.ru.md +0 -0
- {lightagent-0.2.81 → lightagent-0.2.85}/README.zh-CN.md +0 -0
|
@@ -19,7 +19,7 @@ _FUNCTION_INFO = {} # 工具名称 -> 工具info信息
|
|
|
19
19
|
_OPENAI_FUNCTION_SCHEMAS = [] # OpenAI 格式的工具描述
|
|
20
20
|
_PROMPT_FUNCTION_SCHEMAS = [] # prompt 格式的工具描述
|
|
21
21
|
|
|
22
|
-
__version__ = "0.2.
|
|
22
|
+
__version__ = "0.2.85" # 你可以根据需要设置版本号
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def register_tool_manually(tools: List[Union[str, Callable]]) -> bool:
|
|
@@ -155,7 +155,7 @@ def get_tools_str() -> str:
|
|
|
155
155
|
|
|
156
156
|
|
|
157
157
|
class LightAgent:
|
|
158
|
-
__version__ = "0.2.
|
|
158
|
+
__version__ = "0.2.85" # 将版本号放在类中
|
|
159
159
|
|
|
160
160
|
def __init__(
|
|
161
161
|
self,
|
|
@@ -479,15 +479,19 @@ class LightAgent:
|
|
|
479
479
|
output = ""
|
|
480
480
|
function_call_name = ""
|
|
481
481
|
tool_calls = response.choices[0].message.tool_calls
|
|
482
|
-
self.log("DEBUG", "tool_calls", {"tool_calls": tool_calls})
|
|
482
|
+
self.log("DEBUG", "non_stream tool_calls", {"tool_calls": tool_calls})
|
|
483
483
|
|
|
484
484
|
# 遍历所有工具调用
|
|
485
485
|
for tool_call in tool_calls:
|
|
486
486
|
function_call = tool_call.function
|
|
487
|
-
self.log("DEBUG", "function_call", {"function_call": function_call.model_dump()})
|
|
488
487
|
|
|
488
|
+
# 尝试自动修复常见转义问题
|
|
489
|
+
fixed_args = function_call.arguments.replace('\\"', '"').replace('\\\\', '\\')
|
|
490
|
+
self.log("DEBUG", "non_stream function_call", {"function_call": fixed_args})
|
|
491
|
+
|
|
492
|
+
function_args = json.loads(fixed_args)
|
|
489
493
|
# 解析函数参数
|
|
490
|
-
function_args = json.loads(function_call.arguments)
|
|
494
|
+
# function_args = json.loads(function_call.arguments)
|
|
491
495
|
|
|
492
496
|
# 调用工具并获取响应
|
|
493
497
|
tool_response = dispatch_tool(function_call.name, function_args)
|
|
@@ -496,7 +500,7 @@ class LightAgent:
|
|
|
496
500
|
|
|
497
501
|
# 如果工具返回的是生成器(流式输出),则将所有 chunk 叠加
|
|
498
502
|
if isinstance(tool_response, Generator):
|
|
499
|
-
|
|
503
|
+
print(f"Streaming response from tool: {function_call.name}")
|
|
500
504
|
for chunk in tool_response:
|
|
501
505
|
# print("Received chunk:", chunk) # 打印每个 chunk
|
|
502
506
|
if function_call_name == 'finish':
|
|
@@ -521,16 +525,18 @@ class LightAgent:
|
|
|
521
525
|
else:
|
|
522
526
|
# print(f"Non-streaming response from tool: {function_call.name}")
|
|
523
527
|
combined_response = tool_response
|
|
528
|
+
# print("tool_response type:",type(combined_response))
|
|
524
529
|
# 如果是 JSON 字符串,解析并转换为中文
|
|
525
530
|
if isinstance(combined_response, str):
|
|
526
531
|
try:
|
|
527
532
|
combined_response = json.loads(combined_response) # 解析 JSON
|
|
528
533
|
combined_response = json.dumps(combined_response, ensure_ascii=False) # 转换为中文
|
|
529
534
|
except json.JSONDecodeError:
|
|
535
|
+
combined_response = tool_response
|
|
530
536
|
pass # 如果不是 JSON 字符串,保持原样
|
|
531
537
|
tool_responses.append(combined_response) # 直接添加普通响应
|
|
532
538
|
|
|
533
|
-
self.log("INFO", "tool_response", {"tool_response": combined_response})
|
|
539
|
+
self.log("INFO", "non_stream tool_response", {"tool_response": combined_response})
|
|
534
540
|
|
|
535
541
|
# 将工具调用的结果添加到列表中
|
|
536
542
|
tool_responses.append(combined_response)
|
|
@@ -561,8 +567,13 @@ class LightAgent:
|
|
|
561
567
|
# 更新响应
|
|
562
568
|
if function_call_name == 'finish':
|
|
563
569
|
return # 如果最后调用了finish工具,则结束生成器
|
|
564
|
-
# print(params)
|
|
565
|
-
|
|
570
|
+
# print("params:",params)
|
|
571
|
+
self.log("DEBUG", "chat-completions params", {"params": params})
|
|
572
|
+
|
|
573
|
+
try:
|
|
574
|
+
response = self.client.chat.completions.create(**params)
|
|
575
|
+
except Exception as e:
|
|
576
|
+
print(f"An error occurred: {e}")
|
|
566
577
|
|
|
567
578
|
# 重试次数用尽
|
|
568
579
|
self.log("ERROR", "max_retry_reached", {"message": "Failed to generate a valid response."})
|
|
@@ -673,8 +684,11 @@ class LightAgent:
|
|
|
673
684
|
combined_response += chunk # 将每个 chunk 叠加
|
|
674
685
|
tool_responses.append(combined_response) # 将叠加后的完整响应添加到列表
|
|
675
686
|
else:
|
|
676
|
-
# print(f"Non-streaming response from tool: {
|
|
677
|
-
|
|
687
|
+
# print(f"Non-streaming response from tool: {tool_response}")
|
|
688
|
+
combined_response = tool_response
|
|
689
|
+
tool_responses.append(combined_response) # 直接添加普通响应
|
|
690
|
+
self.log("INFO", "stream tool_response", {"tool_response": combined_response})
|
|
691
|
+
|
|
678
692
|
|
|
679
693
|
except json.JSONDecodeError as e:
|
|
680
694
|
self.log("ERROR", "json_decode_error",
|
|
@@ -706,6 +720,7 @@ class LightAgent:
|
|
|
706
720
|
# 更新响应
|
|
707
721
|
if function_call_name == 'finish':
|
|
708
722
|
return # 如果最后调用了finish工具,则结束生成器
|
|
723
|
+
self.log("DEBUG", "chat-completions params", {"params": params})
|
|
709
724
|
response = self.client.chat.completions.create(**params)
|
|
710
725
|
|
|
711
726
|
# 重试次数用尽
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: LightAgent
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.85
|
|
4
4
|
Summary: **LightAgent** is an extremely lightweight active Agentic Framework with memory (`mem0`), tools (`Tools`), and a Tree of Thought (`ToT`). It supports swarm-like multi-agent collaboration, automated tool generation, and agent assessment, with underlying model support for OpenAI, Zhipu ChatGLM, Baichuan Large Model, DeepSeek R1, Qwen series large models, and more. At the same time, LightAgent supports OpenAI streaming format API service output, seamlessly integrating with major mainstream chat frameworks. 🌟
|
|
5
5
|
Home-page: https://github.com/wxai-space/LightAgent
|
|
6
6
|
License: Apache 2.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "LightAgent"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.85"
|
|
4
4
|
description = "**LightAgent** is an extremely lightweight active Agentic Framework with memory (`mem0`), tools (`Tools`), and a Tree of Thought (`ToT`). It supports swarm-like multi-agent collaboration, automated tool generation, and agent assessment, with underlying model support for OpenAI, Zhipu ChatGLM, Baichuan Large Model, DeepSeek R1, Qwen series large models, and more. At the same time, LightAgent supports OpenAI streaming format API service output, seamlessly integrating with major mainstream chat frameworks. 🌟"
|
|
5
5
|
authors = ["caiweige <caiweige@qq.com>"]
|
|
6
6
|
license = "Apache 2.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|