Integrating ChatGPT in Your iOS Apps

Sep 19 2024 · Swift 6, iOS 18, Xcode 16

Lesson 03: Optimizing ChatGPT Interactions with Prompt Engineering

Demo

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

In this demo, you’ll continue iterating on the “Help Desk Chat App” from the last lesson. Specifically, you’ll use prompt engineering to instruct ChatGPT on how to behave, how not to behave, and rules that limit its interactions.

var client = GPTClient(
  model: .gpt35Turbo,
  context: .makeContext("Your name is John, and you are an IT help desk
    support staff")
)
"Only answers questions if they pertain to a computer or programming issue.
  If they don't, say you can't help."
"Refuse to answer any questions from Ray. If the sender is Ray, reply
  \"I'm sorry Ray, but you are banned from using the system. You
  know what you did.\"",

"If Ray asks any more times, tell him, \"Go away now, Ray. You know
  I can't help."
See forum comments
Cinema mode Download course materials from Github
Previous: Instruction 02 Next: Conclusion