Add preference learning to Microsoft AutoGen agents. pref0 extracts preferences from multi-agent conversations and personalizes future sessions.
from autogen import ConversableAgent
import requests
PREF0_API = "https://api.pref0.com"
PREF0_KEY = "pref0_sk_..."
def get_preferences(user_id: str) -> str:
res = requests.get(
f"{PREF0_API}/v1/profiles/{user_id}",
headers={"Authorization": f"Bearer {PREF0_KEY}"},
)
prefs = res.json().get("preferences", [])
return "\n".join(
f"- {p['key']}: {p['value']}"
for p in prefs if p["confidence"] >= 0.5
)
learned = get_preferences("user_abc123")
assistant = ConversableAgent(
name="assistant",
system_message=f"You are a helpful assistant.\n\nLearned preferences:\n{learned}",
llm_config={"model": "gpt-4o"},
)
user_proxy = ConversableAgent(
name="user",
human_input_mode="ALWAYS",
)
user_proxy.initiate_chat(assistant, message="Set up a new project for me")Add preferences to any ConversableAgent's system message. Works with AssistantAgent and custom agents.
Share preferences across all agents in a group chat. Consistent behavior from every agent.
Preferences survive across AutoGen sessions. Track conversations after each chat to keep learning.
pref0 works outside AutoGen's skill system. Simple HTTP calls before and after conversations.
Your users are already teaching your agent what they want. pref0 makes sure the lesson sticks.