45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
"""
|
|
Emma Adapter to provide a canonical, consistent interface to the Emma agent core.
|
|
"""
|
|
# This will be copied to /app/emma_identity.py by the Dockerfile
|
|
from emma_identity import get_runtime_system_prompt
|
|
|
|
class CanonicalEmma:
|
|
"""
|
|
A facade for the Emma agent that enforces a canonical identity and contract,
|
|
while allowing the underlying chat function to be injected as a dependency.
|
|
"""
|
|
def __init__(self, chat_function, model, system_prompt=None):
|
|
"""
|
|
Initializes the CanonicalEmma adapter.
|
|
|
|
Args:
|
|
chat_function: The async function to call for the LLM interaction.
|
|
model: The name of the model to use.
|
|
system_prompt: An optional system prompt to override the default.
|
|
"""
|
|
self._chat_function = chat_function
|
|
self._model = model
|
|
self._system_prompt = system_prompt or get_runtime_system_prompt()
|
|
|
|
async def run(self, prompt, history=None):
|
|
"""
|
|
Runs the Emma agent with the given prompt.
|
|
|
|
In Phase 1, this is a simple pass-through to the injected chat_function,
|
|
ensuring the canonical system prompt is used. History is ignored for now.
|
|
|
|
Args:
|
|
prompt: The user's prompt.
|
|
history: The conversation history (currently ignored).
|
|
|
|
Returns:
|
|
The raw dictionary response from the chat_function.
|
|
"""
|
|
# Phase 1 does not use history or memory.
|
|
return await self._chat_function(
|
|
self._model,
|
|
prompt,
|
|
self._system_prompt,
|
|
)
|