Input/Output Mapping
Map your function’s parameters and return values to Rhesis’s standardized request/response format. The SDK supports both automatic detection and manual configuration.
Auto-Mapping (Recommended)
Use standard field names for automatic detection:
Standard fields:
- Request:
input,session_id,context,metadata,tool_calls - Response:
output,context,metadata,tool_calls,session_id
Manual Mapping
For custom parameter names or complex structures, provide explicit mappings:
Request Mapping (Jinja2 Templates)
Request mapping transforms incoming Rhesis request fields to your function parameters.
- Use Jinja2 template syntax:
{{ variable_name }} - Maps standard Rhesis request fields (
input,session_id,context) to your function parameters - Custom fields from the request are passed through automatically
- Example:
"user_message": "{{ input }}"maps the Rhesisinputfield to your function’suser_messageparameter
Simple Mappings
Complex Structures
For functions that accept complex types (like Pydantic models), mapping keys should match function parameter names:
See Advanced Mapping for how complex types like Pydantic models are automatically constructed from mapped dictionaries.
Response Mapping (JSONPath or Jinja2)
Response mapping extracts values from your function’s return value to Rhesis’s standardized format.
JSONPath Syntax
Use JSONPath expressions (starting with $) for direct field extraction:
Common JSONPath patterns:
| Pattern | Description |
|---|---|
$.field | Top-level field |
$.nested.field | Nested field |
$.array[0] | First array element |
$.array[-1] | Last array element |
$.array[*].field | Field from all array elements |
Jinja2 Templates with JSONPath
Use Jinja2 templates with the jsonpath() function for conditional logic or complex extraction:
Custom Request Fields
You can pass custom fields through the API that aren’t part of the standard schema:
Custom fields must be included in the API request body when invoking the endpoint.
Next Steps - Learn about Advanced Mapping for handling complex objects - See Examples for complete working examples