kadrian
kadrian2w ago

How to let an LLM "use" a tRPC api?

Hey, so I've been wondering lately how to build a simple LLM-supported CRUD app. With REST APIs, it's clear: I can give an LLM the entire API specs (e.g. using openAPI / swagger, etc.) and then ask it to translate the natural language user request (e.g. from a "chat") into a series of actions, using the REST endpoints. Then the LLM can write curl request code, for example, to "use" the REST api. But from a react / typescript perspective, using tRPC is just A LOT better (no need to tell you, hehe). How would you design a system where an LLM is basically "an additional client" that uses tRPC? Would the LLM have to generate typescript code (instead of curl requests) that I'd have to run? How would the LLM know about the api spec? Any other ideas here?
2 Replies
Alex / KATT 🐱
are you planning on generating code? you could probably peek inside of appRouter._def.procedures they also have their input schema(s) embededed there somewhere
kadrian
kadrianOP2w ago
Hmm, okay I'll have a look at that. Yeah, I'm not sure whether I need to be generating code, but I guess I do!

Did you find this page helpful?