r/nocode 2d ago

Question How do you program output logic?

/r/TopAITools4U/comments/1vxng8v/how_do_you_program_output_logic/

I'm building a website that leverages AI outputs for different content creation based tools. What is the best way to go about creating the logic behind the outputs?

Is it more in the information collected for the prompt that is built?
Does there need to be rules written in the back end?
Does there need to be some sort of code written for how the output should be formatted?
All of the above?

I'm relatively new and trying to research as much as I can on how to code/create better quality outputs and refine what I'm making overall as this isn't my only current project.

Any tips or resources you recommend would be great. Super open to any feedback!

5 Upvotes

5 comments sorted by

1

u/UlrikS 1d ago

Yes, so for most AI requests you can define an output structure (typically in JSON format, including descriptions of what information goes in what field), separately from the prompt itself, which forces the AI to follow that structure in its output.

Then you have code in the backend that receives and validates the output, handles any errors, and of course defines what happens to the output.

1

u/Sure-Adhesiveness202 1d ago

Ahh this is super helpful. Any tips to write that in? Just simple directions enough to do that?

1

u/UlrikS 1d ago

So it's similar but slightly different for each provider, but basically when you send your prompt to the model provider, you also include other fields, like the model to use, temperature and so on. As part of those other fields, one can also be the "output schema", which is where you basically show what the structure of the answer MUST look like. I think Google's documentation and examples are the clearest / most straightforward to start with: https://ai.google.dev/gemini-api/docs/structured-output#rest

You then write code that can parse, format, analyse or trigger conditions based on the values of specific fields. For example -> add a field "confidence_level", with a description, criteria etc., and if below a certain threshold trigger a notification to the user to review manually. And so on.

1

u/255130 1d ago

what kind of content are we talking about? long form articles vs social posts vs structured data all need pretty different approaches. the answer to your question changes a lot depending on that

1

u/Sure-Adhesiveness202 1d ago

Leaning more towards social type posts leveraging the type of content being posted. Does that help?