tools.flavor_tool module
Flavor Engine Tool – Stargazer-callable tool for gustatory computation.
- Wraps FlavorEngine for use as a Discord bot tool. Supports:
blend: compute composite flavor profile from a recipe
morph: interpolate between two flavors
lookup: get a single flavor profile
list: list all available flavors
NCM deltas from blend/morph are auto-injected into the limbic system via exhale() so narrative food consumption actually modifies Star’s neurochemistry in Redis DB12.
- async tools.flavor_tool.run(action, recipe='[]', morph_from='', morph_to='', morph_t=0.5, flavor='', ctx=None)[source]
Dispatch one of the four flavor-engine actions and return JSON.
This is the
generate_image-style single-tool entry point for theflavor_enginetool: it instantiates a freshFlavorEngineand routes onactiontolist,lookup,blend, ormorph, serialising the result withjsonutil(aliasedjson). Beyond pure computation it has two side effects that make narrative eating actually change Star’s state: forblendandmorphit calls_inject_ncm_deltasto fold the result’s NCM deltas into the per-channel limbic shard in Redis DB12, and (when aToolContextis present) it records each ingredient viaflavor_memory.record_flavorusing the Redis client from_get_redis. All other failures are caught and returned as anError:string rather than raised.Dispatched by
tool_loader.py, which imports this module and pullsrunout withgetattr(module, "run")to register it underTOOL_NAME(“flavor_engine”); it is also exercised directly in the test suite.- Parameters:
action (
str) – One of"blend","morph","lookup", or"list".recipe (
str) – JSON array of ingredient dicts, used only forblend.morph_from (
str) – Starting flavor name formorph.morph_to (
str) – Target flavor name formorph.morph_t (
float) – Interpolation point in[0, 1]formorph(default 0.5).flavor (
str) – Flavor name forlookup.ctx (
ToolContext|None) – The currentToolContext; supplieschannel_idand the Redis client needed for NCM injection and flavor-memory recording. WhenNone, those side effects are skipped.
- Return type:
- Returns:
A pretty-printed JSON string for a successful action, or an
"Error: ..."message string when the action is unknown, a required parameter is missing, the recipe JSON is invalid, or an exception is raised.