Beginning ChatGPT for Python: Build Intelligent Applications with OpenAI APIs
معرفی کتاب «Beginning ChatGPT for Python: Build Intelligent Applications with OpenAI APIs» نوشتهٔ Lydia Evelyn و Bruce Hopkins، منتشرشده توسط نشر Apress L. P. در سال 2024. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «Beginning ChatGPT for Python: Build Intelligent Applications with OpenAI APIs» در دستهٔ برنامهنویسی قرار دارد.
Unlock the future of software development and empower yourself to elevate your Python applications by harnessing the power of AI as this field continues to grow and evolve. Perfect for beginner to intermediate Python programmers, this book breaks down the essentials of using ChatGPT and OpenAI APIs. You'll start with the basics, learning to authenticate, send prompts, generate responses, test in the Playground, and handle errors with ease. Each chapter includes hands-on exercises that bring concepts to life, demonstrating different API functionalities and practical applications. You'll master models like GPT-4o, GPT-4, GPT-3.5, Whisper, and DALL-E, enabling you to enhance your applications with cutting-edge AI. Discover how generative AI tools like ChatGPT can automate tedious tasks rather than replace jobs. Leverage ChatGPT’s powerful Natural Language Processing (NLP) capabilities to handle various formats of unstructured text within your Python apps. Quickly see how easy it is to use ChatGPT as your AI-pair programmer, boosting your productivity and speed. This step-by-step guide will have you creating intelligent chatbots that can automatically process messages from Slack or Discord. With Beginning ChatGPT for Python, you'll master the ChatGPT and OpenAI APIs, building intelligent applications that offer a personalized and engaging user experience. What You’ll Learn Connect with the ChatGPT and OpenAI APIs and send effective prompts. Harness parameters like temperature and top_p to create unique and engaging responses from ChatGPT. Create an intelligent assistant bot for Slack that automates tasks and enhances productivity. Develop a bot that can moderate conversations and manage communities on Discord. Add context to your prompts to get more accurate and relevant responses. Who This Book Is ForPython developers and enthusiasts who aspire to employ O Table of Contents About the Authors About the Technical Reviewer Chapter 1: Introducing ChatGPT for Python Developers Who Is This Book For? Overview Download the Code Now! So, What Exactly Is ChatGPT and Why Do I Need to Use the OpenAI APIs? Regex vs. ChatGPT: Fight! Analysis Question #1: Who Didn’t Get Any Ice Cream, and Why? Analysis Question #2: Which Kid Was Probably Left Sad? Let’s Unlearn Some Words in Order to Learn More About the ChatGPT API Models. Models? Models!!! When We Talk About Tokens, Don’t Think About Access Tokens Temperature Is All About Creativity Getting Started with the OpenAI Playground 1. Model 2. System 3. User/Assistant 4. Add (Optional) 5. Temperature (Optional) 6. Maximum Tokens (Optional) 7. Code (Optional) Try It Now! Experimenting with the “System” Role Conclusion Chapter 2: Using ChatGPT As Your Python Pair-Programmer Overview Installing (or Updating) the OpenAI Library with pip Three Ways to Set Your API Key Option #1: Setting a System-Wide Environment Variable For Mac OS For Windows For Linux Option #2: Creating a .env File Option #3: Hard-Coding the API Key Directly in Your Application (Take with Caution) Creating Your First Python ChatGPT App: model_lister.py Using OpenAI.models.list() to Get a List of Available Models Handling the Response Using Your API Key to Get a List of Available Models with the OpenAI API Getting a Prettier List of Models Wait, How Many Tokens Are in My Prompt? Using ChatGPT As a Pair-Programmer to Build a Weather Application Setting Up the Prompt Creating accuweather_forecaster.py with the AccuWeather API Refining Our Prompt with Prompt Engineering Using ChatGPT As a Pair-Programmer to Build an Application That Estimates Distance and Arrival Time Creating a Project with Google Maps Platform API Using ChatGPT to Take a cURL Command and Make It Useable in Python: The Flexible Programmer’s Approach Using ChatGPT to Avoid Reading a Lot of Documentation and Having to Decipher Through Any cURL Code Conclusion Chapter 3: Creating a Basic ChatGPT Client in Python Creating Our ChatGPT Chat Completion Application, chatgpt_client.py Using OpenAI.chat.completions.create() to Send Messages to ChatGPT Examining the Method Parameters There Are Four Types of Messages System Message (Dictionary) User Message (Dictionary) Assistant Message (Dictionary) Tool Message (Dictionary) Running chatgpt_client.py Handling the Response (ChatCompletion) ChatCompletionMessage Conclusion Chapter 4: Using AI in the Enterprise! Creating a Text Summarizer for Slack Messages So, What Is Prompt Engineering? ChatGPT Is Here to Take Away Everyone’s Jobs (Not Really) Examining a Real-World Problem: Customer Support for a Software Company Prompt Engineering 101: Text Summarization Prompt #1: “tl;dr” Prompt #2: “Explain This in Three Sentences or Less” Prompt #3: “I’m a Manager. Explain to Me What Happened” Prompt #4: “Give Me Suggestions on Next Steps” Let’s Talk About Real Prompt Engineering Registering a Slack Bot App Specifying What Your Bot Can (and Can’t) Do by Setting the Scope Confirming Your Settings Viewing the OAuth & Permissions Page Installing Your Slack Bot App to Your Workspace Getting Your Slack Bot (Access) Token Inviting Your Bot to Your Channel Finding the Channel ID of Your Channel Using Your Slack Bot App to Automatically Grab Messages from a Channel Programmatically Reading Messages from Slack with slack_chat_reader_bot.py Exercises Left for the Reader Conclusion Chapter 5: Multimodal AI: Creating a Podcast Visualizer with Whisper and DALL·E 3 Introducing the Whisper Model by OpenAI Features and Limitations of the Whisper Model Using OpenAI.audio.transcriptions.create() to Transcribe Audio Examining the Method Parameters Creating a Utility App to Split Audio Files: audio_splitter.py Creating the Audio Transcriber: whisper_transcriber.py Having a Little Fun and Trying Things Out with a Podcast Going Meta: Prompt Engineering GPT-4 to Write a Prompt for DALL·E Using OpenAI.images.generate() to Create Images Examining the Method Parameters Handling the Response Creating the Image Generator: dalle_client.py DALL·E Prompt Engineering and Best Practices DALL·E Golden Rule #1: Get Familiar with the Types of Images That DALL·E Can Generate DALL·E Golden Rule #2: Be Descriptive with What You Want in the Foreground and Background Let’s Play Around with Prompts to DALL·E Conclusion Exercises Left for the Reader Chapter 6: Creating an Automated Community Manager Bot with Discord and Python Choosing Discord as Your Community Platform Creating a More Advanced Bot Than Our Slack Bot Creating a More Advanced Bot Than Any Typical Discord Bot Understanding the Roles for the Bots Our Example Bank: Crook’s Bank First Things First: Create Your Own Discord Server Create the Q&A Channel Registering a New Discord Bot App with Discord Specifying General Info for the Bot Specifying OAuth2 Parameters for the Bot Invite Your Bot to Your Server Getting the Discord ID Token for Your Bot and Setting the Gateway Intents Creating a Q&A Bot App in Python to Answer Questions from a Channel: tech_support_bot_dumb.py Handling Messages Sent to the Discord Server Success! Running Your First Discord Bot: tech_support_bot_dumb.py Streamlining the Process of Registering Our Next Discord Bot App with Discord Registering a New Discord Bot App with Discord Specifying General Info for the Bot Specifying OAuth2 Parameters for the Bot Invite Your Bot to Your Server Getting the Discord ID Token for Your Bot and Setting the Gateway Intents Creating The Next Discord Bot: content_moderator_bot_dumb.py Handling Messages Sent to the Discord Server Success Again! Running Your Second Discord Bot: content_moderator_bot_dumb.py Conclusion Exercises Left for the Reader Chapter 7: Adding Intelligence to Our Discord Bots, Part 1: Using the Chat Model for Q&A Making tech_support_bot.py More Intelligent Important Changes to Note from the Previous Version of the Tech Support Bot Updates to the on_message(message) Function Analyzing chatgpt_client_for_qa_and_moderation.py Breaking Down the ChatGPTClient Class in Python So Our Bot Can Utilize ChatGPT Running Our Intelligent Q&A Bot: tech_support_bot.py We Have a Monumental Achievement...with One Slight Flaw Update the System Message to ChatGPT, and Let’s Try Again Conclusion Chapter 8: Adding Intelligence to Our Discord Bots, Part 2: Using Chat and Moderations Models for Content Moderation Using OpenAI.moderations.create() to Moderate Content Examining the Method Parameters Handling the Response Moderation (Dictionary) Creating Our Client for the Moderations Model: moderation_client.py Making content_moderator_bot.py More Intelligent Updates to the on_message(message) Function Running Our Intelligent Content Moderator Bot: content_moderator_bot.py Conclusion Exercises Left for the Reader Appendix 1 List of OpenAI Models Index df-0.jpg
دانلود کتاب Beginning ChatGPT for Python: Build Intelligent Applications with OpenAI APIs