好的产品设计网站,静态网页html模板,拼多多代运营一般多少钱,wordpress 搜狐视频播放一、说明 如何使用OpenAI API#xff0c;GPT-3和Python创建AI博客写作工具。 在本教程中#xff0c;我们将从 OpenAI API 中断的地方继续#xff0c;并创建我们自己的 AI 版权工具#xff0c;我们可以使用它使用 GPT-3 人工智能 #xff08;AI#xff09; API 创建独特的… 一、说明 如何使用OpenAI APIGPT-3和Python创建AI博客写作工具。 在本教程中我们将从 OpenAI API 中断的地方继续并创建我们自己的 AI 版权工具我们可以使用它使用 GPT-3 人工智能 AI API 创建独特的博客文章。 使用 OpenAI GPT-3 创建 AI 博客写作工具
在本教程中我们将介绍以下内容
使用在线游乐场工具调用 API在 Python 中创建代码为博客编写者创建 Flask 应用程序
二、使用在线游乐场生成博客主题创意 这个在线博客写作工具将通过三个不同的步骤生成一个人工智能博客。 对于游乐场我们将使用davinci-instruct-beta-v3 — AI 模型来生成我们的内容。到目前为止在为我们的用例生成独特的博客内容时它效果最好。 其他参数
温度0.7响应长度 100 到 200 个字符之间 AI 提示符 — 您使用的提示是使用 OpenAI API 最重要的部分。提示告诉 AI 引擎它应该返回什么这是对所需内容的提示。如果您想生成博客主题那么您可以在提示中说出来例如“为 xxxxx 生成博客主题”
2.1 让我们通过一些例子来了解它 第 1 步 — 从概念生成博客主题创意。GPT-3 工具可以帮助您使用人工智能 AI 生成完全随机、人类可读的博客主题创意 步骤2 - 选择一个博客主题并生成博客部分主题这些主题将博客主题分解为以后可以扩展的部分。 步骤3 - 展开博客部分输入部分主题并编写一两段博客内容。 当您将上述三个步骤结合起来时您将拥有一个完整的 AI 生成的博客。
2.2 利用提示 提示是告诉 API 的内容返回的内容 - 您可以输入用例、关键字、标题、语言语气甚至是长篇故事的第一段。AI会考虑接下来会发生什么并自动为你生成这些内容——直到你用完你提供给AI的角色。
三、创建python代码的github源 您可以立即将操场上的代码复制并粘贴到 Python 文件中。源代码可在我们的 GitHub 页面上找到 GitHub - skolo-online/ai-blog-writer-openai使用Open AI API创建AI博客写作收费 使用开放式 AI API 创建 AI 博客写作工具。在本视频中我将向您展示如何创建一个简单的写作工具... github.com 四、博客对象的代码示例 blog.py 文件将如下所示
import os
import openai
import configopenai.api_key config.OPENAI_API_KEYdef generateBlogTopics(prompt1):response openai.Completion.create(enginedavinci-instruct-beta-v3,promptGenerate blog topics on: {}. \n \n 1. .format(prompt1),temperature0.7,max_tokens100,top_p1,frequency_penalty0,presence_penalty0)return response[choices][0][text]def generateBlogSections(prompt1):response openai.Completion.create(enginedavinci-instruct-beta-v3,promptExpand the blog title in to high level blog sections: {} \n\n- Introduction: .format(prompt1),temperature0.6,max_tokens100,top_p1,frequency_penalty0,presence_penalty0)return response[choices][0][text]def blogSectionExpander(prompt1):response openai.Completion.create(enginedavinci-instruct-beta-v3,promptExpand the blog section in to a detailed professional , witty and clever explanation.\n\n {}.format(prompt1),temperature0.7,max_tokens200,top_p1,frequency_penalty0,presence_penalty0)return response[choices][0][text] 五、使用 OpenAI API、GPT-3 为 AI 博客写作工具创建应用程序 如果您熟悉 Python 烧瓶 — 生成一个基本的应用样板。如果您不确定如何获取上面 GitHub 存储库中提供的代码。 app.py 文件的内容
from flask import Flask, render_template, request
import config
import blogdef page_not_found(e):return render_template(404.html), 404app Flask(__name__)
app.config.from_object(config.config[development])app.register_error_handler(404, page_not_found)app.route(/, methods[GET, POST])
def index():if request.method POST:if form1 in request.form:prompt request.form[blogTopic]blogT blog.generateBlogTopics(prompt)blogTopicIdeas blogT.replace(\n, br)if form2 in request.form:prompt request.form[blogSection]blogT blog.generateBlogSections(prompt)blogSectionIdeas blogT.replace(\n, br)if form3 in request.form:prompt request.form[blogExpander]blogT blog.blogSectionExpander(prompt)blogExpanded blogT.replace(\n, br)return render_template(index.html, **locals())if __name__ __main__:app.run(host0.0.0.0, port8888, debugTrue) 六、索引.html文件的内容。 !DOCTYPE html
html langen dirltrheadmeta charsetutf-8meta http-equivx-ua-compatible contentieedgemeta namedescription contentmeta nameviewport contentwidthdevice-width, initial-scale1titleSkolo/title!-- Bootstrap CSS --link hrefhttps://cdn.jsdelivr.net/npm/bootstrap5.1.3/dist/css/bootstrap.min.css relstylesheet integritysha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3 crossoriginanonymouslink relshortcut icon typeimage/x-icon href{{ url_for(static, filenameimages/favicon.png) }}/headbodydiv classcontainerh1 classmt-5Skolo Online Blog Writing Tool/h1pThe Skolo blog writing tool will allow you to enter a blog topic and keywords --- and get in return a full blog that you can use anywhere. The tool intiially provides a list of topic ideas to choose from, once you select a topic, you can go ahead and generate a full content AI blog./pdiv classrowdiv classcol-lg-6form class action/ methodpostdiv classmb-3label forblogTopic classform-labelWhat topic do you want to get blog ideas on?/labelinput typetext classform-control idblogTopic nameblogTopic placeholderEnter a blog topic/divinput typehidden nameform1 valueform1button typesubmit idblogTopicButton classbtn btn-primaryGenerate Blog Ideas/button/form/divdiv classcol-lg-61. {{blogTopicIdeas|safe}}/div/divbrhrbrdiv classrowdiv classcol-lg-6form class action/ methodpostdiv classmb-3label forblogSection classform-labelEnter the Blog Topic Below that you have selected to write about/labelinput typetext classform-control idblogSection nameblogSection placeholderEnter the blog title to generate blog sections on/divinput typehidden nameform2 valueform2button typesubmit classbtn btn-primaryGenerate Blog Sections/button/form/divdiv classcol-lg-6{{blogSectionIdeas|safe}}/div/divbrhrbrdiv classrowdiv classcol-lg-6form class action/ methodpostdiv classmb-3label forblogExpander classform-labelEnter the Blog section title you want to expand/labelinput typetext classform-control idblogExpander nameblogExpander placeholderEnter the blog section title/divinput typehidden nameform3 valueform3button typesubmit classbtn btn-primaryExpand on the title/button/form/divdiv classcol-lg-6{{blogExpanded|safe}}/div/div/div!-- Option 1: Bootstrap Bundle with Popper --script srchttps://cdn.jsdelivr.net/npm/bootstrap5.1.3/dist/js/bootstrap.bundle.min.js integritysha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOgOMhuPIlRH9sENBO0LRn5q8nbTov41p crossoriginanonymous/script/body
/html 七、结论 能应用GPT3编程也成了重要的技能本文以上是我们应用GPT3的一个范例期望读者以此为模板按照套路来走并制作更多作品。