9 Creating an AI-powered application
This chapter covers
- Connecting your app to a Large Language Model (LLM)
- Engineering LLM prompts to achieve your desired results
- Using Structured Outputs to obtain LLM responses in a custom parsable format
- Managing state in a sequential Streamlit app
- Using st.data_editor to create editable tables
Creating software is significantly different from what it was just a few short years ago. The difference stems from major developments in the field of AI (Artificial Intelligence), which—unless you've been living under a rock—you've probably heard of.
I'm talking, of course, about breakthroughs in LLMs or Large Language Models, and the tremendously exciting possibilities they open up. By processing and generating natural language, LLMs can understand context, answer complex questions, and even write software on their own—all with astonishing fluency. Tasks that once required domain-specific expertise or painstaking programming can now be achieved with just a few well-crafted "prompts".
In this chapter, we'll dive into how you can harness the power of LLMs in your applications, relying on AI prompts and responses to implement product features that would have required highly advanced techniques half a decade ago. Along the way, we'll also discuss how to tune your LLM interactions to get the results you want, and how to do so without burning a hole in your pocket.