LightAgent 0.2.6__tar.gz → 0.2.81__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.
@@ -11,13 +11,15 @@ import logging
11
11
  import os
12
12
  import httpx
13
13
  import importlib
14
+ from openai.types.chat import ChatCompletionChunk
14
15
 
15
16
  # 全局工具注册表
16
17
  _FUNCTION_MAPPINGS = {} # 工具名称 -> 工具函数
18
+ _FUNCTION_INFO = {} # 工具名称 -> 工具info信息
17
19
  _OPENAI_FUNCTION_SCHEMAS = [] # OpenAI 格式的工具描述
18
20
  _PROMPT_FUNCTION_SCHEMAS = [] # prompt 格式的工具描述
19
21
 
20
- __version__ = "0.2.1" # 你可以根据需要设置版本号
22
+ __version__ = "0.2.81" # 你可以根据需要设置版本号
21
23
 
22
24
 
23
25
  def register_tool_manually(tools: List[Union[str, Callable]]) -> bool:
@@ -32,6 +34,9 @@ def register_tool_manually(tools: List[Union[str, Callable]]) -> bool:
32
34
 
33
35
  tool_info = func.tool_info
34
36
  tool_name = tool_info["tool_name"]
37
+
38
+ # 注册到全局字典
39
+ _FUNCTION_INFO[tool_name] = tool_info
35
40
  _FUNCTION_MAPPINGS[tool_name] = func # 注册工具
36
41
 
37
42
  # 构建 OpenAI 格式的工具描述
@@ -159,11 +164,14 @@ class LightAgent:
159
164
  instructions: Optional[str] = None, # 代理指令
160
165
  role: Optional[str] = None,
161
166
  model: str,
162
- api_key: str,
167
+ api_key: str | None = None,
163
168
  base_url: str | httpx.URL | None = None,
164
169
  websocket_base_url: str | httpx.URL | None = None,
165
170
  memory=None, # 支持外部传入记忆模块
166
171
  tree_of_thought: bool = False, # 是否启用链式思考
172
+ tot_model: str | None = None,
173
+ tot_api_key: str | None = None,
174
+ tot_base_url: str | httpx.URL | None = None,
167
175
  self_learning: bool = False, # 是否启用agent自我学习
168
176
  tools: List[Union[str, Callable]] = None, # 支持混合输入
169
177
  debug: bool = False, # 是否启用调试模式
@@ -182,6 +190,9 @@ class LightAgent:
182
190
  :param websocket_base_url: WebSocket 的基础 URL。
183
191
  :param memory: 外部传入的记忆模块,需实现 `retrieve` 和 `store` 方法。
184
192
  :param tree_of_thought: 是否启用思维链功能。
193
+ :param tot_model: 使用的模型名称。
194
+ :param tot_api_key: API 密钥。
195
+ :param tot_base_url: API 的基础 URL。
185
196
  :param tools: 工具列表,支持函数名称(字符串)或函数对象。
186
197
  :param debug: 是否启用调试模式。
187
198
  :param log_level: 日志级别(INFO, DEBUG, ERROR)。
@@ -236,9 +247,21 @@ class LightAgent:
236
247
  base_url = f"https://api.openai.com/v1"
237
248
 
238
249
  self.client = OpenAI(
239
- base_url=base_url,
240
- api_key=self.api_key
250
+ base_url = base_url,
251
+ api_key = self.api_key
241
252
  )
253
+ if self.tree_of_thought:
254
+ if tot_api_key is None:
255
+ tot_api_key = api_key
256
+ if tot_base_url is None:
257
+ tot_base_url = base_url
258
+ if not tot_model:
259
+ tot_model = "deepseek-r1" # 默认思维推理模型为deepseek-r1
260
+ self.tot_model = tot_model
261
+ self.tot_client = OpenAI(
262
+ base_url = tot_base_url,
263
+ api_key = tot_api_key
264
+ )
242
265
 
243
266
  def get_tool(self, tool_name: str) -> Callable:
244
267
  """
@@ -272,6 +295,7 @@ class LightAgent:
272
295
  # 注册工具函数
273
296
  if hasattr(tool_func, "tool_info"):
274
297
  tool_info = tool_func.tool_info
298
+ _FUNCTION_INFO[tool_name] = tool_info # 注册工具info信息
275
299
  _FUNCTION_MAPPINGS[tool_name] = tool_func
276
300
 
277
301
  # 构建 OpenAI 格式的工具描述
@@ -358,7 +382,7 @@ class LightAgent:
358
382
  query: str,
359
383
  light_swarm=None,
360
384
  stream: bool = False,
361
- max_retry: int = 5,
385
+ max_retry: int = 10,
362
386
  user_id: str = "default_user",
363
387
  history: list = None,
364
388
  metadata: Optional[Dict] = None,
@@ -398,7 +422,6 @@ class LightAgent:
398
422
  return result
399
423
 
400
424
  # 2. 正常处理任务
401
-
402
425
  now = datetime.now()
403
426
  current_date = now.strftime("%Y-%m-%d")
404
427
  current_time = now.strftime("%H:%M:%S")
@@ -483,10 +506,28 @@ class LightAgent:
483
506
  combined_response += chunk # 将每个 chunk 叠加
484
507
  if combined_response == "":
485
508
  combined_response = "".join(tool_response)
509
+
510
+ # 将 combined_response 解析为 JSON 对象(如果它是 JSON 字符串)
511
+ try:
512
+ combined_response = json.loads(combined_response) # 解析 JSON
513
+ except json.JSONDecodeError:
514
+ pass # 如果不是 JSON 字符串,保持原样
515
+
516
+ # 将 JSON 对象中的 Unicode 编码转换为中文字符
517
+ if isinstance(combined_response, dict):
518
+ combined_response = json.dumps(combined_response, ensure_ascii=False) # 确保中文字符不转义
519
+
486
520
  tool_responses.append(combined_response) # 将叠加后的完整响应添加到列表
487
521
  else:
488
522
  # print(f"Non-streaming response from tool: {function_call.name}")
489
523
  combined_response = tool_response
524
+ # 如果是 JSON 字符串,解析并转换为中文
525
+ if isinstance(combined_response, str):
526
+ try:
527
+ combined_response = json.loads(combined_response) # 解析 JSON
528
+ combined_response = json.dumps(combined_response, ensure_ascii=False) # 转换为中文
529
+ except json.JSONDecodeError:
530
+ pass # 如果不是 JSON 字符串,保持原样
490
531
  tool_responses.append(combined_response) # 直接添加普通响应
491
532
 
492
533
  self.log("INFO", "tool_response", {"tool_response": combined_response})
@@ -520,6 +561,7 @@ class LightAgent:
520
561
  # 更新响应
521
562
  if function_call_name == 'finish':
522
563
  return # 如果最后调用了finish工具,则结束生成器
564
+ # print(params)
523
565
  response = self.client.chat.completions.create(**params)
524
566
 
525
567
  # 重试次数用尽
@@ -583,6 +625,7 @@ class LightAgent:
583
625
  if tool_call["name"]: # 确保工具调用有名称
584
626
  function_call = {
585
627
  "name": tool_call["name"],
628
+ "title": _FUNCTION_INFO.get(tool_call["name"], {}).get('tool_title') or '',
586
629
  "arguments": tool_call["arguments"],
587
630
  }
588
631
  self.log("INFO", "tool_call", {"function_call": function_call})
@@ -610,7 +653,19 @@ class LightAgent:
610
653
  # print(f"Streaming response from tool: {function_call['name']}")
611
654
  combined_response = ""
612
655
  for chunk in tool_response:
613
- yield chunk
656
+ # 将工具返回的数据继续流出
657
+ if isinstance(chunk, ChatCompletionChunk):
658
+ yield chunk
659
+ else:
660
+ tool_output = {
661
+ "name": tool_call["name"],
662
+ "title": _FUNCTION_INFO.get(tool_call["name"], {}).get(
663
+ 'tool_title') or '',
664
+ "output": chunk,
665
+ }
666
+ self.log("INFO", "tool_call", {"tool_output": tool_output})
667
+ yield tool_output
668
+ # 将工具的调用信息推送给开发者
614
669
  if function_call_name == 'finish':
615
670
  content = chunk.choices[0].delta.content or ""
616
671
  combined_response += content # 将每个 chunk 叠加
@@ -788,18 +843,21 @@ class LightAgent:
788
843
 
789
844
  def run_thought(self, query: str, stream=False, tools=None):
790
845
  """使用思维树的方式 让大模型先根据get_tools_str生成一个解答用户query的工具使用计划"""
791
- tot_model = "deepseek-chat" # self.model
846
+ tot_model = self.tot_model # self.model
792
847
  tools = get_tools_str()
793
848
  if not isinstance(tools, str):
794
849
  tools = str(tools) # 确保 tools 是字符串
795
- system_prompt = f"""你是一个智能助手,请根据用户输入的问题,结合工具使用计划,生成一个思维树,并按照思维树依次调用工具步骤,最终生成一个最终回答。/n 工具列表: {tools}"""
850
+ now = datetime.now()
851
+ current_date = now.strftime("%Y-%m-%d")
852
+ current_time = now.strftime("%H:%M:%S")
853
+ system_prompt = f"""你是一个智能助手,请根据用户输入的问题,结合工具使用计划,生成一个思维树,并按照思维树依次调用工具步骤,最终生成一个最终回答。/n 今日的日期: {current_date} 当前时间: {current_time} /n 工具列表: {tools}"""
796
854
  self.log("DEBUG", "run_thought", {"system_prompt": system_prompt})
797
855
 
798
856
  # 第一次请求,生成初始的工具使用计划
799
857
  params = dict(model=tot_model,
800
858
  messages=[{"role": "system", "content": system_prompt}, {"role": "user", "content": query}],
801
859
  stream=False)
802
- response = self.client.chat.completions.create(**params)
860
+ response = self.tot_client.chat.completions.create(**params)
803
861
  initial_content = response.choices[0].message.content
804
862
  self.log("DEBUG", "initial_response", {"response": initial_content})
805
863
 
@@ -812,7 +870,7 @@ class LightAgent:
812
870
  ], stream=False)
813
871
  self.log("DEBUG", "reflection_params", {"params": reflection_params})
814
872
 
815
- reflection_response = self.client.chat.completions.create(**reflection_params)
873
+ reflection_response = self.tot_client.chat.completions.create(**reflection_params)
816
874
  refined_content = reflection_response.choices[0].message.content
817
875
  self.log("DEBUG", "refined_response", {"response": refined_content})
818
876
  return refined_content
@@ -1033,4 +1091,4 @@ class LightSwarm:
1033
1091
  if __name__ == "__main__":
1034
1092
  # Example of registering and using a tool
1035
1093
  print("This is LightAgent")
1036
- # print(dispatch_tool("example_tool", {"param1": "test"}))
1094
+ # print(dispatch_tool("example_tool", {"param1": "test"}))
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: LightAgent
3
- Version: 0.2.6
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, 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. 🌟
3
+ Version: 0.2.81
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
7
7
  Author: caiweige
@@ -54,7 +54,7 @@ Description-Content-Type: text/markdown
54
54
  <h1>LightAgent🚀 (Next Generation Agentic AI Framework)</h1>
55
55
  </div>
56
56
 
57
- **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, 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. 🌟
57
+ **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, Qwen, stepfun and more. At the same time, LightAgent supports OpenAI streaming format API service output, seamlessly integrating with major mainstream chat frameworks. 🌟
58
58
 
59
59
  ---
60
60
 
@@ -72,6 +72,15 @@ Description-Content-Type: text/markdown
72
72
  - **Tool Generator** 🚀: Just provide your API documentation to the [Tool Generator], which will automatically create exclusive tools for you, allowing you to quickly build hundreds of personalized custom tools in just 1 hour to improve efficiency and unleash your creative potential.
73
73
  - **Agent Self-Learning** 🧠️: Each agent has its own scene memory capabilities and the ability to self-learn from user conversations.
74
74
 
75
+ ---
76
+ ## News
77
+ - <img src="https://img.alicdn.com/imgextra/i3/O1CN01SFL0Gu26nrQBFKXFR_!!6000000007707-2-tps-500-500.png" alt="new" width="30" height="30"/>**[2025-02-19]** LightAgent v0.2.7 supports deepseek-r1 model for tot now.Significantly enhances the multi-tool planning capability for complex tasks.
78
+ - **[2025-02-06]** LightAgent version 0.2.5 is released now.
79
+ - **[2025-01-20]** LightAgent version 0.2.0 is released now.
80
+ - **[2025-01-05]** LightAgent version 0.1.0 is released now.
81
+
82
+ ---
83
+
75
84
  ## 🚧 Coming Soon
76
85
 
77
86
  - **Adaptive Tool Mechanism** 🛠️: Supports adding an unlimited number of tools, allowing the large model to first select a candidate tool set from thousands of tools, filtering irrelevant tools before submitting context to the large model, significantly reducing token consumption.
@@ -79,6 +88,7 @@ Description-Content-Type: text/markdown
79
88
  - **Agent Assessment** 📊: Built-in agent assessment tool for conveniently evaluating and optimizing the agents you build, aligning with business scenarios, and continuously improving intelligence levels.
80
89
 
81
90
  ## Built-in "Thought Flow"
91
+ ### ToT now supports DeepSeek-R1.
82
92
  The Thought Flow method effectively addresses challenges in complex scenarios through systematic, structured, and flexible thinking processes. Here are the specific implementation steps:
83
93
  ```text
84
94
  Problem Definition: Clarify the core problems and objectives.
@@ -346,6 +356,7 @@ def get_weather(
346
356
  # Define tool information inside the function
347
357
  get_weather.tool_info = {
348
358
  "tool_name": "get_weather",
359
+ "tool_title": "get weather",
349
360
  "tool_description": "Get current weather information for the specified city.",
350
361
  "tool_params": [
351
362
  {"name": "city_name", "description": "The name of the city to query", "type": "string", "required": True},
@@ -368,6 +379,7 @@ def search_news(
368
379
  # Define tool information inside the function
369
380
  search_news.tool_info = {
370
381
  "tool_name": "search_news",
382
+ "tool_title": "search news",
371
383
  "tool_description": "Search news based on keywords.",
372
384
  "tool_params": [
373
385
  {"name": "keyword", "description": "Search keyword", "type": "string", "required": True},
@@ -488,7 +500,7 @@ agent.create_tool(text, tools_directory=tools_directory)
488
500
  After execution, two files will be generated in the tools directory: get_stock_kline_data.py and get_stock_realtime_data.py.
489
501
 
490
502
  ### 4. Tree of Thought (ToT)
491
- The built-in Tree of Thought module supports complex task decomposition and multi-step reasoning. Through the Tree of Thought, the agent can better handle complex tasks.
503
+ Currently, it is already supported to independently customize the use of the deepseek-r1 model for planning and thinking.The built-in Tree of Thought module supports complex task decomposition and multi-step reasoning. Through the Tree of Thought, the agent can better handle complex tasks.
492
504
 
493
505
  ```python
494
506
  # Enable Tree of Thought
@@ -497,6 +509,9 @@ agent = LightAgent(
497
509
  api_key="your_api_key",
498
510
  base_url="your_base_url",
499
511
  tree_of_thought=True, # Enable Tree of Thought
512
+ tot_model="deepseek-r1",
513
+ tot_api_key="sk-uXx0H0B***17778F1", # your deepseek r1 API Key
514
+ tot_base_url="https://api.deepseek.com/v1", # api url
500
515
  )
501
516
  ```
502
517
 
@@ -758,7 +773,7 @@ We look forward to your feedback and work together to make LightAgent even stron
758
773
  <h1>LightAgent🚀(下一代Agentic AI框架)</h1>
759
774
  </div>
760
775
 
761
- **LightAgent** 是一个极其轻量的带记忆(`mem0`)、工具(`Tools`)、思维树(`ToT`)的主动式 Agentic Framework(自主性框架)。它支持比Openai Swarm更简单的多智能体协同,构建具备自我学习能力的agent,并支持Agent测评,底层模型支持 OpenAI、智谱 ChatGLM、DeepSeek、阶跃星辰、Qwen千问大模型等。同时,LightAgent 支持 OpenAI 流格式 API 服务输出,无缝接入各大主流 Chat 框架。🌟
776
+ **LightAgent** 是一个极其轻量的带记忆(`mem0`)、工具(`Tools`)、思维树(`ToT`)的主动式 Agentic Framework(自主性框架)。它支持比Openai Swarm更简单的多智能体协同,构建具备自我学习能力的agent,并支持Agent测评,底层模型支持 OpenAI、智谱 ChatGLM、DeepSeek、阶跃星辰、Qwen通义千问大模型等。同时,LightAgent 支持 OpenAI 流格式 API 服务输出,无缝接入各大主流 Chat 框架。🌟
762
777
 
763
778
  ---
764
779
 
@@ -776,6 +791,14 @@ We look forward to your feedback and work together to make LightAgent even stron
776
791
  - **Tools工具生成器** 🚀:只需将您的API文档交给[Tools工具生成器],它将自动化地为您打造专属的tools,助您在短短1小时内快速构建数百个个性化的自定义工具,提升效率,释放您的创新潜能。
777
792
  - **agent自我学习** 🧠️:每个agent拥有自己的场景记忆能力,拥有从用户的对话中进行自我学习能力。
778
793
 
794
+ ---
795
+ ## 新闻
796
+ - <img src="https://img.alicdn.com/imgextra/i3/O1CN01SFL0Gu26nrQBFKXFR_!!6000000007707-2-tps-500-500.png" alt="new" width="30" height="30"/>**[2025-02-19]** LightAgent v0.2.7 支持单独采用 deepseek-r1 作为的agent推理规划ToT引擎,大幅度提升复杂任务的多工具Plan能力.
797
+ - **[2025-02-06]** LightAgent version 0.2.5 is released now.
798
+ - **[2025-01-20]** LightAgent version 0.2.0 is released now.
799
+ - **[2025-01-05]** LightAgent version 0.1.0 is released now.
800
+
801
+ ---
779
802
 
780
803
  ## 🚧 即将推出
781
804
 
@@ -784,7 +807,8 @@ We look forward to your feedback and work together to make LightAgent even stron
784
807
  - **Agent 测评** 📊:内置 Agent 测评工具,方便评估和优化你构建的Agent,对齐业务场景,持续提升智能水平。
785
808
 
786
809
 
787
- ## 内置 “思考流”
810
+ ## 🔥内置 “思考流”
811
+ ### ToT现已支持DeepSeek-R1
788
812
  (Thought Flow)方法通过系统性、结构化和灵活的思维过程,能够有效应对复杂场景中的挑战。
789
813
  以下是具体实施步骤:
790
814
  ```text
@@ -1055,6 +1079,7 @@ def get_weather(
1055
1079
  # 在函数内部定义工具信息
1056
1080
  get_weather.tool_info = {
1057
1081
  "tool_name": "get_weather",
1082
+ "tool_name": "获取天气",
1058
1083
  "tool_description": "获取指定城市的当前天气信息",
1059
1084
  "tool_params": [
1060
1085
  {"name": "city_name", "description": "要查询的城市名称", "type": "string", "required": True},
@@ -1077,6 +1102,7 @@ def search_news(
1077
1102
  # 在函数内部定义工具信息
1078
1103
  search_news.tool_info = {
1079
1104
  "tool_name": "search_news",
1105
+ "tool_name": "联网搜索",
1080
1106
  "tool_description": "根据关键词搜索新闻",
1081
1107
  "tool_params": [
1082
1108
  {"name": "keyword", "description": "搜索关键词", "type": "string", "required": True},
@@ -1197,7 +1223,7 @@ agent.create_tool(text, tools_directory=tools_directory)
1197
1223
  执行后将在tools目录中生成2个文件:get_stock_kline_data.py和get_stock_realtime_data.py
1198
1224
 
1199
1225
  ### 4. 思维树(ToT)
1200
- 内置思维树模块,支持复杂任务分解和多步推理。通过思维树,Agent 可以更好地处理复杂任务。
1226
+ 当前已经支持单独自定义使用deepseek-r1模型来做规划思考。内置思维树模块,支持复杂任务分解和多步推理。通过思维树,Agent 可以更好地处理复杂任务。
1201
1227
 
1202
1228
  ```python
1203
1229
  # 启用思维树
@@ -1206,6 +1232,9 @@ agent = LightAgent(
1206
1232
  api_key="your_api_key",
1207
1233
  base_url= "your_base_url",
1208
1234
  tree_of_thought=True, # 启用思维树
1235
+ tot_model="deepseek-r1",
1236
+ tot_api_key="sk-uXx0H0B***17778F1", # 替换为你的 deepseek r1 API Key
1237
+ tot_base_url="https://api.deepseek.com/v1", # api url
1209
1238
  )
1210
1239
  ```
1211
1240
 
@@ -33,7 +33,7 @@
33
33
  <h1>LightAgent🚀 (Next Generation Agentic AI Framework)</h1>
34
34
  </div>
35
35
 
36
- **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, 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. 🌟
36
+ **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, Qwen, stepfun and more. At the same time, LightAgent supports OpenAI streaming format API service output, seamlessly integrating with major mainstream chat frameworks. 🌟
37
37
 
38
38
  ---
39
39
 
@@ -51,6 +51,15 @@
51
51
  - **Tool Generator** 🚀: Just provide your API documentation to the [Tool Generator], which will automatically create exclusive tools for you, allowing you to quickly build hundreds of personalized custom tools in just 1 hour to improve efficiency and unleash your creative potential.
52
52
  - **Agent Self-Learning** 🧠️: Each agent has its own scene memory capabilities and the ability to self-learn from user conversations.
53
53
 
54
+ ---
55
+ ## News
56
+ - <img src="https://img.alicdn.com/imgextra/i3/O1CN01SFL0Gu26nrQBFKXFR_!!6000000007707-2-tps-500-500.png" alt="new" width="30" height="30"/>**[2025-02-19]** LightAgent v0.2.7 supports deepseek-r1 model for tot now.Significantly enhances the multi-tool planning capability for complex tasks.
57
+ - **[2025-02-06]** LightAgent version 0.2.5 is released now.
58
+ - **[2025-01-20]** LightAgent version 0.2.0 is released now.
59
+ - **[2025-01-05]** LightAgent version 0.1.0 is released now.
60
+
61
+ ---
62
+
54
63
  ## 🚧 Coming Soon
55
64
 
56
65
  - **Adaptive Tool Mechanism** 🛠️: Supports adding an unlimited number of tools, allowing the large model to first select a candidate tool set from thousands of tools, filtering irrelevant tools before submitting context to the large model, significantly reducing token consumption.
@@ -58,6 +67,7 @@
58
67
  - **Agent Assessment** 📊: Built-in agent assessment tool for conveniently evaluating and optimizing the agents you build, aligning with business scenarios, and continuously improving intelligence levels.
59
68
 
60
69
  ## Built-in "Thought Flow"
70
+ ### ToT now supports DeepSeek-R1.
61
71
  The Thought Flow method effectively addresses challenges in complex scenarios through systematic, structured, and flexible thinking processes. Here are the specific implementation steps:
62
72
  ```text
63
73
  Problem Definition: Clarify the core problems and objectives.
@@ -325,6 +335,7 @@ def get_weather(
325
335
  # Define tool information inside the function
326
336
  get_weather.tool_info = {
327
337
  "tool_name": "get_weather",
338
+ "tool_title": "get weather",
328
339
  "tool_description": "Get current weather information for the specified city.",
329
340
  "tool_params": [
330
341
  {"name": "city_name", "description": "The name of the city to query", "type": "string", "required": True},
@@ -347,6 +358,7 @@ def search_news(
347
358
  # Define tool information inside the function
348
359
  search_news.tool_info = {
349
360
  "tool_name": "search_news",
361
+ "tool_title": "search news",
350
362
  "tool_description": "Search news based on keywords.",
351
363
  "tool_params": [
352
364
  {"name": "keyword", "description": "Search keyword", "type": "string", "required": True},
@@ -467,7 +479,7 @@ agent.create_tool(text, tools_directory=tools_directory)
467
479
  After execution, two files will be generated in the tools directory: get_stock_kline_data.py and get_stock_realtime_data.py.
468
480
 
469
481
  ### 4. Tree of Thought (ToT)
470
- The built-in Tree of Thought module supports complex task decomposition and multi-step reasoning. Through the Tree of Thought, the agent can better handle complex tasks.
482
+ Currently, it is already supported to independently customize the use of the deepseek-r1 model for planning and thinking.The built-in Tree of Thought module supports complex task decomposition and multi-step reasoning. Through the Tree of Thought, the agent can better handle complex tasks.
471
483
 
472
484
  ```python
473
485
  # Enable Tree of Thought
@@ -476,6 +488,9 @@ agent = LightAgent(
476
488
  api_key="your_api_key",
477
489
  base_url="your_base_url",
478
490
  tree_of_thought=True, # Enable Tree of Thought
491
+ tot_model="deepseek-r1",
492
+ tot_api_key="sk-uXx0H0B***17778F1", # your deepseek r1 API Key
493
+ tot_base_url="https://api.deepseek.com/v1", # api url
479
494
  )
480
495
  ```
481
496
 
@@ -33,7 +33,7 @@
33
33
  <h1>LightAgent🚀(下一代Agentic AI框架)</h1>
34
34
  </div>
35
35
 
36
- **LightAgent** 是一个极其轻量的带记忆(`mem0`)、工具(`Tools`)、思维树(`ToT`)的主动式 Agentic Framework(自主性框架)。它支持比Openai Swarm更简单的多智能体协同,构建具备自我学习能力的agent,并支持Agent测评,底层模型支持 OpenAI、智谱 ChatGLM、DeepSeek、阶跃星辰、Qwen千问大模型等。同时,LightAgent 支持 OpenAI 流格式 API 服务输出,无缝接入各大主流 Chat 框架。🌟
36
+ **LightAgent** 是一个极其轻量的带记忆(`mem0`)、工具(`Tools`)、思维树(`ToT`)的主动式 Agentic Framework(自主性框架)。它支持比Openai Swarm更简单的多智能体协同,构建具备自我学习能力的agent,并支持Agent测评,底层模型支持 OpenAI、智谱 ChatGLM、DeepSeek、阶跃星辰、Qwen通义千问大模型等。同时,LightAgent 支持 OpenAI 流格式 API 服务输出,无缝接入各大主流 Chat 框架。🌟
37
37
 
38
38
  ---
39
39
 
@@ -51,6 +51,14 @@
51
51
  - **Tools工具生成器** 🚀:只需将您的API文档交给[Tools工具生成器],它将自动化地为您打造专属的tools,助您在短短1小时内快速构建数百个个性化的自定义工具,提升效率,释放您的创新潜能。
52
52
  - **agent自我学习** 🧠️:每个agent拥有自己的场景记忆能力,拥有从用户的对话中进行自我学习能力。
53
53
 
54
+ ---
55
+ ## 新闻
56
+ - <img src="https://img.alicdn.com/imgextra/i3/O1CN01SFL0Gu26nrQBFKXFR_!!6000000007707-2-tps-500-500.png" alt="new" width="30" height="30"/>**[2025-02-19]** LightAgent v0.2.7 支持单独采用 deepseek-r1 作为的agent推理规划ToT引擎,大幅度提升复杂任务的多工具Plan能力.
57
+ - **[2025-02-06]** LightAgent version 0.2.5 is released now.
58
+ - **[2025-01-20]** LightAgent version 0.2.0 is released now.
59
+ - **[2025-01-05]** LightAgent version 0.1.0 is released now.
60
+
61
+ ---
54
62
 
55
63
  ## 🚧 即将推出
56
64
 
@@ -59,7 +67,8 @@
59
67
  - **Agent 测评** 📊:内置 Agent 测评工具,方便评估和优化你构建的Agent,对齐业务场景,持续提升智能水平。
60
68
 
61
69
 
62
- ## 内置 “思考流”
70
+ ## 🔥内置 “思考流”
71
+ ### ToT现已支持DeepSeek-R1
63
72
  (Thought Flow)方法通过系统性、结构化和灵活的思维过程,能够有效应对复杂场景中的挑战。
64
73
  以下是具体实施步骤:
65
74
  ```text
@@ -330,6 +339,7 @@ def get_weather(
330
339
  # 在函数内部定义工具信息
331
340
  get_weather.tool_info = {
332
341
  "tool_name": "get_weather",
342
+ "tool_name": "获取天气",
333
343
  "tool_description": "获取指定城市的当前天气信息",
334
344
  "tool_params": [
335
345
  {"name": "city_name", "description": "要查询的城市名称", "type": "string", "required": True},
@@ -352,6 +362,7 @@ def search_news(
352
362
  # 在函数内部定义工具信息
353
363
  search_news.tool_info = {
354
364
  "tool_name": "search_news",
365
+ "tool_name": "联网搜索",
355
366
  "tool_description": "根据关键词搜索新闻",
356
367
  "tool_params": [
357
368
  {"name": "keyword", "description": "搜索关键词", "type": "string", "required": True},
@@ -472,7 +483,7 @@ agent.create_tool(text, tools_directory=tools_directory)
472
483
  执行后将在tools目录中生成2个文件:get_stock_kline_data.py和get_stock_realtime_data.py
473
484
 
474
485
  ### 4. 思维树(ToT)
475
- 内置思维树模块,支持复杂任务分解和多步推理。通过思维树,Agent 可以更好地处理复杂任务。
486
+ 当前已经支持单独自定义使用deepseek-r1模型来做规划思考。内置思维树模块,支持复杂任务分解和多步推理。通过思维树,Agent 可以更好地处理复杂任务。
476
487
 
477
488
  ```python
478
489
  # 启用思维树
@@ -481,6 +492,9 @@ agent = LightAgent(
481
492
  api_key="your_api_key",
482
493
  base_url= "your_base_url",
483
494
  tree_of_thought=True, # 启用思维树
495
+ tot_model="deepseek-r1",
496
+ tot_api_key="sk-uXx0H0B***17778F1", # 替换为你的 deepseek r1 API Key
497
+ tot_base_url="https://api.deepseek.com/v1", # api url
484
498
  )
485
499
  ```
486
500
 
@@ -1,7 +1,7 @@
1
1
  [tool.poetry]
2
2
  name = "LightAgent"
3
- version = "0.2.6"
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, 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. 🌟"
3
+ version = "0.2.81"
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"
7
7
  readme = [
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes