The pain points of building a copilot
austinhenley.com
austinhenley.com
JSON.stringify({ ... } satisfies MyOutputType)
which ensures your examples always exactly match what you expect the LLM to return, even as you iterate on the prompt and output types. Then just call the LLM and validate the output using zod/TypeBox. Once you're done writing the wrapper function, now instead of managing a bunch of string interpolation when you want to have the LLM analyze something, you have a function that takes some input data, and returns your output type, guaranteed.With OpenAI tool calling, you can even convert the zod/TypeBox type into JSON Schema, give that to OpenAI, and have a fairly good chance the LLM doesn't make any mistakes without even needing retries. (Although you should still retry if the zod/TypeBox/whatever validator fails.)
Shameless plug: I work on CopilotKit - open-source copilot building blocks for react apps. Designed to alleviate exactly the pain points in the article. Devs define simple Copilot entrypoints--
state (frontend + backend + 3rd party), action, purpose-specific LLM chains, etc. And the CopilotKit engine takes care of the rest.
https://www.microsoft.com/en-us/microsoft-copilot/microsoft-...