自动生成文章摘要--TianliGPT

2023-12-11前端2 分钟239 次阅读
AI 摘要salmon-ai

本文详细解析了 TianliGPT 文章摘要工具的原理与接入方法,介绍了它如何基于

前言

最近博主看到挺多博客都接入了 AI 文章摘要,感觉挺不错的,可以让读者了解这篇文章的内容大概,看看这篇文章是否有自己需要的内容,减少了读者查询文章的时间。接下来我将在下面聊聊 TianliGPT 并去使用它。

简介

什么是TianliGPT?

TianliGPT 是一个基于 GPT-3.5 的文字摘要生成工具,你可以将需要提取摘要的文本内容发送给 TianliGPT,稍等一会他就可以给你发送一个基于这段文本内容的摘要。

  • 实时生成的摘要
  • 自动生成,无需人工干预
  • 一次生成,再次生成无需消耗key
  • 包含文字审核过滤,适用于中国大陆
  • 支持中国大陆访问

如何使用TianliGPT?

我们可以通过在网页中嵌入TianliGPT的服务支持,让TianliGPT能够获取到你需要提交的内容。

配置完后,可以前往https://afdian.net/item/f18c2e08db4411eda2f25254001e7c00申请 key,充值所需字符。

教程

首先可以去免费领取

静态页面引入

如果当前你的网站是静态页面,直接在文章靠后位置引入js和css

html 复制代码
<link rel="stylesheet" href="https://cdn1.tianli0.top/gh/zhheo/Post-Abstract-AI@0.7/tianli_gpt.css">
<script>
let tianliGPT_postSelector = '#post #article-container';
let tianliGPT_key = '5Q5mpqRK5DkwT1X9Gi5e';
</script>
<script src="https://cdn1.tianli0.top/gh/zhheo/Post-Abstract-AI@0.7/tianli_gpt.js"></script>

动态页面

这里我以我博客页面为例子,这里由于我怕资源偶尔访问不到,索性放在项目里了。

html 复制代码
<template>
  <div>
    <v-card class="article-wrapper">
      <article
          id="write"
          class="article-content markdown-body"
          v-html="article.articleContent"
          ref="article"
      />
    </v-card>
  </div>
</template>
<script>
  mounted() {
    // 可以在获取文章成功后执行此方法。 
    this.loadTianliGPT();
  },  
  beforeDestroy() {
    // 查找具有 "post-TianliGPT" 类的元素
    const existingAIDiv = document.querySelector(".post-TianliGPT");
    // 如果找到了这个元素,就从其父元素中删除它
    if (existingAIDiv) {
      existingAIDiv.parentElement.removeChild(existingAIDiv);
    }
  },
  methods: {
    loadTianliGPT() {
      // 创建link元素,引入样式表
      const linkElement = document.createElement('link');
      linkElement.rel = 'stylesheet';
      // linkElement.href = 'https://cdn1.tianli0.top/gh/zhheo/Post-Abstract-AI@0.7/tianli_gpt.css';
      linkElement.href = '/css/tianli_gpt.css';
      document.head.appendChild(linkElement);

      window.tianliGPT_postSelector = '#write';
      window.tianliGPT_key = '5Q5mpqRK5DkwT1X9Gi5e';
      // window.tianliGPT_postURL = "https://www.blog.salmonedu.ltd" + window.location.pathname;
      window.tianliGPT_postURL = window.document.documentURI;

      // 创建script元素,引入JavaScript脚本
      const scriptElement = document.createElement('script');
      // scriptElement.src = 'https://cdn1.tianli0.top/gh/zhheo/Post-Abstract-AI@0.7/tianli_gpt.js';
      scriptElement.src = '/js/tianli_gpt.js';
      document.body.appendChild(scriptElement);
    },
  }
</script>

效果

image.png
觉得有用就点个赞,不用登录也能读

评论

0 条
登录 之后才能评论
—
还没有评论,来说第一句