fix: tool_use regex negative lookahead to prevent cross-tag matching; tgapp relative path resolve
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import os, sys, re, threading, asyncio, queue as Q, socket, time
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
_TEMP_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'temp')
|
||||
from agentmain import GeneraticAgent
|
||||
try:
|
||||
from telegram import Update
|
||||
@@ -65,6 +66,7 @@ async def _stream(dq, msg):
|
||||
if done:
|
||||
files = re.findall(r'\[FILE:([^\]]+)\]', show[-1000:])
|
||||
for fpath in files:
|
||||
if not os.path.isabs(fpath): fpath = os.path.join(_TEMP_DIR, fpath)
|
||||
if os.path.exists(fpath):
|
||||
if fpath.lower().endswith(('.png','.jpg','.jpeg','.gif','.webp')):
|
||||
try: await msg.reply_photo(open(fpath,'rb'))
|
||||
|
||||
@@ -717,7 +717,7 @@ class ToolClient:
|
||||
remaining_text = re.sub(think_pattern, "", remaining_text, flags=re.DOTALL)
|
||||
|
||||
tool_calls = []; json_strs = []; errors = []
|
||||
tool_pattern = r"<tool_use>(.{15,}?)</tool_use>"
|
||||
tool_pattern = r"<tool_use>((?:(?!<tool_use>).){15,}?)</tool_use>"
|
||||
tool_all = re.findall(tool_pattern, remaining_text, re.DOTALL)
|
||||
|
||||
if tool_all:
|
||||
|
||||
Reference in New Issue
Block a user