Little cleanup
This commit is contained in:
parent
a516bfe31a
commit
3a50722f4c
@ -15,10 +15,7 @@ from lib.personality import PERSONALITY
|
|||||||
from tools.vision import ImagePayload
|
from tools.vision import ImagePayload
|
||||||
from scripts import loggorilla
|
from scripts import loggorilla
|
||||||
|
|
||||||
|
|
||||||
def _cap_output(result):
|
def _cap_output(result):
|
||||||
# Jaring pengaman ukuran output tool. Hormati semantics config:
|
|
||||||
# AGENT_MAX_TOOL_OUTPUT <= 0 = unlimited (tidak dipotong).
|
|
||||||
limit = getattr(config, "AGENT_MAX_TOOL_OUTPUT", 0)
|
limit = getattr(config, "AGENT_MAX_TOOL_OUTPUT", 0)
|
||||||
if not limit or limit <= 0:
|
if not limit or limit <= 0:
|
||||||
return result
|
return result
|
||||||
@ -27,7 +24,6 @@ def _cap_output(result):
|
|||||||
return result[:limit] + f"\n... [truncated: {omitted} chars omitted]"
|
return result[:limit] + f"\n... [truncated: {omitted} chars omitted]"
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def execute_tool(tool_call, TOOL_HANDLERS):
|
def execute_tool(tool_call, TOOL_HANDLERS):
|
||||||
tname = tool_call['function']['name']
|
tname = tool_call['function']['name']
|
||||||
targs = json.loads(tool_call['function']['arguments'])
|
targs = json.loads(tool_call['function']['arguments'])
|
||||||
@ -75,12 +71,9 @@ class SessionStore:
|
|||||||
if self._on_append:
|
if self._on_append:
|
||||||
self._on_append(message)
|
self._on_append(message)
|
||||||
|
|
||||||
|
|
||||||
class AgentResult:
|
class AgentResult:
|
||||||
"""Hasil satu kali jalan loop."""
|
# Hasil satu kali jalan loop.
|
||||||
|
def __init__(self, content=None, session_ended=False, model_info=None, warning=None, is_multimodal=False):
|
||||||
def __init__(self, content=None, session_ended=False,
|
|
||||||
model_info=None, warning=None, is_multimodal=False):
|
|
||||||
self.content = content # str | None
|
self.content = content # str | None
|
||||||
self.session_ended = session_ended # tool end_session pernah dipanggil
|
self.session_ended = session_ended # tool end_session pernah dipanggil
|
||||||
self.model_info = model_info or {} # model yang benar-benar menjawab
|
self.model_info = model_info or {} # model yang benar-benar menjawab
|
||||||
@ -284,5 +277,4 @@ def run_agent_loop(store, llm_client, TOOLS, TOOL_HANDLERS, max_iterations,
|
|||||||
})
|
})
|
||||||
observer.on_max_iterations(max_iterations)
|
observer.on_max_iterations(max_iterations)
|
||||||
observer.on_run_end()
|
observer.on_run_end()
|
||||||
return AgentResult(content=None, session_ended=session_ended,
|
return AgentResult(content=None, session_ended=session_ended, model_info=model_info, warning=warning)
|
||||||
model_info=model_info, warning=warning)
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user