Update agent code and tool schema
This commit is contained in:
@@ -21,7 +21,7 @@ def init():
|
|||||||
from sidercall import sider_cookie, oai_apikey, oai_apibase
|
from sidercall import sider_cookie, oai_apikey, oai_apibase
|
||||||
llm_sessions = []
|
llm_sessions = []
|
||||||
if sider_cookie: llm_sessions += [SiderLLMSession(default_model=x) for x in \
|
if sider_cookie: llm_sessions += [SiderLLMSession(default_model=x) for x in \
|
||||||
["gemini-3.0-flash", "claude-4.5-haiku", "gpt-5-mini"]]
|
["gemini-3.0-flash", "claude-haiku-4.5", "gpt-5-mini"]]
|
||||||
if oai_apikey: llm_sessions += [LLMSession(api_key=oai_apikey, api_base=oai_apibase)]
|
if oai_apikey: llm_sessions += [LLMSession(api_key=oai_apikey, api_base=oai_apibase)]
|
||||||
if len(llm_sessions) == 0:
|
if len(llm_sessions) == 0:
|
||||||
st.error("⚠️ 未配置任何可用的 LLM 接口,请在 mykey.py 中添加 sider_cookie 或 oai_apikey+oai_apibase 等信息后重启。")
|
st.error("⚠️ 未配置任何可用的 LLM 接口,请在 mykey.py 中添加 sider_cookie 或 oai_apikey+oai_apibase 等信息后重启。")
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
"candidates": {"type": "array", "items": {"type": "string"}, "description": "提供给用户的可选快捷选项列表。"}}, "required": ["question"]}
|
"candidates": {"type": "array", "items": {"type": "string"}, "description": "提供给用户的可选快捷选项列表。"}}, "required": ["question"]}
|
||||||
}},
|
}},
|
||||||
{"type": "function", "function": {
|
{"type": "function", "function": {
|
||||||
"name": "distill_good_memory",
|
"name": "conclude_and_reflect",
|
||||||
"description": "当模型认为当前任务执行完美,且有具有长期价值的环境事实或用户偏好需要提炼并存入全局记忆时,调用此工具。注意:此工具无参数,调用即代表触发记忆提炼流程。",
|
"description": "当模型认为当前任务执行完美,且有具有长期价值的环境事实或用户偏好需要提炼并存入全局记忆时,调用此工具。注意:此工具无参数,调用即代表触发记忆提炼流程。",
|
||||||
"parameters": {"type": "object", "properties": {}}}
|
"parameters": {"type": "object", "properties": {}}}
|
||||||
}
|
}
|
||||||
|
|||||||
7
ga.py
7
ga.py
@@ -363,6 +363,9 @@ class GenericAgentHandler(BaseHandler):
|
|||||||
show_linenos = args.get("show_linenos", True)
|
show_linenos = args.get("show_linenos", True)
|
||||||
result = file_read(path, start=start, keyword=keyword,
|
result = file_read(path, start=start, keyword=keyword,
|
||||||
count=count, show_linenos=show_linenos)
|
count=count, show_linenos=show_linenos)
|
||||||
|
if show_linenos:
|
||||||
|
tips = '由于设置了show_linenos,以下返回信息为:(行号|)内容 。\n'
|
||||||
|
result = tips + result
|
||||||
next_prompt = self._get_anchor_prompt()
|
next_prompt = self._get_anchor_prompt()
|
||||||
return StepOutcome(result, next_prompt=next_prompt)
|
return StepOutcome(result, next_prompt=next_prompt)
|
||||||
|
|
||||||
@@ -395,7 +398,7 @@ class GenericAgentHandler(BaseHandler):
|
|||||||
yield "[Info] No tool called. Final response to user.\n"
|
yield "[Info] No tool called. Final response to user.\n"
|
||||||
return StepOutcome(response, next_prompt=None, should_exit=True)
|
return StepOutcome(response, next_prompt=None, should_exit=True)
|
||||||
|
|
||||||
def do_distill_good_memory(self, args, response):
|
def do_conclude_and_reflect(self, args, response):
|
||||||
'''Agent觉得当前任务完成后有重要信息需要记忆时调用此工具。
|
'''Agent觉得当前任务完成后有重要信息需要记忆时调用此工具。
|
||||||
目前只支持全局记忆,暂不处理过程记忆或特定任务经验。
|
目前只支持全局记忆,暂不处理过程记忆或特定任务经验。
|
||||||
'''
|
'''
|
||||||
@@ -420,7 +423,7 @@ def get_global_memory():
|
|||||||
try:
|
try:
|
||||||
with open('memory/global_mem_insight.txt', 'r', encoding='utf-8') as f: insight = f.read()
|
with open('memory/global_mem_insight.txt', 'r', encoding='utf-8') as f: insight = f.read()
|
||||||
prompt += f"\n\n[Global Memory Insight]\n"
|
prompt += f"\n\n[Global Memory Insight]\n"
|
||||||
prompt += 'IMPORTANT PATHS: ../memory/global_mem.txt (Facts), ../memory/global_mem_insight.txt (Logic), ../ (Your Code Root).\n'
|
prompt += 'IMPORTANT PATHS: ../memory/global_mem.txt (Facts), ../memory/global_mem_insight.txt (Logic), ../ (Your Code Root), ../temp (./, Your default cwd) \n'
|
||||||
prompt += 'MEM_RULE: Insight is the index of Facts. Sync Insight whenever Facts change. For details, read Facts.\n'
|
prompt += 'MEM_RULE: Insight is the index of Facts. Sync Insight whenever Facts change. For details, read Facts.\n'
|
||||||
prompt += "EXT: ../memory/ may contain other task-specific memories.\n"
|
prompt += "EXT: ../memory/ may contain other task-specific memories.\n"
|
||||||
prompt += insight + "\n"
|
prompt += insight + "\n"
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ class ToolClient:
|
|||||||
data = tryparse(json_str)
|
data = tryparse(json_str)
|
||||||
func_name = data.get('function') or data.get('tool')
|
func_name = data.get('function') or data.get('tool')
|
||||||
args = data.get('arguments') or data.get('args')
|
args = data.get('arguments') or data.get('args')
|
||||||
if args is None: args = {}
|
if args is None: args = data
|
||||||
if func_name: tool_calls = [MockToolCall(func_name, args)]
|
if func_name: tool_calls = [MockToolCall(func_name, args)]
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
print("[Warn] Failed to parse tool_use JSON:", json_str)
|
print("[Warn] Failed to parse tool_use JSON:", json_str)
|
||||||
|
|||||||
Reference in New Issue
Block a user