<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>NotionNext BLOG</title>
        <link>https://notion.zyqn.site/</link>
        <description>notion的网站</description>
        <lastBuildDate>Sun, 27 Jul 2025 16:30:41 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>zh-CN</language>
        <copyright>All rights reserved 2025, 悟然</copyright>
        <item>
            <title><![CDATA[爬取豆瓣筛选电影]]></title>
            <link>https://notion.zyqn.site/article/爬虫</link>
            <guid>https://notion.zyqn.site/article/爬虫</guid>
            <pubDate>Sat, 05 Oct 2024 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="container" class="mx-auto undefined"><main class="notion light-mode notion-page notion-block-1160bfe8f1c280dcb24dc24b5552eb46"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1160bfe8f1c2807ca1b9f489a6e12525" data-id="1160bfe8f1c2807ca1b9f489a6e12525"><span><div id="1160bfe8f1c2807ca1b9f489a6e12525" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1160bfe8f1c2807ca1b9f489a6e12525" title="爬取豆瓣筛选电影"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">爬取豆瓣筛选电影</span></span></h2><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1160bfe8f1c280a6a474c0e6ebfda780" data-id="1160bfe8f1c280a6a474c0e6ebfda780"><span><div id="1160bfe8f1c280a6a474c0e6ebfda780" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1160bfe8f1c280a6a474c0e6ebfda780" title="1. 了解请求的参数"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. 了解请求的参数</span></span></h4><div class="notion-text notion-block-1160bfe8f1c280b0ae71ddd4089e3d10">在开始爬取之前，首先需要了解访问豆瓣电影页面所需的请求参数。这通常包括查询字符串、分页信息、排序方式等。可以通过浏览器的开发者工具（F12）来查看具体的请求URL和参数。</div><ul class="notion-list notion-list-disc notion-block-1160bfe8f1c280f9b493e1cc746f0ffb"><li><b>URL 和路径</b>：找到目标页面的基本URL。</li></ul><ul class="notion-list notion-list-disc notion-block-1160bfe8f1c280b8a9dbd40e60ae6009"><li><b>查询参数</b>：如<code class="notion-inline-code">start</code>（分页）、<code class="notion-inline-code">sort</code>（排序方式，比如按评分、按热度等）、<code class="notion-inline-code">genres</code>（类型）等。</li></ul><ul class="notion-list notion-list-disc notion-block-1160bfe8f1c280de961cfa7a58dcd8cc"><li><b>Headers</b>：一些必要的头信息，如User-Agent、Cookies（如果需要登录的话）。</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1160bfe8f1c280db8016c45cc88e36b7" data-id="1160bfe8f1c280db8016c45cc88e36b7"><span><div id="1160bfe8f1c280db8016c45cc88e36b7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1160bfe8f1c280db8016c45cc88e36b7" title="2. 分析请求的目标"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2. 分析请求的目标</span></span></h4><div class="notion-text notion-block-1160bfe8f1c280ab9e3ffca86514646a">明确你想要获取的信息，比如电影的标题、导演、主演、评分、评论数等。确定这些信息在网页中的位置，比如在HTML中的哪个标签或类名下。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1160bfe8f1c280b9a99fef3547379a73" data-id="1160bfe8f1c280b9a99fef3547379a73"><span><div id="1160bfe8f1c280b9a99fef3547379a73" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1160bfe8f1c280b9a99fef3547379a73" title="3. 收集所需的信息或资源"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">3. 收集所需的信息或资源</span></span></h4><div class="notion-text notion-block-1160bfe8f1c280fe9001d1c3fad17c8f">编写代码以发送HTTP请求并收集数据。这通常使用Python库如requests获取网页源代码，然后用BeautifulSoup或lxml解析HTML。</div><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-python">import requests
import json
import brotli
import pprint

# 设置请求的URL
for i in range(0, 200, 20):
    url = &quot;&lt;https://m.douban.com/rexxar/api/v2/movie/recommend&gt;&quot;

    # 设置查询参数
    params = {
        &#x27;refresh&#x27;: &#x27;0&#x27;,
        &#x27;start&#x27;: i,
        &#x27;count&#x27;: &#x27;20&#x27;,
        &#x27;selected_categories&#x27;: &#x27;{&quot;类型&quot;:&quot;喜剧&quot;,&quot;地区&quot;:&quot;华语&quot;}&#x27;,
        &#x27;uncollect&#x27;: &#x27;false&#x27;,
        &#x27;tags&#x27;: &#x27;喜剧,华语&#x27;
    }

    # 设置请求头
    headers = {
        &#x27;authority&#x27;: &#x27;m.douban.com&#x27;,
        &#x27;content-type&#x27;: &#x27;application/json;charset=UTF-8&#x27;,
        &#x27;method&#x27;: &#x27;GET&#x27;,
        &#x27;scheme&#x27;: &#x27;https&#x27;,
        &#x27;accept&#x27;: &#x27;application/json, text/plain, */*&#x27;,
        &#x27;accept-encoding&#x27;: &#x27;gzip, deflate, br, zstd&#x27;,
        &#x27;accept-language&#x27;: &#x27;zh-CN,zh;q=0.9,en;q=0.8,en-US;q=0.7&#x27;,
        &#x27;cookie&#x27;: &#x27;ll=&quot;118249&quot;; __utma=30149280.1322661629.1680093798.1693740274.1696601757.3; bid=xeizLvc9md8; viewed=&quot;5367706_3810699_36071759&quot;; ap_v=0,6.0&#x27;,
        &#x27;origin&#x27;: &#x27;&lt;https://movie.douban.com&gt;&#x27;,
        &#x27;priority&#x27;: &#x27;u=1, i&#x27;,
        &#x27;referer&#x27;: &#x27;&lt;https://movie.douban.com/explore&gt;&#x27;,
        &#x27;user-agent&#x27;: &#x27;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36&#x27;
    }

    # 发送GET请求
    response = requests.get(url, params=params, headers=headers)

    # 检查Content-Encoding是否是Brotli
    content_encoding = response.headers.get(&#x27;Content-Encoding&#x27;)

    if content_encoding == &#x27;br&#x27;:
        try:
            # 如果是Brotli编码，尝试解压缩
            decompressed_data = brotli.decompress(response.content)
            response_text = decompressed_data.decode(&#x27;utf-8&#x27;)
        except brotli.error as e:
            # print(f&quot;Brotli解压缩失败: {e}&quot;)
            response_text = response.content.decode(&#x27;utf-8&#x27;, errors=&#x27;ignore&#x27;)
    else:
        # 如果不是Brotli编码，使用 requests 自动推断编码
        response.encoding = response.apparent_encoding
        response_text = response.text

    # 尝试解析为JSON
    try:
        response_json = json.loads(response_text)[&#x27;items&#x27;]
        # 便利输出
        for item in response_json:
            if item[&#x27;rating&#x27;][&#x27;value&#x27;] &gt; 8.0:
                print(str(item[&#x27;title&#x27;]) + &quot;:&quot; + str(item[&#x27;rating&#x27;][&#x27;value&#x27;]))

        # pprint.pprint(response_json)
    except json.decoder.JSONDecodeError:
        print(&quot;响应内容不是有效的JSON格式&quot;)
</code></pre><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1160bfe8f1c280749df4c2f8ea5a9d37" data-id="1160bfe8f1c280749df4c2f8ea5a9d37"><span><div id="1160bfe8f1c280749df4c2f8ea5a9d37" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1160bfe8f1c280749df4c2f8ea5a9d37" title="4. 处理或分析收集到的信息"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">4. 处理或分析收集到的信息</span></span></h4><div class="notion-text notion-block-1160bfe8f1c280439536e7285c4b0067">一旦成功收集到数据，你就可以进行处理和分析：</div><ul class="notion-list notion-list-disc notion-block-1160bfe8f1c2802db9eef39570c3a336"><li><b>解析JSON或HTML</b>：根据返回的数据格式解析信息。</li></ul><ul class="notion-list notion-list-disc notion-block-1160bfe8f1c280cc93aad1e230235595"><li><b>提取所需字段</b>：从数据中提取关键信息，如电影名称、评分等。</li></ul><ul class="notion-list notion-list-disc notion-block-1160bfe8f1c280968673c9bf334b4a80"><li><b>存储数据</b>：将数据存入CSV文件、数据库或其他存储系统中，以便后续分析。</li></ul><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-python">import csv
import json
import requests
import brotli

# 设置请求的URL
url = &quot;&lt;https://m.douban.com/rexxar/api/v2/movie/recommend&gt;&quot;

# 创建一个空列表来存储电影信息
movies_list = []

# 循环分页请求
for i in range(0, 200, 20):
    # 设置查询参数
    params = {
        &#x27;refresh&#x27;: &#x27;0&#x27;,
        &#x27;start&#x27;: i,
        &#x27;count&#x27;: &#x27;20&#x27;,
        &#x27;selected_categories&#x27;: &#x27;{&quot;类型&quot;:&quot;喜剧&quot;,&quot;地区&quot;:&quot;华语&quot;}&#x27;,
        &#x27;uncollect&#x27;: &#x27;false&#x27;,
        &#x27;tags&#x27;: &#x27;喜剧,华语&#x27;
    }

    # 设置请求头
    headers = {
        &#x27;authority&#x27;: &#x27;m.douban.com&#x27;,
        &#x27;content-type&#x27;: &#x27;application/json;charset=UTF-8&#x27;,
        &#x27;method&#x27;: &#x27;GET&#x27;,
        &#x27;scheme&#x27;: &#x27;https&#x27;,
        &#x27;accept&#x27;: &#x27;application/json, text/plain, */*&#x27;,
        &#x27;accept-encoding&#x27;: &#x27;gzip, deflate, br, zstd&#x27;,
        &#x27;accept-language&#x27;: &#x27;zh-CN,zh;q=0.9,en;q=0.8,en-US;q=0.7&#x27;,
        &#x27;cookie&#x27;: &#x27;ll=&quot;118249&quot;; __utma=30149280.1322661629.1680093798.1693740274.1696601757.3; bid=xeizLvc9md8; viewed=&quot;5367706_3810699_36071759&quot;; ap_v=0,6.0&#x27;,
        &#x27;origin&#x27;: &#x27;&lt;https://movie.douban.com&gt;&#x27;,
        &#x27;priority&#x27;: &#x27;u=1, i&#x27;,
        &#x27;referer&#x27;: &#x27;&lt;https://movie.douban.com/explore&gt;&#x27;,
        &#x27;user-agent&#x27;: &#x27;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36&#x27;
    }

    # 发送GET请求
    response = requests.get(url, params=params, headers=headers)

    # 检查Content-Encoding是否是Brotli
    content_encoding = response.headers.get(&#x27;Content-Encoding&#x27;)

    if content_encoding == &#x27;br&#x27;:
        try:
            # 如果是Brotli编码，尝试解压缩
            decompressed_data = brotli.decompress(response.content)
            response_text = decompressed_data.decode(&#x27;utf-8&#x27;)
        except brotli.error as e:
            response_text = response.content.decode(&#x27;utf-8&#x27;, errors=&#x27;ignore&#x27;)
    else:
        response.encoding = response.apparent_encoding
        response_text = response.text

    # 尝试解析为JSON
    try:
        response_json = json.loads(response_text)[&#x27;items&#x27;]
        # 筛选评分大于8.0的电影并添加到列表中
        for item in response_json:
            if item[&#x27;rating&#x27;][&#x27;value&#x27;] &gt; 8.0:
                movies_list.append({
                    &#x27;title&#x27;: item[&#x27;title&#x27;],
                    &#x27;rating&#x27;: item[&#x27;rating&#x27;][&#x27;value&#x27;],
                    &#x27;url&#x27;: item[&#x27;url&#x27;]
                })
    except json.decoder.JSONDecodeError:
        print(&quot;响应内容不是有效的JSON格式&quot;)

# 将收集到的电影信息写入CSV文件
with open(&#x27;douban_movies.csv&#x27;, mode=&#x27;w&#x27;, newline=&#x27;&#x27;, encoding=&#x27;utf-8&#x27;) as file:
    writer = csv.writer(file)
    # 写入表头
    writer.writerow([&#x27;Title&#x27;, &#x27;Rating&#x27;, &#x27;URL&#x27;])

    # 写入每部电影的信息
    for movie in movies_list:
        writer.writerow([movie[&#x27;title&#x27;], movie[&#x27;rating&#x27;], movie[&#x27;url&#x27;]])
</code></pre><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1160bfe8f1c280a3ada8e9879b87b1f7" data-id="1160bfe8f1c280a3ada8e9879b87b1f7"><span><div id="1160bfe8f1c280a3ada8e9879b87b1f7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1160bfe8f1c280a3ada8e9879b87b1f7" title="注意事项："><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">注意事项：</span></span></h4><ul class="notion-list notion-list-disc notion-block-1160bfe8f1c280af8e0ae0b4cf2e06bd"><li><b>法律与道德</b>：遵守网站的robots.txt规则和相关法律法规，不要进行过于频繁的抓取。</li></ul><ul class="notion-list notion-list-disc notion-block-1160bfe8f1c280538e51c3705465a32a"><li><b>反爬机制</b>：可能需要解决验证码或使用代理IP来防止被禁止访问。</li></ul><ul class="notion-list notion-list-disc notion-block-1160bfe8f1c280bcadb4f66fbf6418d5"><li><b>隐私问题</b>：不要抓取用户隐私信息，并确保合规地使用抓取的数据。</li></ul></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[chat2api免费使用GPT-4o]]></title>
            <link>https://notion.zyqn.site/article/CHAT2API</link>
            <guid>https://notion.zyqn.site/article/CHAT2API</guid>
            <pubDate>Mon, 27 May 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[CHAT2API免费的GPT-4o]]></description>
            <content:encoded><![CDATA[<div id="container" class="mx-auto undefined"><main class="notion light-mode notion-page notion-block-55c268611cee42e8b140a1f7f7c2d02a"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-214f52d58c12442a9f00cf46d9576b02" data-id="214f52d58c12442a9f00cf46d9576b02"><span><div id="214f52d58c12442a9f00cf46d9576b02" class="notion-header-anchor"></div><a class="notion-hash-link" href="#214f52d58c12442a9f00cf46d9576b02" title="CHAT2API"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>CHAT2API</b></span></span></h2><div class="notion-text notion-block-d45e6b00030041b08b6806f5d990706f"></div><div class="notion-text notion-block-1c37302dbc0146a494e8dd44d77d3139">🤖 一个简单的 ChatGPT TO API 代理</div><div class="notion-text notion-block-06689f389df64bde92e7a32d08f1e8d7">🌟 无需账号即可使用免费、无限的 <code class="notion-inline-code">GPT-3.5</code></div><div class="notion-text notion-block-5c8c38e7e8ca463fae57a0f7e183b0b2">💥 支持 AccessToken 使用账号，支持 <code class="notion-inline-code">GPT-4</code>、<code class="notion-inline-code">GPT-4o</code>、 <code class="notion-inline-code">GPTs</code></div><div class="notion-text notion-block-28b083cd8bdc4965ac2b960ec39ae589">🔍 回复格式与真实 API 完全一致，适配几乎所有客户端</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-31eeb1c3f90843a4b51a6ecc6536d664" data-id="31eeb1c3f90843a4b51a6ecc6536d664"><span><div id="31eeb1c3f90843a4b51a6ecc6536d664" class="notion-header-anchor"></div><a class="notion-hash-link" href="#31eeb1c3f90843a4b51a6ecc6536d664" title="功能"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>功能</b></span></span></h2><ol start="1" class="notion-list notion-list-numbered notion-block-4518d91b4b194809ab70ad4e6f2cb4e4"><li>免登录 GPT-3.5 对话</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-bb0afe6bebd7487bba49ccedea356d65"><li>GPT-3.5 对话（传入模型名不包含 gpt-4，则默认使用 gpt-3.5，也就是 text-davinci-002-render-sha）</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-e32c40cc4ae94b7a8b679ed422368e3e"><li>GPT-4 对话（传入模型名包含: gpt-4，gpt-4o，gpt-4-moblie 即可使用对应模型，需传入 AccessToken）</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-ed1b80368285400884d971238188923e"><li>GPT-4 画图、代码、联网</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-273a637ed7ef46889d2ce331521e7c8a"><li>支持 GPTs（传入模型名：gpt-4-gizmo-g-*）</li></ol><ol start="6" class="notion-list notion-list-numbered notion-block-f3d3d9b02f61490ab6dfda7d1731e4b4"><li>支持 Team Plus 账号（需传入 team account id）</li></ol><ol start="7" class="notion-list notion-list-numbered notion-block-922c4f2d3cb14ab99e7d09dbc1179f1c"><li>上传图片、文件（格式为 API 对应格式，支持 URL 和 base64）</li></ol><ol start="8" class="notion-list notion-list-numbered notion-block-fc1fbff5efd84392ab680c317054c8eb"><li>WebUI（<a target="_blank" rel="noopener noreferrer" class="notion-link" href="http://127.0.0.1:5005/">http://127.0.0.1:5005</a>，不支持登录使用）</li></ol><ol start="9" class="notion-list notion-list-numbered notion-block-4ce309fbcb6945ae8364914f7656593f"><li>可作为网关使用，可多机分布部署</li></ol><ol start="10" class="notion-list notion-list-numbered notion-block-eb8cf2d3733b46bdb10a6a2cff57b2ab"><li>多账号轮询，同时支持 AccessToken 和 RefreshToken</li></ol><ol start="11" class="notion-list notion-list-numbered notion-block-c62f7c74b8934155af6be36ee86c51f6"><li>Tokens 管理，支持上传、清除</li></ol><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-057c33c3a87644ed80e410cd666dac7b" data-id="057c33c3a87644ed80e410cd666dac7b"><span><div id="057c33c3a87644ed80e410cd666dac7b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#057c33c3a87644ed80e410cd666dac7b" title="部署docker-compose.yml"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">部署<b>docker-compose.yml</b></span></span></h2><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-yaml">version: &#x27;3&#x27;

services:
  chat2api:
    image: lanqian528/chat2api:latest
    container_name: chat2api
    restart: unless-stopped
    ports:
      - &#x27;5005:5005&#x27;
    volumes:
      - ./data:/app/data # 挂载一些需要保存的数据
    environment:
      - TZ=Asia/Shanghai # 设置时区
      - ARKOSE_TOKEN_URL=http://arkose:5006/token # 已内置，不要改动

  arkose:
    image: lanqian528/funcaptcha_solver:latest
    container_name: funcaptcha_solver
    restart: unless-stopped
    ports:
      - &#x27;5006:5006&#x27;
    environment:
      - TZ=Asia/Shanghai # 设置时区</code></pre><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-e3565d00011f4b829ca56629b034e8cc" data-id="e3565d00011f4b829ca56629b034e8cc"><span><div id="e3565d00011f4b829ca56629b034e8cc" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e3565d00011f4b829ca56629b034e8cc" title="环境变量"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">环境变量</span></span></h2><div class="notion-text notion-block-2eaa0b2f38e84f668e8433b4f84ed29a">每个环境变量都有默认值，如果不懂环境变量的含义，请不要设置，更不要传空值，字符串无需引号。</div><table class="notion-simple-table notion-block-1b9d9dbeb3a34797bff9797807818e1e"><tbody><tr class="notion-simple-table-row notion-block-e426472fd4c14b46886ec43153617779"><td class="" style="width:89px"><div class="notion-simple-table-cell">分类</div></td><td class="" style="width:159.0250015258789px"><div class="notion-simple-table-cell">变量名</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">示例值</div></td><td class="" style="width:79px"><div class="notion-simple-table-cell">默认值</div></td><td class="" style="width:219.96250915527344px"><div class="notion-simple-table-cell">描述</div></td></tr><tr class="notion-simple-table-row notion-block-a05685c2d70d4809ba20f3ffbc67fb57"><td class="" style="width:89px"><div class="notion-simple-table-cell">安全相关</div></td><td class="" style="width:159.0250015258789px"><div class="notion-simple-table-cell">API_PREFIX</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">your_prefix</code></div></td><td class="" style="width:79px"><div class="notion-simple-table-cell"><code class="notion-inline-code">None</code></div></td><td class="" style="width:219.96250915527344px"><div class="notion-simple-table-cell">API 前缀密码，不设置容易被人访问，设置后需请求 <code class="notion-inline-code">/your_prefix/v1/chat/completions</code></div></td></tr><tr class="notion-simple-table-row notion-block-2b295d5faf204821afca6dc7a22e5c49"><td class="" style="width:89px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:159.0250015258789px"><div class="notion-simple-table-cell">AUTHORIZATION</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">your_first_authorization</code><span style="padding:0.5em"></span><code class="notion-inline-code">your_second_authorization</code></div></td><td class="" style="width:79px"><div class="notion-simple-table-cell"><code class="notion-inline-code">[]</code></div></td><td class="" style="width:219.96250915527344px"><div class="notion-simple-table-cell">你自己为使用多账号轮询 Tokens 设置的授权，英文逗号分隔</div></td></tr><tr class="notion-simple-table-row notion-block-1c3e0e041e814f32ac9b780ec914ee5b"><td class="" style="width:89px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:159.0250015258789px"><div class="notion-simple-table-cell">AUTH_KEY</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">your_auth_key</code></div></td><td class="" style="width:79px"><div class="notion-simple-table-cell"><code class="notion-inline-code">None</code></div></td><td class="" style="width:219.96250915527344px"><div class="notion-simple-table-cell">私人网关需要加<code class="notion-inline-code">auth_key</code>请求头才设置该项</div></td></tr><tr class="notion-simple-table-row notion-block-f1f8d1e1558c45bd80134456b4332ead"><td class="" style="width:89px"><div class="notion-simple-table-cell">请求相关</div></td><td class="" style="width:159.0250015258789px"><div class="notion-simple-table-cell">CHATGPT_BASE_URL</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">https://chatgpt.com</code></div></td><td class="" style="width:79px"><div class="notion-simple-table-cell"><code class="notion-inline-code">https://chatgpt.com</code></div></td><td class="" style="width:219.96250915527344px"><div class="notion-simple-table-cell">ChatGPT 网关地址，设置后会改变请求的网站，多个网关用逗号分隔</div></td></tr><tr class="notion-simple-table-row notion-block-b096f24e47984cef9535efc843fd38d9"><td class="" style="width:89px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:159.0250015258789px"><div class="notion-simple-table-cell">PROXY_URL</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">http://ip:port</code><span style="padding:0.5em"></span><code class="notion-inline-code">http://username:password@ip:port</code></div></td><td class="" style="width:79px"><div class="notion-simple-table-cell"><code class="notion-inline-code">[]</code></div></td><td class="" style="width:219.96250915527344px"><div class="notion-simple-table-cell">代理 URL，多个代理用逗号分隔</div></td></tr><tr class="notion-simple-table-row notion-block-40cf9718a94740c384d8e0644ec877aa"><td class="" style="width:89px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:159.0250015258789px"><div class="notion-simple-table-cell">ARKOSE_TOKEN_URL</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">https://example.com/token</code></div></td><td class="" style="width:79px"><div class="notion-simple-table-cell"><code class="notion-inline-code">[]</code></div></td><td class="" style="width:219.96250915527344px"><div class="notion-simple-table-cell">获取 Arkose token 的地址</div></td></tr><tr class="notion-simple-table-row notion-block-2c65c787a20b4a87b5ec50eed6822da6"><td class="" style="width:89px"><div class="notion-simple-table-cell">功能相关</div></td><td class="" style="width:159.0250015258789px"><div class="notion-simple-table-cell">HISTORY_DISABLED</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">true</code></div></td><td class="" style="width:79px"><div class="notion-simple-table-cell"><code class="notion-inline-code">true</code></div></td><td class="" style="width:219.96250915527344px"><div class="notion-simple-table-cell">是否不保存聊天记录并返回 conversation_id</div></td></tr><tr class="notion-simple-table-row notion-block-856c59f9627c4b2a8a32f6ec7fd0c662"><td class="" style="width:89px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:159.0250015258789px"><div class="notion-simple-table-cell">POW_DIFFICULTY</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">00003a</code></div></td><td class="" style="width:79px"><div class="notion-simple-table-cell"><code class="notion-inline-code">00003a</code></div></td><td class="" style="width:219.96250915527344px"><div class="notion-simple-table-cell">要解决的工作量证明难度，不懂别设置</div></td></tr><tr class="notion-simple-table-row notion-block-0392fb999286496f976e1dc1be35e12b"><td class="" style="width:89px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:159.0250015258789px"><div class="notion-simple-table-cell">RETRY_TIMES</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">3</code></div></td><td class="" style="width:79px"><div class="notion-simple-table-cell"><code class="notion-inline-code">3</code></div></td><td class="" style="width:219.96250915527344px"><div class="notion-simple-table-cell">出错重试次数，使用 AUTHORIZATION 会自动轮询下一个账号</div></td></tr><tr class="notion-simple-table-row notion-block-90e1580813dd4037aba17affb474a99f"><td class="" style="width:89px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:159.0250015258789px"><div class="notion-simple-table-cell">ENABLE_GATEWAY</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">true</code></div></td><td class="" style="width:79px"><div class="notion-simple-table-cell"><code class="notion-inline-code">true</code></div></td><td class="" style="width:219.96250915527344px"><div class="notion-simple-table-cell">是否启用网关模式（WEBUI）</div></td></tr><tr class="notion-simple-table-row notion-block-09710361e73d41cda431360910c4a1fa"><td class="" style="width:89px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:159.0250015258789px"><div class="notion-simple-table-cell">CONVERSATION_ONLY</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">false</code></div></td><td class="" style="width:79px"><div class="notion-simple-table-cell"><code class="notion-inline-code">false</code></div></td><td class="" style="width:219.96250915527344px"><div class="notion-simple-table-cell">是否直接使用对话接口，如果你用的网关支持自动解决pow和arkose才启用</div></td></tr><tr class="notion-simple-table-row notion-block-614fd0e533984d7aa63ca793e3d4539e"><td class="" style="width:89px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:159.0250015258789px"><div class="notion-simple-table-cell">ENABLE_LIMIT</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">true</code></div></td><td class="" style="width:79px"><div class="notion-simple-table-cell"><code class="notion-inline-code">true</code></div></td><td class="" style="width:219.96250915527344px"><div class="notion-simple-table-cell">开启后不尝试突破官方次数限制，尽可能防止封号</div></td></tr><tr class="notion-simple-table-row notion-block-7a8a1dd9e7d04ae7912ff9b969b101f5"><td class="" style="width:89px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:159.0250015258789px"><div class="notion-simple-table-cell">UPLOAD_BY_URL</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">false</code></div></td><td class="" style="width:79px"><div class="notion-simple-table-cell"><code class="notion-inline-code">false</code></div></td><td class="" style="width:219.96250915527344px"><div class="notion-simple-table-cell">开启后按照 <code class="notion-inline-code">URL+空格+正文</code> 进行对话，自动解析 URL 内容并上传，多个 URL 用空格分隔</div></td></tr><tr class="notion-simple-table-row notion-block-3a05eab010b34bb6903d63664cde11b2"><td class="" style="width:89px"><div class="notion-simple-table-cell">ㅤ</div></td><td class="" style="width:159.0250015258789px"><div class="notion-simple-table-cell">CHECK_MODEL</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"><code class="notion-inline-code">false</code></div></td><td class="" style="width:79px"><div class="notion-simple-table-cell"><code class="notion-inline-code">false</code></div></td><td class="" style="width:219.96250915527344px"><div class="notion-simple-table-cell">检查账号是否支持传入模型，开启后可以稍微避免4o返回3.5内容，但是会增加请求时延，且并不能解决降智问题</div></td></tr></tbody></table><div class="notion-blank notion-block-374771ccbb514552bfd36e6622359e71"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GitHub action打包推送镜仓库]]></title>
            <link>https://notion.zyqn.site/article/GitHub action</link>
            <guid>https://notion.zyqn.site/article/GitHub action</guid>
            <pubDate>Mon, 27 May 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[GitHub action打包推送镜仓库]]></description>
            <content:encoded><![CDATA[<div id="container" class="mx-auto undefined"><main class="notion light-mode notion-page notion-block-0e700ca0b86a4dd8bf6969483435be91"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-06f930751fe242b0b91bdb8e2ae1759c" data-id="06f930751fe242b0b91bdb8e2ae1759c"><span><div id="06f930751fe242b0b91bdb8e2ae1759c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#06f930751fe242b0b91bdb8e2ae1759c" title="一、先来创建一个项目"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>一、先来创建一个项目</b></span></span></h2><div class="notion-text notion-block-d61f6fb63a0e41e58a4f233991bb84a0">首先在 github 上面创建一个私有项目</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-f1e30204429d42d1a407eaa86a92c139"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fccc2507b-ee1c-4168-880a-941be01d0730%2Fe4ff6b94-9522-4bf3-893d-73289d812eba%2FUntitled.png?table=block&amp;id=f1e30204-429d-42d1-a407-eaa86a92c139&amp;t=f1e30204-429d-42d1-a407-eaa86a92c139" alt="notion image" loading="lazy" decoding="async"/></div></figure><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-478920ca8cf94c8486c9a73b521737f3" data-id="478920ca8cf94c8486c9a73b521737f3"><span><div id="478920ca8cf94c8486c9a73b521737f3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#478920ca8cf94c8486c9a73b521737f3" title="二、前置准备工作"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>二、前置准备工作</b></span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-ed2c79e1cbb34fd78bc1df7b6d08f409" data-id="ed2c79e1cbb34fd78bc1df7b6d08f409"><span><div id="ed2c79e1cbb34fd78bc1df7b6d08f409" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ed2c79e1cbb34fd78bc1df7b6d08f409" title="1.推送ghcr.io"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1.推送<a target="_blank" rel="noopener noreferrer" class="notion-link" href="http://ghcr.io/">ghcr.io</a></span></span></h3><div class="notion-text notion-block-fb8abf245ca34b089c919011474c55a1">去  <!-- -->这个网站生成一个 token</div><blockquote class="notion-quote notion-block-2172290b95084c47bc28d4518a285013"><div> PS:注意此 token 需要读写 packages 等权限 详情请见这里准备好你的要部署的服务器的 账号 和密码（当前页可以使用秘钥登录，这里暂且使用密码）想好你的镜像名称（此处以 web-image 为例）</div></blockquote><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-db6518f5027a4d9fbc45a9be3fbdfa5e" data-id="db6518f5027a4d9fbc45a9be3fbdfa5e"><span><div id="db6518f5027a4d9fbc45a9be3fbdfa5e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#db6518f5027a4d9fbc45a9be3fbdfa5e" title="2.推送hub.docker.com"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2.推送<a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://hub.docker.com/">hub.docker.com</a></span></span></h3><div class="notion-text notion-block-b49cc81540f84a94a20a192b5c0f39ec">1.首先当然是申请账号，然后在Account setting、security下面有个AccessToken，生成一个</div><div class="notion-text notion-block-ff83b8ec835e4169a5585815e844d223">2.然后在github项目的setting=&gt;security下，找到secrets and variables</div><div class="notion-text notion-block-e21e8c6e4bea4964963eae29c5c09daa">3.配置上DOCKERHUB_USER和DOCKERHUB_TOKEN</div><div class="notion-text notion-block-858b7d312ce3450aa52a0c1a0e46b397">4.将dockerhub的image namespace改为自己的，因为官方的账号我们没有权限推送，只能推自己账号下的空间</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-24bea13909364ac4b74e0ab8ab678c2c" data-id="24bea13909364ac4b74e0ab8ab678c2c"><span><div id="24bea13909364ac4b74e0ab8ab678c2c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#24bea13909364ac4b74e0ab8ab678c2c" title="三、编写 github action"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">三、<b>编写 github action</b></span></span></h2><div class="notion-text notion-block-e55d486fc69d4a458be9997c1e14a288">1、在源仓库的<code class="notion-inline-code">.github/workflows</code>目录创建一个 <code class="notion-inline-code">publish-image.yml</code></div><div class="notion-text notion-block-3f1d3a25206944778902da4fe79457da">2、在workflow文件中设置触发条件和作业（jobs）&quot;</div><div class="notion-text notion-block-94389b09cafa4036a32387012316d163">&quot;示例代码如下：&quot;
</div><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-yaml">name: Docker Hub

on:
  push:
    branches: [dev]
    tags: [&quot;v*.*.*&quot;]
  pull_request:
    branches: [dev]

env:
  REGISTRY: docker.io
  IMAGE_NAME: ${{ secrets.DOCKER_USERNAME }}/pandora-web

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: Log into Docker Hub
        if: github.event_name != &#x27;pull_request&#x27;
        uses: docker/login-action@v1
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
          tags: |
            type=sha
            type=ref,event=branch,branch=dev
            type=semver,pattern={{version}}

      - name: Build and push Docker image
        uses: docker/build-push-action@v2
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: ${{ github.event_name != &#x27;pull_request&#x27; }}
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}</code></pre><div class="notion-text notion-block-0ca74cacca6e46da804d58d869c05d16">这段代码是一个GitHub Actions的工作流程配置文件，用于自动化构建和推送Docker镜像到Docker Hub。它在特定的条件下（如代码推送到特定分支或创建拉取请求时）触发。以下是详细解释：</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-5d64c4fc7e734138a59b2ade2d17a6a0" data-id="5d64c4fc7e734138a59b2ade2d17a6a0"><span><div id="5d64c4fc7e734138a59b2ade2d17a6a0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#5d64c4fc7e734138a59b2ade2d17a6a0" title="工作流程名称"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">工作流程名称</span></span></h4><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-yaml">name: Docker Hub</code></pre><div class="notion-text notion-block-d953ffab1f874605835496def0ab7d5f">工作流程的名称为“Docker Hub”。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-392d898907414da880770eca7539ca84" data-id="392d898907414da880770eca7539ca84"><span><div id="392d898907414da880770eca7539ca84" class="notion-header-anchor"></div><a class="notion-hash-link" href="#392d898907414da880770eca7539ca84" title="触发条件"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">触发条件</span></span></h4><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-yaml">on:
  push:
    branches: [dev]
    tags: [&quot;v*.*.*&quot;]
  pull_request:
    branches: [dev]</code></pre><div class="notion-text notion-block-eff6d7a63bde40e5a55aeff3c3640b06">该工作流程会在以下情况下触发：</div><ul class="notion-list notion-list-disc notion-block-504e07de6b854bd4baf51dc19b51cf4d"><li>当代码推送到<code class="notion-inline-code">dev</code>分支时。</li></ul><ul class="notion-list notion-list-disc notion-block-d9b862dd1b1c4131b5dbb030341fada6"><li>当推送带有特定模式（<code class="notion-inline-code">v*.*.*</code>）的标签时。</li></ul><ul class="notion-list notion-list-disc notion-block-2a020d906f904b16b4cfa1c33fafd6b3"><li>当针对<code class="notion-inline-code">dev</code>分支创建拉取请求时。</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-e130405eb996401990006256bca766fe" data-id="e130405eb996401990006256bca766fe"><span><div id="e130405eb996401990006256bca766fe" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e130405eb996401990006256bca766fe" title="环境变量"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">环境变量</span></span></h4><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-yaml">env:
  REGISTRY: docker.io
  IMAGE_NAME: ${{ secrets.DOCKER_USERNAME }}/pandora-web</code></pre><div class="notion-text notion-block-8a85167cdedd408aa136f5e805b584c2">定义了一些环境变量：</div><ul class="notion-list notion-list-disc notion-block-bd0ca80785644f90a52eb755ea04cc8c"><li><code class="notion-inline-code">REGISTRY</code>：Docker注册表地址，设为<code class="notion-inline-code">docker.io</code>。</li></ul><ul class="notion-list notion-list-disc notion-block-e56b54660b0c4cac933fa0b0cb713137"><li><code class="notion-inline-code">IMAGE_NAME</code>：Docker镜像名称，包含了从机密变量中读取的Docker用户名和固定的镜像名称<code class="notion-inline-code">pandora-web</code>。</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-af92ed1c19e84b63a18d204ead362ad5" data-id="af92ed1c19e84b63a18d204ead362ad5"><span><div id="af92ed1c19e84b63a18d204ead362ad5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#af92ed1c19e84b63a18d204ead362ad5" title="工作流的任务定义"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">工作流的任务定义</span></span></h4><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-yaml">jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write</code></pre><div class="notion-text notion-block-d81dbd9880f649e38cb6f61949f036b6">定义了一个名为<code class="notion-inline-code">build</code>的任务，运行环境为<code class="notion-inline-code">ubuntu-latest</code>。并且设置了权限，允许读取内容和写入包。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-c4fc7d1fc1c24a4f8aabf5e2c514e29b" data-id="c4fc7d1fc1c24a4f8aabf5e2c514e29b"><span><div id="c4fc7d1fc1c24a4f8aabf5e2c514e29b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#c4fc7d1fc1c24a4f8aabf5e2c514e29b" title="步骤定义"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">步骤定义</span></span></h4><ol start="1" class="notion-list notion-list-numbered notion-block-380241ba180144b3a79d8e6d8aa41b1d"><li><b>检出代码仓库</b></li><ol class="notion-list notion-list-numbered notion-block-380241ba180144b3a79d8e6d8aa41b1d"><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-yaml">- name: Checkout repository
  uses: actions/checkout@v2</code></pre><div class="notion-text notion-block-d11fd439de67404e81975a097a44ef89">使用<code class="notion-inline-code">actions/checkout@v2</code>动作检出代码仓库。</div></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-7f84cf796bdb49a78e5d6e75c9d6a875"><li><b>设置Docker Buildx</b></li><ol class="notion-list notion-list-numbered notion-block-7f84cf796bdb49a78e5d6e75c9d6a875"><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-yaml">- name: Set up Docker Buildx
  uses: docker/setup-buildx-action@v1</code></pre><div class="notion-text notion-block-466332edbc8b4600a8c55e906ac1862d">使用<code class="notion-inline-code">docker/setup-buildx-action@v1</code>设置Docker Buildx，用于构建多平台镜像。</div></ol></ol><ol start="3" class="notion-list notion-list-numbered notion-block-a85204c5f76540e78ec8eda82d146b59"><li><b>登录Docker Hub</b></li><ol class="notion-list notion-list-numbered notion-block-a85204c5f76540e78ec8eda82d146b59"><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-yaml">- name: Log into Docker Hub
  if: github.event_name != &#x27;pull_request&#x27;
  uses: docker/login-action@v1
  with:
    registry: ${{ env.REGISTRY }}
    username: ${{ secrets.DOCKER_USERNAME }}
    password: ${{ secrets.DOCKERHUB_TOKEN }}</code></pre><div class="notion-text notion-block-7d0845fde6364995a1cf4831da473714">这一步在非拉取请求的事件中执行，使用<code class="notion-inline-code">docker/login-action@v1</code>登录Docker Hub。用户名和密码从机密变量中读取。</div></ol></ol><ol start="4" class="notion-list notion-list-numbered notion-block-7d4d0007294149c4b3eb0cfe655fb41b"><li><b>提取Docker元数据</b></li><ol class="notion-list notion-list-numbered notion-block-7d4d0007294149c4b3eb0cfe655fb41b"><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-yaml">- name: Extract Docker metadata
  id: meta
  uses: docker/metadata-action@v3
  with:
    images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
    tags: |
      type=sha
      type=ref,event=branch,branch=dev
      type=semver,pattern={{version}}</code></pre><div class="notion-text notion-block-80b6eb1a1ac848b6928f119a60babf36">使用<code class="notion-inline-code">docker/metadata-action@v3</code>提取Docker元数据并生成标签。根据不同的类型生成标签，如基于SHA的标签、分支标签（当事件为分支推送且分支为dev时）、和基于语义版本（semver）的标签。</div></ol></ol><ol start="5" class="notion-list notion-list-numbered notion-block-560edc10bdfc4927b5ab89aa6239d672"><li><b>构建并推送Docker镜像</b></li><ol class="notion-list notion-list-numbered notion-block-560edc10bdfc4927b5ab89aa6239d672"><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-yaml">- name: Build and push Docker image
  uses: docker/build-push-action@v2
  with:
    context: .
    platforms: linux/amd64,linux/arm64
    push: ${{ github.event_name != &#x27;pull_request&#x27; }}
    tags: ${{ steps.meta.outputs.tags }}
    labels: ${{ steps.meta.outputs.labels }}</code></pre><div class="notion-text notion-block-77ebf38a58af467e9daee44c236516fb">使用<code class="notion-inline-code">docker/build-push-action@v2</code>构建并推送Docker镜像：</div><ul class="notion-list notion-list-disc notion-block-a14022882d9e4b8fad4c0a64efc461d9"><li><code class="notion-inline-code">context</code>：构建上下文，当前目录。</li></ul><ul class="notion-list notion-list-disc notion-block-e1cd7ddede3b4a5d93b81bb859aab879"><li><code class="notion-inline-code">platforms</code>：指定目标平台（amd64和arm64）。</li></ul><ul class="notion-list notion-list-disc notion-block-001d8f85ae2a42249bd848bdf18beaf4"><li><code class="notion-inline-code">push</code>：只有在不是拉取请求的事件中才推送镜像。</li></ul><ul class="notion-list notion-list-disc notion-block-7d75b7512460446b8af2ed7cadb43b0e"><li><code class="notion-inline-code">tags</code>：使用从上一步骤中提取的标签。</li></ul><ul class="notion-list notion-list-disc notion-block-05fb8449b6d344c1ae47ca0447237171"><li><code class="notion-inline-code">labels</code>：使用从上一步骤中提取的标签。</li></ul></ol></ol><div class="notion-text notion-block-8d13e78a08fa4df8b08048dc7b95271d">总体来说，这个GitHub Actions配置文件实现了在特定条件下自动化构建和推送Docker镜像的功能。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-6803bf35ef044792ad2a6157ab71f845" data-id="6803bf35ef044792ad2a6157ab71f845"><span><div id="6803bf35ef044792ad2a6157ab71f845" class="notion-header-anchor"></div><a class="notion-hash-link" href="#6803bf35ef044792ad2a6157ab71f845" title="四、修改的配置"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">四、修改的配置</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-e0235f92710b458ab92b7c1e3e4af56e" data-id="e0235f92710b458ab92b7c1e3e4af56e"><span><div id="e0235f92710b458ab92b7c1e3e4af56e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e0235f92710b458ab92b7c1e3e4af56e" title="1.创建版本号文件"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>1.创建版本号文件</b></span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-4dbac9bb99ea47ee8507490f0006286e"><li><b>创建 </b><code class="notion-inline-code"><b>VERSION</b></code><b> 文件</b>:</li><ol class="notion-list notion-list-numbered notion-block-4dbac9bb99ea47ee8507490f0006286e"><ul class="notion-list notion-list-disc notion-block-c1a84daef66a4a3eb9c5330036e0e042"><li>在你的代码仓库根目录下创建一个名为 <code class="notion-inline-code"><b>VERSION</b></code> 的文件。</li></ul><ul class="notion-list notion-list-disc notion-block-cba49e1d2c024ed48fe39d227792b4ac"><li>文件内容为当前的版本号，例如：</li><ul class="notion-list notion-list-disc notion-block-cba49e1d2c024ed48fe39d227792b4ac"><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-plain text">1.0.0</code></pre></ul></ul></ol></ol><div class="notion-text notion-block-1bfd52dc11f04d2c9d501fd1162a0d28">这样配置之后，每次在 <code class="notion-inline-code"><b>dev</b></code> 分支推送代码时，GitHub Actions将自动递增版本号，构建Docker镜像，并推送到Docker Hub，同时保留所有之前的版本。</div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-7b0408cc91cc45e29d31172334688073" data-id="7b0408cc91cc45e29d31172334688073"><span><div id="7b0408cc91cc45e29d31172334688073" class="notion-header-anchor"></div><a class="notion-hash-link" href="#7b0408cc91cc45e29d31172334688073" title="2.新增的修改"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2.新增的修改</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-8467891809314874bbeffafbf583a9c9"><li>读取当前版本号。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-0d43f526dd9c4af190146845ff9937d8"><li>递增版本号。</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-f90255ee7ed54e1083af7c23b86ceac3"><li>更新并提交新的版本号。</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-50c0b18ec8334983bdff3c87435c64f6"><li>构建并推送带有版本号和<code class="notion-inline-code"><b>latest</b></code>标签的Docker镜像</li></ol><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-yaml">name: Docker Hub

on:
  push:
    branches: [dev]
  pull_request:
    branches: [dev]

env:
  REGISTRY: docker.io
  IMAGE_NAME: ${{ secrets.DOCKER_USERNAME }}/pandora-web

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      packages: write

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: Log into Docker Hub
        if: github.event_name != &#x27;pull_request&#x27;
        uses: docker/login-action@v1
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Get current version
        id: get_version
        run: echo &quot;CURRENT_VERSION=$(cat VERSION)&quot; &gt;&gt; $GITHUB_ENV

      - name: Increment version
        id: increment_version
        run: |
          VERSION_PARTS=(${CURRENT_VERSION//./ })
          NEW_PATCH=$((VERSION_PARTS[2]+1))
          NEW_VERSION=&quot;${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$NEW_PATCH&quot;
          echo &quot;NEW_VERSION=$NEW_VERSION&quot; &gt;&gt; $GITHUB_ENV
          echo $NEW_VERSION &gt; VERSION

      - name: Commit new version
        run: |
          git config --global user.name &#x27;github-actions&#x27;
          git config --global user.email &#x27;github-actions@github.com&#x27;
          git add VERSION
          git commit -m &quot;Increment version to ${{ env.NEW_VERSION }}&quot;
          git push

      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
          tags: |
            type=raw,value=${{ env.NEW_VERSION }}
            type=raw,value=latest
          labels: |
            type=raw,value=${{ env.NEW_VERSION }}
            type=raw,value=latest

      - name: Build and push Docker image
        uses: docker/build-push-action@v2
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: ${{ github.event_name != &#x27;pull_request&#x27; }}
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
</code></pre><div class="notion-blank notion-block-9a1d2a9465204905934eed981fba4c02"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[部署自用的GPT4]]></title>
            <link>https://notion.zyqn.site/article/chatgpt</link>
            <guid>https://notion.zyqn.site/article/chatgpt</guid>
            <pubDate>Mon, 06 May 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[pandoraweb是一个部署了GPT的项目，提供了两套UI供用户选择。该项目支持设置站点密码、隔离用户对话、老Pandora式的无密码直接访问等功能。此外，它还支持API对话自动保存、重定向3.5/4模型、携带历史对话等。用户可以单独指定模型的网络代理，]]></description>
            <content:encoded><![CDATA[<div id="container" class="mx-auto undefined"><main class="notion light-mode notion-page notion-block-f249db7241274750b39078d3484cafbe"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-02671211945b42e5997ee4e9250f39a8" data-id="02671211945b42e5997ee4e9250f39a8"><span><div id="02671211945b42e5997ee4e9250f39a8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#02671211945b42e5997ee4e9250f39a8" title="pandoraweb项目介绍"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><span class="notion-default"><b>pandoraweb项目介绍</b></span></span></span></h3><div class="notion-text notion-block-f9b7cc81df864b3db0e02e037a42fc21">今天我介绍一个部署GPT的项目<span class="notion-red"><b>pandoraweb</b></span></div><ul class="notion-list notion-list-disc notion-block-9dfbfdc9ace14ace8c446984e4491ca1"><li>两套UI任君选择，随意搭配</li></ul><ul class="notion-list notion-list-disc notion-block-d4d424dffe714a31883c55fafd9a26a0"><li>支持设置站点密码</li></ul><ul class="notion-list notion-list-disc notion-block-4327c85029354ac0b325908cf4892d0c"><li>支持隔离用户对话(隔离码长度不少于四位)</li></ul><ul class="notion-list notion-list-disc notion-block-1518b949045e4e0a9208b0118601d757"><li>支持老Pandora式的无密码直接访问(见后文配置说明)</li></ul><ul class="notion-list notion-list-disc notion-block-377d73fdba2847ebb2c41adc734d9f8e"><li>API对话自动保存</li></ul><ul class="notion-list notion-list-disc notion-block-135373c29f7542998447f5f83850b19f"><li>重定向3.5/4模型</li></ul><ul class="notion-list notion-list-disc notion-block-373a1f41521040459d35c8fdc85f8766"><li>携带历史对话(可单独对模型设定、可设置当历史消息数量大于设定数量时，自动携带第一组历史对话)</li></ul><ul class="notion-list notion-list-disc notion-block-c8eb3e3d2f8945ca9a495cb900ca1b7b"><li>模型<code class="notion-inline-code">Auth</code>轮询</li></ul><ul class="notion-list notion-list-disc notion-block-b60d92f3ccb14d06bc4a97223039dd20"><li>单独指定模型的网络代理</li></ul><ul class="notion-list notion-list-disc notion-block-9398a5465dfa41c59d78dd7e17a5be53"><li>设定内置Prompt</li></ul><ul class="notion-list notion-list-disc notion-block-57d01f8bc8c9430a9322fc17ae08fd41"><li>隐藏(假删除)对话(默认,可更改)</li></ul><ul class="notion-list notion-list-disc notion-block-d6ebb9ccf64a4979abae9eac261f90f8"><li>仅OAI(仅支持3.5模型)/API或二者共存运行</li></ul><ul class="notion-list notion-list-disc notion-block-2bc9e5538fb945229f1eddbc288cd432"><li>文生图模型可调用其他文本模型以生成/优化你的绘图Prompt</li></ul><ul class="notion-list notion-list-disc notion-block-b35d28d98c34424b97b64fd23155c97c"><li>对于某些以二进制文件(Blob对象)作为响应的文生图模型(比如Cloudflare AI)，自动保存并转为url输出(若使用了CDN服务，请注意<b>流量消耗</b>)</li></ul><ul class="notion-list notion-list-disc notion-block-11cd54b97ed14c66a71c090dd5990886"><li>文件上传(支持以Base64编码/Url携带(需公网)、支持类型/大小限制)</li></ul><ul class="notion-list notion-list-disc notion-block-818716065b634f89a00c2bc897e70f6c"><li>(3月24日)可以本地网络环境使用<code class="notion-inline-code">Access Token</code>进行3.5对话，详见后文<code class="notion-inline-code">更新日志0324</code>部分</li></ul><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-b962eacd15eb412c8ab760118e8d650f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fccc2507b-ee1c-4168-880a-941be01d0730%2F19188650-d1ba-4f68-99cf-b46204b442ec%2FUntitled.png?table=block&amp;id=b962eacd-15eb-412c-8ab7-60118e8d650f&amp;t=b962eacd-15eb-412c-8ab7-60118e8d650f" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-187d63d231c34974a797d34549903532" data-id="187d63d231c34974a797d34549903532"><span><div id="187d63d231c34974a797d34549903532" class="notion-header-anchor"></div><a class="notion-hash-link" href="#187d63d231c34974a797d34549903532" title="如何部署"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">如何部署</span></span></h3><div class="notion-text notion-block-b275e2783e674623a70c91b5bc8cd5aa">使用docker部署<span class="notion-blue">docker-compose.yml</span>文件</div><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-yaml">version: &#x27;3.8&#x27;
services:
  pandoraweb:
    image: ghcr.io/gavingoo/pandora-web:dev
    container_name: pandoraweb
    environment:
      - PANDORA_SERVER=0.0.0.0:8008
      - PANDORA_SITE_PASSWORD=5201314
      - PANDORA_HISTORY_COUNT=40
      - PANDORA_LOCAL_OPTION=True
#    - PANDORA_OAI_ONLY=True
      - PANDORA_FILE_ACCESS=True
      - PANDORA_GPT35_MODEL=gpt-3.5-turbo
      - PANDORA_GPT4_MODEL=gpt-4
      - TZ=Asia/Shanghai
    volumes:
      - ~/pandoraweb:/data
    ports:
      - &quot;8008:8008&quot;
    restart: unless-stopped</code></pre><div class="notion-text notion-block-5d00326fafc7436599b67c6431769e6d">上述的环境变量的配置直接看项目地方，<b>注：我设置的是只调用api模型，可以支持反代chatgpt,自行配置。</b></div><blockquote class="notion-quote notion-block-6070c82aea294fb9a88335dffa35b7fc"><div>ps:上述的<code class="notion-inline-code">PANDORA_GPT35_MODE</code>默认模型可以修改<code class="notion-inline-code">api.json</code>的任意模型，要和<code class="notion-inline-code">api.json</code>中的模型对应，这个模型加上后只能对话，不能上传文件，要可以上传文件的配置可以修改<code class="notion-inline-code">PANDORA_GPT4_MODEL</code>模型，这个模型可以上传模型，前提<code class="notion-inline-code">api</code>支持上传模型，其他多余的模型会在<code class="notion-inline-code">alpha models</code>上显示如下图所示</div></blockquote><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-ee8cc75e87b6458388e34d35ffc7d6f6"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fccc2507b-ee1c-4168-880a-941be01d0730%2F36ff5d62-c8d6-4eac-88d7-26d647bdec51%2FUntitled.png?table=block&amp;id=ee8cc75e-87b6-4583-88e3-4d35ffc7d6f6&amp;t=ee8cc75e-87b6-4583-88e3-4d35ffc7d6f6" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-79da14da3846455c8e04a8a562553c13">运行上述上述文件后在~/pandoraweb的目录下找到那个pandoraweb文件夹，在文件夹下添加配置api.json文件</div><pre class="notion-code"><div class="notion-code-copy"><div class="notion-code-copy-button"><svg fill="currentColor" viewBox="0 0 16 16" width="1em" version="1.1"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg></div></div><code class="language-json">{
    &quot;glm-4v&quot;: {
        &quot;slug&quot;: &quot;glm-4v&quot;,
        &quot;url&quot;: &quot;https://open.bigmodel.cn/api/paas/v4/chat/completions&quot;,
        &quot;auth&quot;: &quot;&lt;智谱AI Token&gt;&quot;,
        &quot;title&quot;: &quot;ChatGLM-4V&quot;,
        &quot;description&quot;: &quot;ChatGLM-4V&quot;,
        &quot;upload&quot;: true,
        &quot;file_base64&quot;: true,
        &quot;history_count&quot;: 10,
        &quot;max_tokens&quot;: 8191 
    },
    &quot;kimi&quot;: {
        &quot;slug&quot;: &quot;kimi&quot;,
        &quot;url&quot;: &quot;http://172.17.0.1:8000/v1/chat/completions&quot;,
        &quot;auth&quot;: &quot;&lt;Your Refresh Token&gt;&quot;,
        &quot;title&quot;: &quot;Kimi&quot;,
        &quot;description&quot;: &quot;Kimi&quot;,
        &quot;upload&quot;: true,
        &quot;max_tokens&quot;: 8191 
    },
    &quot;glm-4&quot;: {
        &quot;slug&quot;: &quot;glm-4&quot;,
        &quot;url&quot;: &quot;https://open.bigmodel.cn/api/paas/v4/chat/completions&quot;,
        &quot;auth&quot;: &quot;&lt;智谱AI Token&gt;&quot;,
        &quot;title&quot;: &quot;ChatGLM-4&quot;,
        &quot;description&quot;: &quot;ChatGLM-4&quot;,
        &quot;max_tokens&quot;: 8191 
    },
    &quot;gemini-pro&quot;: {
        &quot;slug&quot;: &quot;gemini-pro&quot;,
        &quot;url&quot;: &quot;https://generativelanguage.googleapis.com/v1/models/gemini-pro:streamGenerateContent?key=&lt;Your Google AI Key&gt;&quot;,
        &quot;title&quot;: &quot;Gemini-Pro&quot;,
        &quot;description&quot;: &quot;Gemini-Pro&quot;,
        &quot;max_tokens&quot;: 8191 
    },

    &quot;gpt-4&quot;: {
        &quot;slug&quot;: &quot;gpt-4&quot;,
        &quot;url&quot;: &quot;&lt;Your API Url&gt;&quot;,
        &quot;auth&quot;: [&quot;鸡&quot;, &quot;你&quot;, &quot;太&quot;, &quot;美&quot;],
        &quot;prompt&quot;: &quot;You use the GPT-4 version of OpenAI’s GPT models.Respond in the following locale: zh-cn.&quot;,
        &quot;title&quot;: &quot;GPT-4&quot;,
        &quot;description&quot;: &quot;GPT-4&quot;,
        &quot;max_tokens&quot;: 8191 
    }
}</code></pre><div class="notion-text notion-block-f8f3bf8e65b44ccb966d38bdc6fc4978">配置解释：</div><div class="notion-text notion-block-612e1c4381e6427f944c70b6267321bf"><code class="notion-inline-code">slug</code>: 请求时的模型名(请与键值保持一致)</div><div class="notion-text notion-block-dd331ce8106c450391c7b6f068cc463b"><code class="notion-inline-code">url</code>: 模型请求的url</div><div class="notion-text notion-block-d7f5d9d9031249348a3e9bbe9aab19c2"><code class="notion-inline-code">auth</code>: 模型请求的验证头(智谱家的与某模型会自动处理(<code class="notion-inline-code">slug</code>需包含关键词比如<code class="notion-inline-code">glm</code>)，直接填入你的Key即可)无则不写<code class="notion-inline-code">auth</code>这个键，比如Gemini。轮询请参照<code class="notion-inline-code">gpt-4</code>模型填写</div><div class="notion-text notion-block-c854d58191ea42ecabfe822f9530812c"><code class="notion-inline-code">proxy</code>: 指定该模型使用的网络代理(优先级最高)(如果使用Docker且网络模式非host,指向本机时请使用<code class="notion-inline-code">172.17.0.1</code>或内网IP)，可设置为<code class="notion-inline-code">&quot;&quot;</code>意味着该模型不走代理</div><div class="notion-text notion-block-f99b254e56064d3a985016e38a976d96"><code class="notion-inline-code">prompt</code>: 你的内置Prompt</div><div class="notion-text notion-block-ca87a67416eb429596798e7fc1c25e6b"><code class="notion-inline-code">title</code>: 前端页面上的模型显示名称</div><div class="notion-text notion-block-0d55b2161d274bc990f5004cec097c85"><code class="notion-inline-code">description</code>: 老Pandora页面上的模型描述</div><div class="notion-text notion-block-4ba267dcc56846a8806f2771f2c10c48"><code class="notion-inline-code">history_count</code>: 设置历史消息的数量，优先级最高</div><div class="notion-text notion-block-b49b1c3030434fbe921af6c88504d087"><code class="notion-inline-code">upload</code>: <code class="notion-inline-code">true</code> 启用文件上传，如需以Url携带请配置<code class="notion-inline-code">file_access</code>参数/<code class="notion-inline-code">PANDORA_FILE_ACCESS</code>环境变量为<code class="notion-inline-code">True</code></div><div class="notion-text notion-block-627ef985040649efb7262e5ba9a0c8ef"><code class="notion-inline-code">file_base64</code>: <code class="notion-inline-code">true</code> 文件以Base64编码</div><div class="notion-text notion-block-77adaaf0d910473e92a045e5c12a651d"><code class="notion-inline-code">max_tokens</code>: (不知道啥玩意，官方有我也就顺便带上了)</div><div class="notion-blank notion-block-86f7d13b9f134bfe834f87db71da4b80"> </div><div class="notion-blank notion-block-38741a1c4b7a44988b82d0f98d69c9f9"> </div><div class="notion-blank notion-block-3bc87b1156bf44f690460dd3a15f67c0"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[白嫖GPT4,只需普通号]]></title>
            <link>https://notion.zyqn.site/article/GPT4</link>
            <guid>https://notion.zyqn.site/article/GPT4</guid>
            <pubDate>Thu, 16 Nov 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[白嫖GPT4,只需普通号]]></description>
            <content:encoded><![CDATA[<div id="container" class="mx-auto undefined"><main class="notion light-mode notion-page notion-block-aa8c7b76d527461d872508313e1b739f"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-61749c76b390406bb3e674a247de7480">在人工智能的领域中，GPT-4（第四代生成预训练变换器）标志着一个重要的里程碑。作为OpenAI旗下最先进的语言模型之一，GPT-4不仅在规模上超越了其前身，更在理解复杂语言、回答查询、生成文本和执行多种语言任务方面展示了前所未有的能力。这个模型的核心是基于深度学习和大规模数据集的训练，它能够理解和生成与人类水平相媲美的语言内容。在这篇介绍中，我们将深入探讨GPT-4的架构、能力和在各个领域中的潜在应用</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-ca3571d9df404f788b47e2639938bf32" data-id="ca3571d9df404f788b47e2639938bf32"><span><div id="ca3571d9df404f788b47e2639938bf32" class="notion-header-anchor"></div><a class="notion-hash-link" href="#ca3571d9df404f788b47e2639938bf32" title="GPT4特点"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">GPT4特点</span></span></h3><div class="notion-text notion-block-c77eb40066bd45078052309259d4742e">GPT-4（Generative Pre-trained Transformer 4）是OpenAI开发的先进人工智能语言模型，它具有一系列显著的功能特点：</div><ol start="1" class="notion-list notion-list-numbered notion-block-f5d6f67360b64747869c99d4f82a6c91"><li><b>大规模多模态能力</b>：GPT-4不仅在文本处理方面表现出色，还能处理图像输入，提供更为丰富和多样化的交互方式。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-86d6a2b0e47e400a99fb45451c1ae38a"><li><b>深度学习和大数据训练</b>：GPT-4通过深度学习算法和大量数据集的训练，能够理解和生成复杂、高质量的文本内容。</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-7b6eb62978e24ed193f981b352ca8246"><li><b>高级理解和生成能力</b>：这个模型在理解上下文、生成连贯和有逻辑的文本方面表现卓越，能够在多种语言任务中展现出人类水平的性能。</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-49214a9cc5f24bfc8d2757cc8668a402"><li><b>跨领域适应性</b>：GPT-4能够应用于多种不同的领域，如写作辅助、编程帮助、艺术创作、教育、客户服务等。</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-5b144e319e7048e690d8e259478c2dbd"><li><b>更好的语境理解</b>：与前代模型相比，GPT-4在理解长篇文本和复杂语境方面有了显著提升。</li></ol><ol start="6" class="notion-list notion-list-numbered notion-block-c4420aca622248ae9cc83718caf42d80"><li><b>改进的安全性和减少偏见</b>：OpenAI在GPT-4中采用了更先进的技术和策略来减少生成偏见内容的风险，并提高了模型的整体安全性。</li></ol><ol start="7" class="notion-list notion-list-numbered notion-block-eda7c38c0eb3493a925c8b17315aa2c8"><li><b>可定制和可扩展性</b>：GPT-4提供了更多的定制选项，使开发者和企业能够根据特定需求定制和应用这个模型。</li></ol><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-b312e08d321b468b95cf2ae20a963e53" data-id="b312e08d321b468b95cf2ae20a963e53"><span><div id="b312e08d321b468b95cf2ae20a963e53" class="notion-header-anchor"></div><a class="notion-hash-link" href="#b312e08d321b468b95cf2ae20a963e53" title="下面是GPT3.5的界面"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">下面是GPT3.5的界面</span></span></h4><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-e59237bc1ff84a4584cefc36f3cc0862"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fccc2507b-ee1c-4168-880a-941be01d0730%2F9d07ff65-2674-4062-a733-d867e3e98274%2FUntitled.png?table=block&amp;id=e59237bc-1ff8-4a45-84ce-fc36f3cc0862&amp;t=e59237bc-1ff8-4a45-84ce-fc36f3cc0862" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-e3668d7e29ae4857a773aae81ee7b479" data-id="e3668d7e29ae4857a773aae81ee7b479"><span><div id="e3668d7e29ae4857a773aae81ee7b479" class="notion-header-anchor"></div><a class="notion-hash-link" href="#e3668d7e29ae4857a773aae81ee7b479" title="白嫖GPT4方法"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">白嫖GPT4方法</span></span></h3><div class="notion-text notion-block-a1199916615748b8ba45d3ec25d663ce">登陆chat 访问这个地址就能用gpt4 官方出bug了</div><div class="notion-text notion-block-f527bee917fc4087a1423a017c5329a3"> <a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://chat.openai.com/?model=gpt-4-gizmo">https://chat.openai.com/?model=gpt-4-gizmo</a></div><div class="notion-text notion-block-897363ba5ab14f42b063926f6913872a">就会有GPT4</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-196bdc65504d43b3a11d05e8c29d4368"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fccc2507b-ee1c-4168-880a-941be01d0730%2Fa7bb4208-e02c-4a87-9819-cc7b53b0eff1%2FUntitled.png?table=block&amp;id=196bdc65-504d-43b3-a11d-05e8c29d4368&amp;t=196bdc65-504d-43b3-a11d-05e8c29d4368" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-0416f2d281a24651900f9f7bd999f94b">有这个就是GPT4</div><div class="notion-text notion-block-fdbb3acabddf490dab6c4616e2b43fc1">大家赶紧，过后估计没有了😁</div></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>