from opper import Opper
from pydantic import BaseModel
class EmailInput(BaseModel):
customer_message: str
tone: str
class EmailResponse(BaseModel):
response: str
# Create function with automatic example retrieval
function = opper.functions.create(
name="customer_support",
instructions="Generate helpful support responses",
input_schema=EmailInput.model_json_schema(),
output_schema=EmailResponse.model_json_schema(),
configuration={
"invocation.few_shot.count": 5 # Pull 5 relevant examples
}
)
# Add curated examples to guide the model
function.dataset.add_entry({
"input": {"customer_message": "I can't log in", "tone": "friendly"},
"output": {"response": "I'd be happy to help you with login issues..."}
})
# Model automatically uses relevant examples from dataset
result = function.call(input={"customer_message": "Payment failed", "tone": "professional"})