13 Building AI-powered applications

 

This chapter covers

  • Adding AI to applications using APIs, even without advanced AI knowledge
  • Using function calling to make AI outputs work with application logic
  • Creating AI assistants for databases, documents, and automated tasks
  • Working with OpenAI’s Assistants API to maintain conversation state
  • Getting structured data safely using function calling
  • Securing AI systems with proper validation, permissions, and tracking
Any sufficiently advanced technology is indistinguishable from magic.
—Arthur C. Clarke

Many software engineers will soon need to add generative AI to their applications. This could mean letting users interact with data through natural language, using AI to sort documents in SharePoint, or creating realistic test data. These AI features can expand your app’s capabilities without requiring deep AI expertise.

Adding AI to your applications is often simpler than you may think. You don’t need advanced knowledge of AI models because most integrations work through standard REST APIs—similar to how you’d use Stripe or Twilio. This applies to both chat interfaces and core application features.

13.1 Function calling

13.1.1 Chatting with the OpenAI API

13.1.2 Building a database copilot

13.1.3 Implementing function calling

13.2 The functions

13.2.1 What matters in AI function design

13.3 Validating SQL queries with examine_sql

13.3.1 Defining what makes a query dangerous

13.3.2 Generating a user-friendly response

13.3.3 AI-powered SQL assistance in action

13.4 Practical applications and security considerations

13.4.1 Example: AI-powered currency conversion

13.4.2 Security considerations for function calling

13.5 Prompts used in this chapter

Summary