Enable multiple llms

This commit is contained in:
Niels Geens
2024-11-22 15:05:54 +01:00
parent bbb88f39e8
commit 8766a945c0
28 changed files with 972 additions and 525 deletions

View File

@@ -22,7 +22,6 @@ class BaseAgent(ABC):
action_schema: str,
working_memory: WorkingMemory,
metrics: SystemMetrics,
llm: LlmEngine,
validator: XMLValidator,
parser: ResponseParser,
):
@@ -33,7 +32,6 @@ class BaseAgent(ABC):
self._action_schema = action_schema
self._working_memory = working_memory
self._metrics = metrics
self._llm = llm
self._validator = validator
self._parser = parser
@@ -47,7 +45,7 @@ class BaseAgent(ABC):
"""Get the system prompt."""
return f"{self._system_prompt}\n{self._action_schema}"
def _compile_context(self) -> str:
def _compile_context(self, llmEngine: LlmEngine) -> str:
"""
Compile the current context for LLM inference.
Includes system metrics and working memory entries.
@@ -76,8 +74,8 @@ class BaseAgent(ABC):
context_str = pretty_print_element(context)
# Calculate token usage percentage
token_count = self._llm.token_count(self.system_prompt, context_str)
token_limit = self._llm.token_limit()
token_count = llmEngine.token_count(self.system_prompt, context_str)
token_limit = llmEngine.token_limit()
context_usage = (float(token_count) / float(token_limit)) * 100.0
# Update context usage metric