【GPT-3 】创建AI博客写作工具

一、说明

        如何使用OpenAI API,GPT-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 config


openai.api_key = config.OPENAI_API_KEY


def generateBlogTopics(prompt1):
    response = openai.Completion.create(
      engine="davinci-instruct-beta-v3",
      prompt="Generate blog topics on: {}. \n \n 1.  ".format(prompt1),
      temperature=0.7,
      max_tokens=100,
      top_p=1,
      frequency_penalty=0,
      presence_penalty=0
    )

    return response['choices'][0]['text']

def generateBlogSections(prompt1):
    response = openai.Completion.create(
      engine="davinci-instruct-beta-v3",
      prompt="Expand the blog title in to high level blog sections: {} \n\n- Introduction: ".format(prompt1),
      temperature=0.6,
      max_tokens=100,
      top_p=1,
      frequency_penalty=0,
      presence_penalty=0
    )

    return response['choices'][0]['text']


def blogSectionExpander(prompt1):
    response = openai.Completion.create(
      engine="davinci-instruct-beta-v3",
      prompt="Expand the blog section in to a detailed professional , witty and clever explanation.\n\n {}".format(prompt1),
      temperature=0.7,
      max_tokens=200,
      top_p=1,
      frequency_penalty=0,
      presence_penalty=0
    )

    return response['choices'][0]['text']

五、使用 OpenAI API、GPT-3 为 AI 博客写作工具创建应用程序

        如果您熟悉 Python 烧瓶 — 生成一个基本的应用样板。如果您不确定如何获取上面 GitHub 存储库中提供的代码。

        app.py 文件的内容

​
from flask import Flask, render_template, request
import config
import blog


def page_not_found(e):
  return render_template('404.html'), 404


app = 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(host='0.0.0.0', port='8888', debug=True)

​

六、索引.html文件的内容。

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Skolo</title>
    <!-- Bootstrap CSS -->
   <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <link rel="shortcut icon" type="image/x-icon" href="{{ url_for('static', filename='images/favicon.png') }}">

  </head>
  <body>
    <div class="container">
      <h1 class="mt-5">Skolo Online Blog Writing Tool</h1>

      <p>The 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.</p>

      <div class="row">
        <div class="col-lg-6">
          <form class="" action="/" method="post">
            <div class="mb-3">
              <label for="blogTopic" class="form-label">What topic do you want to get blog ideas on?</label>
              <input type="text" class="form-control" id="blogTopic" name="blogTopic" placeholder="Enter a blog topic">
            </div>
            <input type="hidden" name="form1" value="form1">

            <button type="submit" id="blogTopicButton" class="btn btn-primary">Generate Blog Ideas</button>
          </form>
        </div>

        <div class="col-lg-6">
          1. {{blogTopicIdeas|safe}}
        </div>
      </div>

      <br>
      <hr>
      <br>

      <div class="row">
        <div class="col-lg-6">
          <form class="" action="/" method="post">
            <div class="mb-3">
              <label for="blogSection" class="form-label">Enter the Blog Topic Below that you have selected to write about</label>
              <input type="text" class="form-control" id="blogSection" name="blogSection" placeholder="Enter the blog title to generate blog sections on">
            </div>
            <input type="hidden" name="form2" value="form2">

            <button type="submit" class="btn btn-primary">Generate Blog Sections</button>
          </form>
        </div>

        <div class="col-lg-6">
          {{blogSectionIdeas|safe}}
        </div>
      </div>

      <br>
      <hr>
      <br>

      <div class="row">
        <div class="col-lg-6">
          <form class="" action="/" method="post">
            <div class="mb-3">
              <label for="blogExpander" class="form-label">Enter the Blog section title you want to expand</label>
              <input type="text" class="form-control" id="blogExpander" name="blogExpander" placeholder="Enter the blog section title">
            </div>
            <input type="hidden" name="form3" value="form3">

            <button type="submit" class="btn btn-primary">Expand on the title</button>
          </form>
        </div>

        <div class="col-lg-6">
          {{blogExpanded|safe}}
        </div>
      </div>
    </div>

    <!-- Option 1: Bootstrap Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

  </body>
</html>

七、结论

        能应用GPT3编程,也成了重要的技能,本文以上是我们应用GPT3的一个范例;期望读者以此为模板,按照套路来走,并制作更多作品。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/63344.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Crond和sudo

目录 前言 一、Crond &#xff08;一&#xff09;、一次性任务 &#xff08;二&#xff09;、周期性任务 1./etc/crontab中加入 2.使用crontab命令编辑计划任务 二、sudo 1.sudo概念 2.sudo提权 总结 前言 crond是linux下用来周期性的执行某种任务或等待处理某些事件的…

今天小编继续给大家分享五款高效的电脑宝藏软件

目录 1、keytweak 2、ScreenToGif 3、Greenshot截屏工具 4、GIMP 5、HandBrake 1、keytweak keytweak 简单来说就是一个键盘按键修改器&#xff0c;说白了就是一个键盘按键重映射的软件。比如你键盘上的Q不好用了&#xff0c;你可以更换成一个不常见的按键来代替Q键&#x…

STM32 CubeMX USB_(HID 鼠标和键盘)

STM32 CubeMX STM32 CubeMX USB_HID&#xff08;HID 鼠标和键盘&#xff09; STM32 CubeMX前言 《鼠标》一、STM32 CubeMX 设置USB时钟设置USB使能UBS功能选择 二、代码部分添加代码鼠标发送给PC的数据解析实验效果 《键盘》STM32 CubeMX 设置&#xff08;同上&#xff09;代码…

探索PostgreSQL的新功能:最新版本更新解析

PostgreSQL作为一种强大而开源的关系型数据库管理系统&#xff0c;不断在不断进化和改进。每一次的版本更新都带来了更多功能和改进&#xff0c;让用户在处理大规模数据和复杂查询时体验更好的性能和功能。在本文中&#xff0c;我们将深入探索PostgreSQL的最新版本更新&#xf…

系统架构设计高级技能 · 软件架构概念、架构风格、ABSD、架构复用、DSSA(一)【系统架构设计师】

系列文章目录 系统架构设计高级技能 软件架构概念、架构风格、ABSD、架构复用、DSSA&#xff08;一&#xff09;【系统架构设计师】 系统架构设计高级技能 系统质量属性与架构评估&#xff08;二&#xff09;【系统架构设计师】 系统架构设计高级技能 软件可靠性分析与设计…

小黑子—JavaWeb:第六章 - Filter、Listener、AJAX与JSON

JavaWeb入门6.0 1. Filter1.1 Filter快速入门1.2 Filter执行流程1.3 Filter拦截路径配置1.4 Filter过滤器链1.5 案例登录验证 2. Listener2.1 ServletContextListener使用 3. AJAX3.1 AJAX 快速入门3.2 案例 验证用户名是否存在3.3 Axios 异步框架3.3.1 Axios 快速入门3.3.2 Ax…

涂鸦智能获Matter Non-VID Scoped PAA资质 助力开发者拥抱Matter生态

今年5月&#xff0c;全球化IoT开发者平台涂鸦智能&#xff08;NYSE: TUYA&#xff0c;HKEX: 2391&#xff09;正式生成Tuya Matter PAA密钥根&#xff0c;并于7月&#xff0c;成功通过了连接标准联盟和第三方MA机构审查而上线。自此&#xff0c;涂鸦正式成为全球同时提供支持Ma…

Docker 发布一个springboot项目

文章目录 1、新建SpringBootDemo项目并打包2、使用Dockerfile打包&#xff08;基础用法&#xff09;进一步maven源码打包法 3、更进一步&#xff08;maven插件打包&#xff09;docker-maven-pluginspring-boot-maven-plugin前提条件本地环境配置项目环境配置maven插件打包运行校…

pycharm出现python test运行报错(pytest模式)

pycharm出现python test运行报错 一、python test 执行代码报错二、删除运行配置三、修改pycharm默认配置为 unittests四、成功&#xff01; 一、python test 执行代码报错 二、删除运行配置 三、修改pycharm默认配置为 unittests 四、成功&#xff01;

多语言一键铺货跨境电商平台快速开发(java开源)

要搭建一个多语言一键铺货跨境电商平台&#xff0c;可以参考以下步骤&#xff1a; 1. 确定需求&#xff1a;首先&#xff0c;明确平台的功能需求&#xff0c;包括多语言支持、一键铺货功能、跨境支付等。 2. 选择适合的开源项目&#xff1a;选择一个适合的Java开源电商平台项…

C语言系列之原码、反码和补码

一.欢迎来到我的酒馆 讨论c语言中&#xff0c;原码、反码、补码。 目录 一.欢迎来到我的酒馆二.原码 二.原码 2.1在计算机中&#xff0c;所有数据都是以二进制存储的&#xff0c;但不是直接存储二进制数&#xff0c;而是存储二进制的补码。原码很好理解&#xff0c;就是对应的…

SpringBoot + Docker 实现一次构建到处运行~

一、容器化部署的好处 图片 Docker 作为一种新兴的虚拟化方式&#xff0c;它可以更高效的利用系统资源&#xff0c;不需要进行硬件虚拟以及运行完整操作系统等额外开销。 传统的虚拟机技术启动应用服务往往需要数分钟&#xff0c;而 Docker 容器应用&#xff0c;由于直接运行…

vue项目实战-脑图编辑管理系统kitymind百度脑图

前言 项目为前端vue项目&#xff0c;把kitymind百度脑图整合到前端vue项目中&#xff0c;显示了脑图的绘制&#xff0c;编辑&#xff0c;到处为json&#xff0c;png&#xff0c;text等格式的功能 文章末尾有相关的代码链接&#xff0c;代码只包含前端项目&#xff0c;在原始的…

Stephen Wolfram:ChatGPT 的训练

The Training of ChatGPT ChatGPT 的训练 OK, so we’ve now given an outline of how ChatGPT works once it’s set up. But how did it get set up? How were all those 175 billion weights in its neural net determined? Basically they’re the result of very large…

opencv基础-38 形态学操作-闭运算(先膨胀,后腐蚀)cv2.morphologyEx(img, cv2.MORPH_CLOSE, kernel)

闭运算是先膨胀、后腐蚀的运算&#xff0c;它有助于关闭前景物体内部的小孔&#xff0c;或去除物体上的小黑点&#xff0c;还可以将不同的前景图像进行连接。 例如&#xff0c;在图 8-17 中&#xff0c;通过先膨胀后腐蚀的闭运算去除了原始图像内部的小孔&#xff08;内部闭合的…

在Raspberry Pi 4上安装Ubuntu 20.04 + ROS noetic(不带显示器)

在Raspberry Pi 4上安装Ubuntu 20.04 ROS noetic&#xff08;不带显示器&#xff09; 1. 所需设备 所需设备&#xff1a; 树莓派 4 B 型 wifi microSD 卡&#xff1a;最小 32GB MicroSD 转 SD 适配器 &#xff08;可选&#xff09;显示器&#xff0c;鼠标等 2. 树莓派…

【山河送书第五期】:《码上行动:利用Python与ChatGPT高效搞定Excel数据分析》参与活动,送书三本!!

《码上行动&#xff1a;利用Python与ChatGPT高效搞定Excel数据分析》 前言内容提要本书亮点购买链接参与方式往期赠书回顾&#xff1a; 前言 在过去的 5 年里&#xff0c;Python 已经 3 次获得 TIOBE 指数年度大奖&#xff0c;这得益于数据科学和人工智能领域的发展&#xff0…

【转】金融行业JR/T0197-2020《金融数据安全 数据安全分级指南》解读

原文链接&#xff1a;金融行业JR/T0197-2020《金融数据安全 数据安全分级指南》解读 《金融数据安全 数据安全分级指南》 解 读 随着IT技术的发展&#xff0c;银行的基础业务、核心流程等众多事务和活动都运营在信息化基础之上&#xff0c;金融机构运行过程中产生了大量的数字…

GNSS基本原理

大家都知道&#xff0c;GNSS卫星之所以能够对地球上的终端&#xff08;例如手机、汽车、轮船、飞机等&#xff09;进行定位&#xff0c;依靠的是三维坐标系。 找至少4颗卫星&#xff0c;分别计算各个卫星与终端之间的距离△L&#xff08;这个距离也被称为“伪距”&#xff09;&…

RISC-V基础之函数调用(五)函数递归调用及函数参数数量溢出(超出现有寄存器个数)约定(包含实例)

首先先解释一下栈在函数调用中的作用&#xff0c;更详细的部分请参照考研复习之数据结构笔记&#xff08;五&#xff09;栈和队列&#xff08;上&#xff09;&#xff08;包含栈的相关内容&#xff09;_管二狗赶快去工作&#xff01;的博客-CSDN博客 函数嵌套调用栈的作用是用…