0:00
/
0:00
Transcript

Build Your First AI-Powered Web Application - Prompt Engineering

Here we take our simple AI-powered Web Application and apply prompt engineering. We want the LLM to reply by providing a haiku, based on the prompt or user input.

 # Enhanced prompt that instructs the AI to respond in haiku format

        haiku_prompt = f"Answer this question with a relevant haiku (5-7-5 syllable format). Put each line on a separate line: {user_question}"

We only changed one line of code from the previous application. The user inputs a question: “Who was Paul Robeson?”. We assign their question to the variable “user_question”. Instead of sending the question directly to the LLM, we surround it what an enhanced prompt: “Answer this question with a relevant haiku (5-7-5 syllable format). Put each line on a separate line: ‘Who was Paul Robeson?’”

We send this new constructed prompt (haiku_prompt) to the LLM.

Discussion about this video