Skip to content

v1.11.0 β€” AI hooks: describe β†’ shape / patch πŸ€–

Choose a tag to compare

@ozgesolidkey ozgesolidkey released this 29 Sep 22:16
· 5 commits to main since this release

AI hooks β€” "describe β†’ shape / patch." KMPMedia's vector primitives are just data, so a language model can produce them. New com.solidkey.painpoints.ai.OGAiVector is a provider-agnostic JSON interop layer: it hands a model the exact contract and turns the reply back into a live clip shape or SVG patch.

  • polygonPrompt(instruction) / svgPatchPrompt(instruction, nodeIds) β€” build a prompt stating the JSON schema.
  • decodePolygon / decodeSvgPatch (+ …OrNull) β€” a model's reply β†’ OGPolygonShape for clipShape, or Map<String, OGSvgNodeOverride> for OGSVGView(overrides = …). Tolerant of the ```json fences + prose models add.
  • encodePolygon / encodeSvgPatch β€” serialize the other way (persist a lasso, seed a prompt).
  • OGPolygonSpec / OGNodeOverrideSpec / OGSvgPatchSpec β€” @Serializable DTOs.

No network calls and no AI SDK in the library β€” it defines the contract and does the JSON; you own the model and the call. Purely additive (new package), zero-dependency beyond the serialization family already in use. Colors reuse the SVG color parser (#RGB/#RRGGBB/#AARRGGBB/rgb()/name). All work happens at generate/patch time, never per frame. 12 tests green on JVM + iOS.

First shipped piece of Bet 1 β€” Runtime & AI-editable vector's "AI hooks" item. See docs/AI_HOOKS.md.

implementation("se.solidkey:kmpmedia-lib:1.11.0")