您的浏览器禁用了JavaScript(一种计算机语言,用以实现您与网页的交互),请解除该禁用,或者联系我们。 [Packt]:利用OpenAI API构建AI应用 - 发现报告

利用OpenAI API构建AI应用

信息技术 2024-10-28 - Packt 郭生根
报告封面

Building AI Applicationswith OpenAI APIs Leverage ChatGPT, Whisper, and DALL-E APIs to build 10innovative AI projects Martin Yanev Building AI Applications with OpenAI APIs Copyright © 2024 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmittedin any form or by any means, without the prior written permission of the publisher, except in the caseof brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the informationpresented. However, the information contained in this book is sold without warranty, either expressor implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liablefor any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies andproducts mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannotguarantee the accuracy of this information. Group Product Manager: Niranjan NaikwadiPublishing Product Manager: Tejashwini RBook Project Manager: Urvi SharmaContent Development Editor: Priyanka SoamTechnical Editor: Kavyashree K SCopy Editor: Safis EditingProofreader: Priyanka SoamIndexer: Hemangini BariProduction Designer: Shankar KalbhorDevRel Marketing Coordinator: Vinishka Kalra First published: September 2023Second edition: October 2024 Production reference: 1160824 Published byPackt Publishing Ltd.Grosvenor House11 St Paul’s SquareBirminghamB3 1RB, UK. ISBN 978-1-83588-400-3 www.packtpub.com To my sister, Petya Yaneva, whose encouragement and guidance in learning coding have beeninvaluable to my journey. To my lifelong friend and colleague, Petar Dimov, whose enduringfriendship has been a source of ideas, motivation, and positivity, always supporting me through everychallenge. – Martin Yanev Contributors About the author Martin Yanevis a highly accomplished software engineer with a wealth of expertise spanning diverseindustries, including aerospace and medical technology. With an illustrious career of over eight years,Martin has carved a niche for himself in developing and seamlessly integrating cutting-edge softwaresolutions for critical domains such as air traffic control and chromatography systems. Renowned as an esteemed instructor and a computer science professor at Fitchburg State University,Martin has empowered an impressive global community of over 280,000 students. His instructionalprowess shines through as he imparts knowledge and guidance, leveraging his extensive proficiencyin frameworks such as Flask, Django, pytest, and TensorFlow. Possessing a deep understanding ofthe complete spectrum of OpenAI APIs, Martin exhibits mastery in constructing, training, andfine-tuning AI systems. Martin’s commitment to excellence is exemplified by his dual master’s degrees in aerospace systems andsoftware engineering. This remarkable academic achievement underscores his unwavering dedicationto both the practical and theoretical facets of the industry. With his exceptional track record andmultifaceted skill set, Martin continues to propel innovation and drive transformative advancementsin the ever-evolving landscape of software engineering. About the reviewer Alok Jainis a seasoned IT professional with over 20 years of hands-on experience in various roles,including architect, full-stack engineer, cloud engineer, and machine learning engineer. He has workedwith federal agencies, the banking industry, and insurance companies in the past. His expertise includesdigital modernization and applied generative AI solutions. He holds an engineering degree from theIndian Institute of Technology, Kanpur. Alok is also the author of a book on time management anda book on Java. Table of Contents Part 1: Getting Started with OpenAI APIs 1 Getting Started with the ChatGPT API for NLP Tasks3 Setting up your Python developmentenvironment12 Installing Python and the VSCode IDE12Setting up a Python virtual environment13The pip package installer15 Getting started with the ChatGPT API8 Obtaining an API key8API tokens and pricing10 2 Building a ChatGPT Clone 21 Technical requirements22Creating a ChatGPT clone with Flask22Frontend HTML generation26Enhancing the ChatGPT clone design29Intercepting ChatGPT API endpoints31 ChatGPT clone conversation retention34Summary36 Part 2: Build Web Applications with ChatGPT API 3 Creating and Deploying a Code Bug-Fixing Application Using Flask39 Technical requirements40Performing multiple ChatGPT APIrequests40Setting up the Code Bug Fixer project41Implementing the Code Bug Fixerbackend43 Using text areas and containers46Testing the Code Bug Fixer app51Deploying the ChatGPT app to theAzure cloud54Summary59 4 Integrating the Code Bug-Fixing Application with a Payment Service61 Implementing the usage counters71