import litert_lm
import numpy as np

# Path to your compiled Gemma or local container model
model_path = "~/.litert-lm/models/gemma-4-E2B-it.litertlm/model.litertlm"

# 1. Initialize the Engine (Binds to CPU, GPU, or NPU backends)
with litert_lm.Engine(
    model_path, 
    backend=litert_lm.Backend.CPU()
) as engine:
    
    # Optional: Seed the system instructions to force structural formatting
    system_instruction = litert_lm.Message.system(
        "You are an XYFLOW coordinate optimizer. Output your parameter choices cleanly."
    )
    
    # 2. Open an active orchestrating conversation manifold
    with engine.create_conversation(messages=[system_instruction]) as conversation:
        
        # 3. Inject a user message/query directly as an API object
        user_prompt = "The system is tumbling into noise. Choose mu damping parameter targets."
        response = conversation.send_message(user_prompt)
        
        # 4. Extract generated token content cleanly 
        ai_raw_text = response["content"][0]["text"]
        print(f"AI Selected Strategy:\n{ai_raw_text}")
        
        # Example: Instantly hand the generated intent over to your NumPy environment
        # values = np.array([parse_mu(ai_raw_text), ...])
