fix: Address code review feedback on tool format normalization
This commit is contained in:
@@ -145,11 +145,9 @@ class LLM:
|
|||||||
if delta:
|
if delta:
|
||||||
accumulated += delta
|
accumulated += delta
|
||||||
if "</function>" in accumulated or "</invoke>" in accumulated:
|
if "</function>" in accumulated or "</invoke>" in accumulated:
|
||||||
for end_tag in ("</function>", "</invoke>"):
|
end_tag = "</function>" if "</function>" in accumulated else "</invoke>"
|
||||||
pos = accumulated.find(end_tag)
|
pos = accumulated.find(end_tag)
|
||||||
if pos != -1:
|
|
||||||
accumulated = accumulated[: pos + len(end_tag)]
|
accumulated = accumulated[: pos + len(end_tag)]
|
||||||
break
|
|
||||||
yield LLMResponse(content=accumulated)
|
yield LLMResponse(content=accumulated)
|
||||||
done_streaming = 1
|
done_streaming = 1
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import re
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
_INVOKE_OPEN = re.compile(r'<invoke\s+name=["\']([^"\']+)["\']\s*>')
|
_INVOKE_OPEN = re.compile(r'<invoke\s+name=["\']([^"\']+)["\']>')
|
||||||
_PARAM_NAME_ATTR = re.compile(r'<parameter\s+name=["\']([^"\']+)["\']\s*>')
|
_PARAM_NAME_ATTR = re.compile(r'<parameter\s+name=["\']([^"\']+)["\']>')
|
||||||
_FUNCTION_CALLS_TAG = re.compile(r"</?function_calls>")
|
_FUNCTION_CALLS_TAG = re.compile(r"</?function_calls>")
|
||||||
_QUOTED_FUNCTION = re.compile(r"""<function\s*=\s*['"]([^"']+)['"]\s*>""")
|
_QUOTED_FUNCTION = re.compile(r"""<function\s*=\s*['"]([^"']+)['"]\s*>""")
|
||||||
_QUOTED_PARAMETER = re.compile(r"""<parameter\s*=\s*['"]([^"']+)['"]\s*>""")
|
_QUOTED_PARAMETER = re.compile(r"""<parameter\s*=\s*['"]([^"']+)['"]\s*>""")
|
||||||
|
|||||||
Reference in New Issue
Block a user