New web interface, move llm engine to separate process
This commit is contained in:
@@ -4,7 +4,6 @@ import xml.etree.ElementTree as ET
|
||||
from .llm_engine import LlmEngine
|
||||
from .response_parser import ResponseParser
|
||||
from .system_metrics import SystemMetrics
|
||||
from .util import pretty_print_element
|
||||
from .working_memory import WorkingMemory
|
||||
|
||||
class BaseAgent(ABC):
|
||||
@@ -36,8 +35,13 @@ class BaseAgent(ABC):
|
||||
def system_prompt(self) -> str:
|
||||
"""Get the system prompt."""
|
||||
return f"{self._system_prompt}\n{self._action_schema}"
|
||||
|
||||
@property
|
||||
def working_memory(self) -> WorkingMemory:
|
||||
"""Get the working memory."""
|
||||
return self._working_memory
|
||||
|
||||
def _compile_context(self, llmEngine: LlmEngine) -> str:
|
||||
def _compile_context(self, llmEngine: LlmEngine) -> ET:
|
||||
"""
|
||||
Compile the current context for LLM inference.
|
||||
Includes system metrics and working memory entries.
|
||||
@@ -60,15 +64,13 @@ class BaseAgent(ABC):
|
||||
|
||||
for entry in memory_context:
|
||||
context.append(entry)
|
||||
|
||||
context_str = pretty_print_element(context)
|
||||
|
||||
# Calculate token usage percentage
|
||||
token_count = llmEngine.token_count(self.system_prompt, context_str)
|
||||
token_count = llmEngine.token_count(self.system_prompt, context)
|
||||
token_limit = llmEngine.token_limit()
|
||||
context_usage = (float(token_count) / float(token_limit)) * 100.0
|
||||
|
||||
# Update context usage metric
|
||||
context.set("context", f"{str(round(context_usage, 2))}%")
|
||||
|
||||
return pretty_print_element(context)
|
||||
return context
|
||||
Reference in New Issue
Block a user