MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / add

Method add

uncommon_route/scene_store.py:205–225  ·  view source on GitHub ↗

Add or update a scene. Returns the stored scene.

(self, scene: SceneConfig)

Source from the content-addressed store, hash-verified

203 return sorted(self._scenes.values(), key=lambda s: s.name)
204
205 def add(self, scene: SceneConfig) -> SceneConfig:
206 """Add or update a scene. Returns the stored scene."""
207 normalized = SceneConfig(
208 name=scene.name.strip().lower(),
209 primary=scene.primary.strip(),
210 fallback=[f.strip() for f in scene.fallback if f.strip()],
211 hard_pin=scene.hard_pin,
212 description=scene.description,
213 tier_floor=scene.tier_floor,
214 tier_cap=scene.tier_cap,
215 allowed_providers=scene.allowed_providers,
216 max_cost_per_request=scene.max_cost_per_request,
217 )
218 # Deduplicate fallback against primary
219 normalized = replace(
220 normalized,
221 fallback=[f for f in normalized.fallback if f != normalized.primary],
222 )
223 self._scenes[normalized.name] = normalized
224 self._save()
225 return normalized
226
227 def remove(self, name: str) -> bool:
228 """Remove a scene. Returns True if it existed."""

Calls 2

_saveMethod · 0.95
SceneConfigClass · 0.85