diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
new file mode 100644
index 0000000000000000000000000000000000000000..39fdd7b044dd26e16e3726aa7dab2aea7de0fc08
--- /dev/null
+++ b/.github/CONTRIBUTING.md
@@ -0,0 +1,49 @@
+# 如何做出贡献
+
+感谢您对 **川虎Chat** 的关注!感谢您投入时间为我们的项目做出贡献!
+
+在开始之前,您可以阅读我们的以下简短提示。更多信息您可以点击链接查阅。
+
+## GitHub 新手?
+
+以下是 GitHub 的一些资源,如果您是GitHub新手,它们可帮助您开始为开源项目做贡献:
+
+- [GitHub上为开源做出贡献的方法](https://docs.github.com/en/get-started/exploring-projects-on-github/finding-ways-to-contribute-to-open-source-on-github)
+- [设置Git](https://docs.github.com/en/get-started/quickstart/set-up-git)
+- [GitHub工作流](https://docs.github.com/en/get-started/quickstart/github-flow)
+- [使用拉取请求](https://docs.github.com/en/github/collaborating-with-pull-requests)
+
+## 提交 Issues
+
+是的!提交ISSUE其实是您为项目做出贡献的一种方式!但需要您提出合理的ISSUE才是对项目有帮助的。
+
+我们的[常见问题](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/常见问题)中描述了您应当怎样提出一个不重复的ISSUE,以及什么情况应当提ISSUE,什么情况应当在讨论区发问。
+
+**请注意,ISSUE不是项目的评论区。**
+
+> **Note**
+>
+> 另外,请注意“问题”一词表示“question”和“problem”的区别。
+> 如果您需要报告项目本身实际的技术问题、故障或错误(problem),那么欢迎提交一个新的 issue。但是,如果您只是碰到了一些自己无法解决的问题需要向其他用户或我们提问(question),那么最好的选择是在讨论区中发布一个新的帖子。 如果您不确定,请首先考虑在讨论区提问。
+>
+> 目前,我们默认了您发在 issue 中的问题是一个 question,但我们希望避免再在 issue 中见到类似“我该怎么操作?”的提问QAQ。
+
+## 提交 Pull Request
+
+如果您具备一定能力,您可以修改本项目的源代码,并提交一个 pull request!合并之后,您的名字将会出现在 CONTRIBUTORS 中~
+
+我们的[贡献指南](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/贡献指南)详细地写出了您每一步应当做什么~ 如果您希望提交源代码的更改,快去看看吧~
+
+> **Note**
+>
+> 我们不会强制要求您符合我们的规范,但希望您可以减轻我们的工作。
+
+## 参与讨论
+
+讨论区是我们进行对话的地方。
+
+如果您想帮助有一个很棒的新想法,或者想分享您的使用技巧,请加入我们的讨论(Discussion)!同时,许多用户会在讨论区提出他们的疑问,如果您能为他们提供解答,我们也将无比感激!
+
+-----
+
+再次感谢您看到这里!感谢您为我们项目做出的贡献!
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 0000000000000000000000000000000000000000..aaab20991e70a51c2f200dc50da78d0873511964
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,5 @@
+blank_issues_enabled:
+contact_links:
+ - name: 讨论区
+ url: https://github.com/GaiZhenbiao/ChuanhuChatGPT/discussions
+ about: 如果遇到疑问,请优先前往讨论区提问~
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml
new file mode 100644
index 0000000000000000000000000000000000000000..083ac2aa80fa578e9375121e8a0fe3de00d28bb8
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature-request.yml
@@ -0,0 +1,35 @@
+name: 功能请求
+description: "请求更多功能!"
+title: "[功能请求]: "
+labels: ["feature request"]
+body:
+ - type: markdown
+ attributes:
+ value: 您可以请求更多功能!麻烦您花些时间填写以下信息~
+ - type: textarea
+ attributes:
+ label: 相关问题
+ description: 该功能请求是否与某个问题相关?
+ placeholder: 发送信息后有概率ChatGPT返回error,刷新后又要重新打一遍文字,较为麻烦
+ validations:
+ required: false
+ - type: textarea
+ attributes:
+ label: 可能的解决办法
+ description: 如果可以,给出一个解决思路~ 或者,你希望实现什么功能?
+ placeholder: 发送失败后在输入框或聊天气泡保留发送的文本
+ validations:
+ required: true
+ - type: checkboxes
+ attributes:
+ label: 帮助开发
+ description: 如果您能帮助开发并提交一个pull request,那再好不过了!
+ 参考:[贡献指南](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/贡献指南)
+ options:
+ - label: 我愿意协助开发!
+ required: false
+ - type: textarea
+ attributes:
+ label: 补充说明
+ description: |
+ 链接?参考资料?任何更多背景信息!
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/report-bug.yml b/.github/ISSUE_TEMPLATE/report-bug.yml
new file mode 100644
index 0000000000000000000000000000000000000000..c98a9f75108ce3ca183781b787ab52434ab1161b
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/report-bug.yml
@@ -0,0 +1,75 @@
+name: 报告BUG
+description: "报告一个bug,且您确信这是bug而不是您的问题"
+title: "[Bug]: "
+labels: ["bug"]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ 感谢提交 issue! 请尽可能完整填写以下信息,帮助我们更好地定位问题~
+ **在一切开始之前,请确保您已经阅读过 [常见问题](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/常见问题) 页面**。
+ 如果您确信这是一个我们的 bug,而不是因为您的原因部署失败,欢迎提交该issue!
+ 如果您不能确定这是bug还是您的问题,请选择 [其他类型的issue模板](https://github.com/GaiZhenbiao/ChuanhuChatGPT/issues/new/choose)。
+
+ ------
+ - type: checkboxes
+ attributes:
+ label: 这个bug是否已存在现有issue了?
+ description: 请搜索全部issue和[常见问题](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/常见问题)以查看您想报告的issue是否已存在。
+ options:
+ - label: 我确认没有已有issue,且已阅读**常见问题**。
+ required: true
+ - type: textarea
+ id: what-happened
+ attributes:
+ label: 错误表现
+ description: 请描述您遇到的bug。
+ 提示:如果可以,也请提供错误的截图,如本地部署的网页截图与终端错误报告的截图。
+ 如果可以,也请提供`.json`格式的对话记录。
+ placeholder: 发生什么事了?
+ validations:
+ required: true
+ - type: textarea
+ attributes:
+ label: 复现操作
+ description: 你之前干了什么,然后出现了bug呢?
+ placeholder: |
+ 1. 正常完成本地部署
+ 2. 在对话框中要求 ChatGPT “以LaTeX格式输出三角函数”
+ 3. ChatGPT 输出部分内容后程序被自动终止
+ validations:
+ required: true
+ - type: textarea
+ id: logs
+ attributes:
+ label: 错误日志
+ description: 请将终端中的主要错误报告粘贴至此处。
+ render: shell
+ - type: textarea
+ attributes:
+ label: 运行环境
+ description: |
+ 网页底部会列出您运行环境的版本信息,请务必填写。以下是一个例子:
+ - **OS**: Windows11 22H2
+ - **Browser**: Chrome
+ - **Gradio version**: 3.22.1
+ - **Python version**: 3.11.1
+ value: |
+ - OS:
+ - Browser:
+ - Gradio version:
+ - Python version:
+ validations:
+ required: false
+ - type: checkboxes
+ attributes:
+ label: 帮助解决
+ description: 如果您能够并愿意协助解决该问题,向我们提交一个pull request,那再好不过了!
+ 参考:[贡献指南](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/贡献指南)
+ options:
+ - label: 我愿意协助解决!
+ required: false
+ - type: textarea
+ attributes:
+ label: 补充说明
+ description: 链接?参考资料?任何更多背景信息!
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/report-docker.yml b/.github/ISSUE_TEMPLATE/report-docker.yml
new file mode 100644
index 0000000000000000000000000000000000000000..e62b34a50dcaec9fb8609257f0eb421296e18fc7
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/report-docker.yml
@@ -0,0 +1,73 @@
+name: Docker部署错误
+description: "报告使用 Docker 部署时的问题或错误"
+title: "[Docker]: "
+labels: ["question","docker deployment"]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ 感谢提交 issue! 请尽可能完整填写以下信息,帮助我们更好地定位问题~
+ **在一切开始之前,请确保您已经阅读过 [常见问题](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/常见问题) 页面**,查看它是否已经对您的问题做出了解答。
+ 如果没有,请检索 [issue](https://github.com/GaiZhenbiao/ChuanhuChatGPT/issues) 与 [discussion](https://github.com/GaiZhenbiao/ChuanhuChatGPT/discussions) ,查看有没有相同或类似的问题。
+
+ ------
+ - type: checkboxes
+ attributes:
+ label: 是否已存在现有反馈与解答?
+ description: 请搜索issue、discussion和[常见问题](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/常见问题)以查看您想报告的issue是否已存在。
+ options:
+ - label: 我确认没有已有issue或discussion,且已阅读**常见问题**。
+ required: true
+ - type: checkboxes
+ attributes:
+ label: 是否是一个代理配置相关的疑问?
+ description: 请不要提交代理配置相关的issue。如有疑问请前往 [讨论区](https://github.com/GaiZhenbiao/ChuanhuChatGPT/discussions)。
+ options:
+ - label: 我确认这不是一个代理配置相关的疑问。
+ required: true
+ - type: textarea
+ id: what-happened
+ attributes:
+ label: 错误描述
+ description: 请描述您遇到的错误或问题。
+ 提示:如果可以,也请提供错误的截图,如本地部署的网页截图与终端错误报告的截图。
+ 如果可以,也请提供`.json`格式的对话记录。
+ placeholder: 发生什么事了?
+ validations:
+ required: true
+ - type: textarea
+ attributes:
+ label: 复现操作
+ description: 你之前干了什么,然后出现了错误呢?
+ placeholder: |
+ 1. 正常完成本地部署
+ 2. 在对话框中要求 ChatGPT “以LaTeX格式输出三角函数”
+ 3. ChatGPT 输出部分内容后程序被自动终止
+ validations:
+ required: true
+ - type: textarea
+ id: logs
+ attributes:
+ label: 错误日志
+ description: 请将终端中的主要错误报告粘贴至此处。
+ render: shell
+ - type: textarea
+ attributes:
+ label: 运行环境
+ description: |
+ 网页底部会列出您运行环境的版本信息,请务必填写。以下是一个例子:
+ - **OS**: Linux/amd64
+ - **Docker version**: 1.8.2
+ - **Gradio version**: 3.22.1
+ - **Python version**: 3.11.1
+ value: |
+ - OS:
+ - Docker version:
+ - Gradio version:
+ - Python version:
+ validations:
+ required: false
+ - type: textarea
+ attributes:
+ label: 补充说明
+ description: 链接?参考资料?任何更多背景信息!
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/report-localhost.yml b/.github/ISSUE_TEMPLATE/report-localhost.yml
new file mode 100644
index 0000000000000000000000000000000000000000..ebd0baf43bc80bb5883a7441f14887d8410b9f51
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/report-localhost.yml
@@ -0,0 +1,76 @@
+name: 本地部署错误
+description: "报告本地部署时的问题或错误(小白首选)"
+title: "[本地部署]: "
+labels: ["question","localhost deployment"]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ 感谢提交 issue! 请尽可能完整填写以下信息,帮助我们更好地定位问题~
+ **在一切开始之前,请确保您已经阅读过 [常见问题](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/常见问题) 页面**,查看它是否已经对您的问题做出了解答。
+ 如果没有,请检索 [issue](https://github.com/GaiZhenbiao/ChuanhuChatGPT/issues) 与 [discussion](https://github.com/GaiZhenbiao/ChuanhuChatGPT/discussions) ,查看有没有相同或类似的问题。
+
+ **另外,请不要再提交 `Something went wrong Expecting value: line 1 column 1 (char 0)` 和 代理配置 相关的问题,请再看一遍 [常见问题](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/常见问题) 页,实在不行请前往 discussion。**
+
+ ------
+ - type: checkboxes
+ attributes:
+ label: 是否已存在现有反馈与解答?
+ description: 请搜索issue、discussion和[常见问题](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/常见问题)以查看您想报告的issue是否已存在。
+ options:
+ - label: 我确认没有已有issue或discussion,且已阅读**常见问题**。
+ required: true
+ - type: checkboxes
+ attributes:
+ label: 是否是一个代理配置相关的疑问?
+ description: 请不要提交代理配置相关的issue。如有疑问请前往 [讨论区](https://github.com/GaiZhenbiao/ChuanhuChatGPT/discussions)。
+ options:
+ - label: 我确认这不是一个代理配置相关的疑问。
+ required: true
+ - type: textarea
+ id: what-happened
+ attributes:
+ label: 错误描述
+ description: 请描述您遇到的错误或问题。
+ 提示:如果可以,也请提供错误的截图,如本地部署的网页截图与终端错误报告的截图。
+ 如果可以,也请提供`.json`格式的对话记录。
+ placeholder: 发生什么事了?
+ validations:
+ required: true
+ - type: textarea
+ attributes:
+ label: 复现操作
+ description: 你之前干了什么,然后出现了错误呢?
+ placeholder: |
+ 1. 正常完成本地部署
+ 2. 在对话框中要求 ChatGPT “以LaTeX格式输出三角函数”
+ 3. ChatGPT 输出部分内容后程序被自动终止
+ validations:
+ required: true
+ - type: textarea
+ id: logs
+ attributes:
+ label: 错误日志
+ description: 请将终端中的主要错误报告粘贴至此处。
+ render: shell
+ - type: textarea
+ attributes:
+ label: 运行环境
+ description: |
+ 网页底部会列出您运行环境的版本信息,请务必填写。以下是一个例子:
+ - **OS**: Windows11 22H2
+ - **Browser**: Chrome
+ - **Gradio version**: 3.22.1
+ - **Python version**: 3.11.1
+ value: |
+ - OS:
+ - Browser:
+ - Gradio version:
+ - Python version:
+ render: markdown
+ validations:
+ required: false
+ - type: textarea
+ attributes:
+ label: 补充说明
+ description: 链接?参考资料?任何更多背景信息!
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/report-others.yml b/.github/ISSUE_TEMPLATE/report-others.yml
new file mode 100644
index 0000000000000000000000000000000000000000..0bc1f583a368615ab57c28c4a02ec4dbac55d67f
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/report-others.yml
@@ -0,0 +1,67 @@
+name: 其他错误
+description: "报告其他问题(如 Hugging Face 中的 Space 等)"
+title: "[其他]: "
+labels: ["question"]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ 感谢提交 issue! 请尽可能完整填写以下信息,帮助我们更好地定位问题~
+ **在一切开始之前,请确保您已经阅读过 [常见问题](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/常见问题) 页面**,查看它是否已经对您的问题做出了解答。
+ 如果没有,请检索 [issue](https://github.com/GaiZhenbiao/ChuanhuChatGPT/issues) 与 [discussion](https://github.com/GaiZhenbiao/ChuanhuChatGPT/discussions) ,查看有没有相同或类似的问题。
+
+ ------
+ - type: checkboxes
+ attributes:
+ label: 是否已存在现有反馈与解答?
+ description: 请搜索issue、discussion和[常见问题](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/常见问题)以查看您想报告的issue是否已存在。
+ options:
+ - label: 我确认没有已有issue或discussion,且已阅读**常见问题**。
+ required: true
+ - type: textarea
+ id: what-happened
+ attributes:
+ label: 错误描述
+ description: 请描述您遇到的错误或问题。
+ 提示:如果可以,也请提供错误的截图,如本地部署的网页截图与终端错误报告的截图。
+ 如果可以,也请提供`.json`格式的对话记录。
+ placeholder: 发生什么事了?
+ validations:
+ required: true
+ - type: textarea
+ attributes:
+ label: 复现操作
+ description: 你之前干了什么,然后出现了错误呢?
+ placeholder: |
+ 1. 正常完成本地部署
+ 2. 在对话框中要求 ChatGPT “以LaTeX格式输出三角函数”
+ 3. ChatGPT 输出部分内容后程序被自动终止
+ validations:
+ required: true
+ - type: textarea
+ id: logs
+ attributes:
+ label: 错误日志
+ description: 请将终端中的主要错误报告粘贴至此处。
+ render: shell
+ - type: textarea
+ attributes:
+ label: 运行环境
+ description: |
+ 网页底部会列出您运行环境的版本信息,请务必填写。以下是一个例子:
+ - **OS**: Windows11 22H2
+ - **Browser**: Chrome
+ - **Gradio version**: 3.22.1
+ - **Python version**: 3.11.1
+ value: |
+ - OS:
+ - Browser:
+ - Gradio version:
+ - Python version:
+ (或您的其他运行环境信息)
+ validations:
+ required: false
+ - type: textarea
+ attributes:
+ label: 补充说明
+ description: 链接?参考资料?任何更多背景信息!
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/report-server.yml b/.github/ISSUE_TEMPLATE/report-server.yml
new file mode 100644
index 0000000000000000000000000000000000000000..26080429bf62acf922bb27f8ff751c675bb775a9
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/report-server.yml
@@ -0,0 +1,73 @@
+name: 服务器部署错误
+description: "报告在远程服务器上部署时的问题或错误"
+title: "[远程部署]: "
+labels: ["question","server deployment"]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ 感谢提交 issue! 请尽可能完整填写以下信息,帮助我们更好地定位问题~
+ **在一切开始之前,请确保您已经阅读过 [常见问题](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/常见问题) 页面**,查看它是否已经对您的问题做出了解答。
+ 如果没有,请检索 [issue](https://github.com/GaiZhenbiao/ChuanhuChatGPT/issues) 与 [discussion](https://github.com/GaiZhenbiao/ChuanhuChatGPT/discussions) ,查看有没有相同或类似的问题。
+
+ ------
+ - type: checkboxes
+ attributes:
+ label: 是否已存在现有反馈与解答?
+ description: 请搜索issue、discussion和[常见问题](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/常见问题)以查看您想报告的issue是否已存在。
+ options:
+ - label: 我确认没有已有issue或discussion,且已阅读**常见问题**。
+ required: true
+ - type: checkboxes
+ attributes:
+ label: 是否是一个代理配置相关的疑问?
+ description: 请不要提交代理配置相关的issue。如有疑问请前往 [讨论区](https://github.com/GaiZhenbiao/ChuanhuChatGPT/discussions)。
+ options:
+ - label: 我确认这不是一个代理配置相关的疑问。
+ required: true
+ - type: textarea
+ id: what-happened
+ attributes:
+ label: 错误描述
+ description: 请描述您遇到的错误或问题。
+ 提示:如果可以,也请提供错误的截图,如本地部署的网页截图与终端错误报告的截图。
+ 如果可以,也请提供`.json`格式的对话记录。
+ placeholder: 发生什么事了?
+ validations:
+ required: true
+ - type: textarea
+ attributes:
+ label: 复现操作
+ description: 你之前干了什么,然后出现了错误呢?
+ placeholder: |
+ 1. 正常完成本地部署
+ 2. 在对话框中要求 ChatGPT “以LaTeX格式输出三角函数”
+ 3. ChatGPT 输出部分内容后程序被自动终止
+ validations:
+ required: true
+ - type: textarea
+ id: logs
+ attributes:
+ label: 错误日志
+ description: 请将终端中的主要错误报告粘贴至此处。
+ render: shell
+ - type: textarea
+ attributes:
+ label: 运行环境
+ description: |
+ 网页底部会列出您运行环境的版本信息,请务必填写。以下是一个例子:
+ - **OS**: Windows11 22H2
+ - **Docker version**: 1.8.2
+ - **Gradio version**: 3.22.1
+ - **Python version**: 3.11.1
+ value: |
+ - OS:
+ - Server:
+ - Gradio version:
+ - Python version:
+ validations:
+ required: false
+ - type: textarea
+ attributes:
+ label: 补充说明
+ description: 链接?参考资料?任何更多背景信息!
\ No newline at end of file
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
new file mode 100644
index 0000000000000000000000000000000000000000..e36644fe4edf77082f9aa771ff773af519349a40
--- /dev/null
+++ b/.github/pull_request_template.md
@@ -0,0 +1,37 @@
+
+
+## 作者自述
+### 描述
+描述您的 pull request 所做的更改。
+另外请附上相关程序运行时的截图(before & after),以直观地展现您的更改达成的效果。
+
+### 相关问题
+(如有)请列出与此拉取请求相关的issue。
+
+### 补充信息
+(如有)请提供任何其他信息或说明,有助于其他贡献者理解您的更改。
+如果您提交的是 draft pull request,也请在这里写明开发进度。
+
+
+
+
+
+## Copilot4PR
+copilot:all
\ No newline at end of file
diff --git a/.github/workflows/Build_Docker.yml b/.github/workflows/Build_Docker.yml
new file mode 100644
index 0000000000000000000000000000000000000000..caa2fb3e95a36d8ec870ca78b1a72b45964f6773
--- /dev/null
+++ b/.github/workflows/Build_Docker.yml
@@ -0,0 +1,51 @@
+name: Build Docker when Push
+
+on:
+ push:
+ branches:
+ - "main"
+
+jobs:
+ docker:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Set commit SHA
+ run: echo "COMMIT_SHA=$(echo ${{ github.sha }} | cut -c 1-7)" >> ${GITHUB_ENV}
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v2
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Login to GitHub Container Registry
+ uses: docker/login-action@v2
+ with:
+ registry: ghcr.io
+ username: ${{ github.repository_owner }}
+ password: ${{ secrets.MY_TOKEN }}
+
+ - name: Owner names
+ run: |
+ GITOWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
+ echo "GITOWNER=$GITOWNER" >> ${GITHUB_ENV}
+
+ - name: Build and export
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ platforms: linux/amd64,linux/arm64
+ push: false
+ tags: |
+ ghcr.io/${{ env.GITOWNER }}/chuanhuchatgpt:latest
+ ghcr.io/${{ env.GITOWNER }}/chuanhuchatgpt:${{ github.sha }}
+ outputs: type=oci,dest=/tmp/myimage-${{ env.COMMIT_SHA }}.tar
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v3
+ with:
+ name: chuanhuchatgpt-${{ env.COMMIT_SHA }}
+ path: /tmp/myimage-${{ env.COMMIT_SHA }}.tar
diff --git a/.github/workflows/Release_docker.yml b/.github/workflows/Release_docker.yml
new file mode 100644
index 0000000000000000000000000000000000000000..e07623e819e936c0deab27b70c695b46be4f32ac
--- /dev/null
+++ b/.github/workflows/Release_docker.yml
@@ -0,0 +1,55 @@
+name: Build and Push Docker when Release
+
+on:
+ release:
+ types: [published]
+ workflow_dispatch:
+
+jobs:
+ docker:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ with:
+ ref: ${{ github.event.release.target_commitish }}
+
+ - name: Set release tag
+ run: |
+ echo "RELEASE_TAG=${{ github.event.release.tag_name }}" >> ${GITHUB_ENV}
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v2
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+
+ - name: Login to Docker Hub
+ uses: docker/login-action@v2
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Login to GitHub Container Registry
+ uses: docker/login-action@v2
+ with:
+ registry: ghcr.io
+ username: ${{ github.repository_owner }}
+ password: ${{ secrets.MY_TOKEN }}
+
+ - name: Owner names
+ run: |
+ GITOWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')
+ echo "GITOWNER=$GITOWNER" >> ${GITHUB_ENV}
+
+ - name: Build and push
+ uses: docker/build-push-action@v4
+ with:
+ context: .
+ platforms: linux/amd64,linux/arm64
+ push: true
+ tags: |
+ ghcr.io/${{ env.GITOWNER }}/chuanhuchatgpt:latest
+ ghcr.io/${{ env.GITOWNER }}/chuanhuchatgpt:${{ env.RELEASE_TAG }}
+ ${{ secrets.DOCKERHUB_USERNAME }}/chuanhuchatgpt:latest
+ ${{ secrets.DOCKERHUB_USERNAME }}/chuanhuchatgpt:${{ env.RELEASE_TAG }}
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..3152ffd829b2cb9cf321a1ace2fde4f932c17a08
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,157 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+pip-wheel-metadata/
+share/python-wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+history/
+index/
+
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+nohup.out
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+*.py,cover
+.hypothesis/
+.pytest_cache/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+db.sqlite3-journal
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# IPython
+profile_default/
+ipython_config.py
+
+# pyenv
+.python-version
+
+# pipenv
+# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
+# However, in case of collaboration, if having platform-specific dependencies or dependencies
+# having no cross-platform support, pipenv may install dependencies that don't work, or not
+# install all needed dependencies.
+#Pipfile.lock
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+__pypackages__/
+
+# Celery stuff
+celerybeat-schedule
+celerybeat.pid
+
+# SageMath parsed files
+*.sage.py
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.dmypy.json
+dmypy.json
+
+# Pyre type checker
+.pyre/
+
+# Mac system file
+**/.DS_Store
+
+#vscode
+.vscode
+.vs
+
+# 配置文件/模型文件
+api_key.txt
+config.json
+auth.json
+.models/
+models/*
+lora/
+.idea
+templates/*
+files/
+tmp/
+
+scripts/
+include/
+pyvenv.cfg
+
+create_release.sh
diff --git a/CITATION.cff b/CITATION.cff
new file mode 100644
index 0000000000000000000000000000000000000000..ea3e1503a4aff8e954bb36b1bba6370f81f239f6
--- /dev/null
+++ b/CITATION.cff
@@ -0,0 +1,20 @@
+cff-version: 1.2.0
+title: Chuanhu Chat
+message: >-
+ If you use this software, please cite it using these
+ metadata.
+type: software
+authors:
+ - given-names: Chuanhu
+ orcid: https://orcid.org/0000-0001-8954-8598
+ - given-names: MZhao
+ orcid: https://orcid.org/0000-0003-2298-6213
+ - given-names: Keldos
+ orcid: https://orcid.org/0009-0005-0357-272X
+repository-code: 'https://github.com/GaiZhenbiao/ChuanhuChatGPT'
+url: 'https://github.com/GaiZhenbiao/ChuanhuChatGPT'
+abstract: This software provides a light and easy-to-use interface for ChatGPT API and many LLMs.
+license: GPL-3.0
+commit: c6c08bc62ef80e37c8be52f65f9b6051a7eea1fa
+version: '20230709'
+date-released: '2023-07-09'
diff --git a/ChuanhuChatbot.py b/ChuanhuChatbot.py
new file mode 100644
index 0000000000000000000000000000000000000000..d7abed8442f0ce8b37537b47de6c1ebfac4b3e64
--- /dev/null
+++ b/ChuanhuChatbot.py
@@ -0,0 +1,807 @@
+# -*- coding:utf-8 -*-
+import logging
+logging.basicConfig(
+ level=logging.INFO,
+ format="%(asctime)s [%(levelname)s] [%(filename)s:%(lineno)d] %(message)s",
+)
+
+from modules.models.models import get_model
+from modules.train_func import *
+from modules.repo import *
+from modules.webui import *
+from modules.overwrites import *
+from modules.presets import *
+from modules.utils import *
+from modules.config import *
+from modules import config
+import gradio as gr
+import colorama
+
+
+logging.getLogger("httpx").setLevel(logging.WARNING)
+
+gr.Chatbot._postprocess_chat_messages = postprocess_chat_messages
+gr.Chatbot.postprocess = postprocess
+
+# with open("web_assets/css/ChuanhuChat.css", "r", encoding="utf-8") as f:
+# ChuanhuChatCSS = f.read()
+
+
+def create_new_model():
+ return get_model(model_name=MODELS[DEFAULT_MODEL], access_key=my_api_key)[0]
+
+
+with gr.Blocks(theme=small_and_beautiful_theme) as demo:
+ user_name = gr.Textbox("", visible=False)
+ promptTemplates = gr.State(load_template(get_template_names()[0], mode=2))
+ user_question = gr.State("")
+ assert type(my_api_key) == str
+ user_api_key = gr.State(my_api_key)
+ current_model = gr.State()
+
+ topic = gr.State(i18n("未命名对话历史记录"))
+
+ with gr.Row(elem_id="chuanhu-header"):
+ gr.HTML(get_html("header_title.html").format(
+ app_title=CHUANHU_TITLE), elem_id="app-title")
+ status_display = gr.Markdown(get_geoip, elem_id="status-display")
+ with gr.Row(elem_id="float-display"):
+ user_info = gr.Markdown(
+ value="getting user info...", elem_id="user-info")
+ update_info = gr.HTML(get_html("update.html").format(
+ current_version=repo_tag_html(),
+ version_time=version_time(),
+ cancel_btn=i18n("取消"),
+ update_btn=i18n("更新"),
+ seenew_btn=i18n("详情"),
+ ok_btn=i18n("好"),
+ ), visible=check_update)
+
+ with gr.Row(equal_height=True, elem_id="chuanhu-body"):
+
+ with gr.Column(elem_id="menu-area"):
+ with gr.Column(elem_id="chuanhu-history"):
+ with gr.Box():
+ with gr.Row(elem_id="chuanhu-history-header"):
+ with gr.Row(elem_id="chuanhu-history-search-row"):
+ with gr.Column(min_width=150, scale=2):
+ historySearchTextbox = gr.Textbox(show_label=False, container=False, placeholder=i18n(
+ "搜索(支持正则)..."), lines=1, elem_id="history-search-tb")
+ with gr.Column(min_width=52, scale=1, elem_id="gr-history-header-btns"):
+ uploadFileBtn = gr.UploadButton(
+ interactive=True, label="", file_types=[".json"], elem_id="gr-history-upload-btn")
+ historyRefreshBtn = gr.Button("", elem_id="gr-history-refresh-btn")
+
+
+ with gr.Row(elem_id="chuanhu-history-body"):
+ with gr.Column(scale=6, elem_id="history-select-wrap"):
+ historySelectList = gr.Radio(
+ label=i18n("从列表中加载对话"),
+ choices=get_history_names(),
+ value=get_first_history_name(),
+ # multiselect=False,
+ container=False,
+ elem_id="history-select-dropdown"
+ )
+ with gr.Row(visible=False):
+ with gr.Column(min_width=42, scale=1):
+ historyDeleteBtn = gr.Button(
+ "🗑️", elem_id="gr-history-delete-btn")
+ with gr.Column(min_width=42, scale=1):
+ historyDownloadBtn = gr.Button(
+ "⏬", elem_id="gr-history-download-btn")
+ with gr.Column(min_width=42, scale=1):
+ historyMarkdownDownloadBtn = gr.Button(
+ "⤵️", elem_id="gr-history-mardown-download-btn")
+ with gr.Row(visible=False):
+ with gr.Column(scale=6):
+ saveFileName = gr.Textbox(
+ show_label=True,
+ placeholder=i18n("设置文件名: 默认为.json,可选为.md"),
+ label=i18n("设置保存文件名"),
+ value=i18n("对话历史记录"),
+ elem_classes="no-container"
+ # container=False,
+ )
+ with gr.Column(scale=1):
+ renameHistoryBtn = gr.Button(
+ i18n("💾 保存对话"), elem_id="gr-history-save-btn")
+ exportMarkdownBtn = gr.Button(
+ i18n("📝 导出为 Markdown"), elem_id="gr-markdown-export-btn")
+
+ with gr.Column(elem_id="chuanhu-menu-footer"):
+ with gr.Row(elem_id="chuanhu-func-nav"):
+ gr.HTML(get_html("func_nav.html"))
+ # gr.HTML(get_html("footer.html").format(versions=versions_html()), elem_id="footer")
+ # gr.Markdown(CHUANHU_DESCRIPTION, elem_id="chuanhu-author")
+
+ with gr.Column(elem_id="chuanhu-area", scale=5):
+ with gr.Column(elem_id="chatbot-area"):
+ with gr.Row(elem_id="chatbot-header"):
+ model_select_dropdown = gr.Dropdown(
+ label=i18n("选择模型"), choices=MODELS, multiselect=False, value=MODELS[DEFAULT_MODEL], interactive=True,
+ show_label=False, container=False, elem_id="model-select-dropdown"
+ )
+ lora_select_dropdown = gr.Dropdown(
+ label=i18n("选择LoRA模型"), choices=[], multiselect=False, interactive=True, visible=False,
+ container=False,
+ )
+ gr.HTML(get_html("chatbot_header_btn.html").format(
+ json_label=i18n("历史记录(JSON)"),
+ md_label=i18n("导出为 Markdown")
+ ), elem_id="chatbot-header-btn-bar")
+ with gr.Row():
+ chatbot = gr.Chatbot(
+ label="Chuanhu Chat",
+ elem_id="chuanhu-chatbot",
+ latex_delimiters=latex_delimiters_set,
+ sanitize_html=False,
+ # height=700,
+ show_label=False,
+ avatar_images=[config.user_avatar, config.bot_avatar],
+ show_share_button=False,
+ )
+ with gr.Row(elem_id="chatbot-footer"):
+ with gr.Box(elem_id="chatbot-input-box"):
+ with gr.Row(elem_id="chatbot-input-row"):
+ gr.HTML(get_html("chatbot_more.html").format(
+ single_turn_label=i18n("单轮对话"),
+ websearch_label=i18n("在线搜索"),
+ upload_file_label=i18n("上传文件"),
+ uploaded_files_label=i18n("知识库文件"),
+ uploaded_files_tip=i18n("在工具箱中管理知识库文件")
+ ))
+ with gr.Row(elem_id="chatbot-input-tb-row"):
+ with gr.Column(min_width=225, scale=12):
+ user_input = gr.Textbox(
+ elem_id="user-input-tb",
+ show_label=False,
+ placeholder=i18n("在这里输入"),
+ elem_classes="no-container",
+ max_lines=5,
+ # container=False
+ )
+ with gr.Column(min_width=42, scale=1, elem_id="chatbot-ctrl-btns"):
+ submitBtn = gr.Button(
+ value="", variant="primary", elem_id="submit-btn")
+ cancelBtn = gr.Button(
+ value="", variant="secondary", visible=False, elem_id="cancel-btn")
+ # Note: Buttons below are set invisible in UI. But they are used in JS.
+ with gr.Row(elem_id="chatbot-buttons", visible=False):
+ with gr.Column(min_width=120, scale=1):
+ emptyBtn = gr.Button(
+ i18n("🧹 新的对话"), elem_id="empty-btn"
+ )
+ with gr.Column(min_width=120, scale=1):
+ retryBtn = gr.Button(
+ i18n("🔄 重新生成"), elem_id="gr-retry-btn")
+ with gr.Column(min_width=120, scale=1):
+ delFirstBtn = gr.Button(i18n("🗑️ 删除最旧对话"))
+ with gr.Column(min_width=120, scale=1):
+ delLastBtn = gr.Button(
+ i18n("🗑️ 删除最新对话"), elem_id="gr-dellast-btn")
+ with gr.Row(visible=False) as like_dislike_area:
+ with gr.Column(min_width=20, scale=1):
+ likeBtn = gr.Button(
+ "👍", elem_id="gr-like-btn")
+ with gr.Column(min_width=20, scale=1):
+ dislikeBtn = gr.Button(
+ "👎", elem_id="gr-dislike-btn")
+
+ with gr.Column(elem_id="toolbox-area", scale=1):
+ # For CSS setting, there is an extra box. Don't remove it.
+ with gr.Box(elem_id="chuanhu-toolbox"):
+ with gr.Row():
+ gr.Markdown("## "+i18n("工具箱"))
+ gr.HTML(get_html("close_btn.html").format(
+ obj="toolbox"), elem_classes="close-btn")
+ with gr.Tabs(elem_id="chuanhu-toolbox-tabs"):
+ with gr.Tab(label=i18n("对话")):
+ keyTxt = gr.Textbox(
+ show_label=True,
+ placeholder=f"Your API-key...",
+ value=hide_middle_chars(user_api_key.value),
+ type="password",
+ visible=not HIDE_MY_KEY,
+ label="API-Key",
+ )
+ with gr.Accordion(label="Prompt", open=True):
+ systemPromptTxt = gr.Textbox(
+ show_label=True,
+ placeholder=i18n("在这里输入System Prompt..."),
+ label="System prompt",
+ value=INITIAL_SYSTEM_PROMPT,
+ lines=8
+ )
+ retain_system_prompt_checkbox = gr.Checkbox(
+ label=i18n("新建对话保留Prompt"), value=False, visible=True, elem_classes="switch-checkbox")
+ with gr.Accordion(label=i18n("加载Prompt模板"), open=False):
+ with gr.Column():
+ with gr.Row():
+ with gr.Column(scale=6):
+ templateFileSelectDropdown = gr.Dropdown(
+ label=i18n("选择Prompt模板集合文件"),
+ choices=get_template_names(),
+ multiselect=False,
+ value=get_template_names()[0],
+ container=False,
+ )
+ with gr.Column(scale=1):
+ templateRefreshBtn = gr.Button(
+ i18n("🔄 刷新"))
+ with gr.Row():
+ with gr.Column():
+ templateSelectDropdown = gr.Dropdown(
+ label=i18n("从Prompt模板中加载"),
+ choices=load_template(
+ get_template_names()[
+ 0], mode=1
+ ),
+ multiselect=False,
+ container=False,
+ )
+ gr.Markdown("---", elem_classes="hr-line")
+ with gr.Accordion(label=i18n("知识库"), open=True):
+ use_websearch_checkbox = gr.Checkbox(label=i18n(
+ "使用在线搜索"), value=False, elem_classes="switch-checkbox", elem_id="gr-websearch-cb", visible=False)
+ index_files = gr.Files(label=i18n(
+ "上传"), type="file", file_types=[".pdf", ".docx", ".pptx", ".epub", ".xlsx", ".txt", "text", "image"], elem_id="upload-index-file")
+ two_column = gr.Checkbox(label=i18n(
+ "双栏pdf"), value=advance_docs["pdf"].get("two_column", False))
+ summarize_btn = gr.Button(i18n("总结"))
+ # TODO: 公式ocr
+ # formula_ocr = gr.Checkbox(label=i18n("识别公式"), value=advance_docs["pdf"].get("formula_ocr", False))
+
+ with gr.Tab(label=i18n("参数")):
+ gr.Markdown(i18n("# ⚠️ 务必谨慎更改 ⚠️"),
+ elem_id="advanced-warning")
+ with gr.Accordion(i18n("参数"), open=True):
+ temperature_slider = gr.Slider(
+ minimum=-0,
+ maximum=2.0,
+ value=1.0,
+ step=0.1,
+ interactive=True,
+ label="temperature",
+ )
+ top_p_slider = gr.Slider(
+ minimum=-0,
+ maximum=1.0,
+ value=1.0,
+ step=0.05,
+ interactive=True,
+ label="top-p",
+ )
+ n_choices_slider = gr.Slider(
+ minimum=1,
+ maximum=10,
+ value=1,
+ step=1,
+ interactive=True,
+ label="n choices",
+ )
+ stop_sequence_txt = gr.Textbox(
+ show_label=True,
+ placeholder=i18n("停止符,用英文逗号隔开..."),
+ label="stop",
+ value="",
+ lines=1,
+ )
+ max_context_length_slider = gr.Slider(
+ minimum=1,
+ maximum=32768,
+ value=2000,
+ step=1,
+ interactive=True,
+ label="max context",
+ )
+ max_generation_slider = gr.Slider(
+ minimum=1,
+ maximum=32768,
+ value=1000,
+ step=1,
+ interactive=True,
+ label="max generations",
+ )
+ presence_penalty_slider = gr.Slider(
+ minimum=-2.0,
+ maximum=2.0,
+ value=0.0,
+ step=0.01,
+ interactive=True,
+ label="presence penalty",
+ )
+ frequency_penalty_slider = gr.Slider(
+ minimum=-2.0,
+ maximum=2.0,
+ value=0.0,
+ step=0.01,
+ interactive=True,
+ label="frequency penalty",
+ )
+ logit_bias_txt = gr.Textbox(
+ show_label=True,
+ placeholder=f"word:likelihood",
+ label="logit bias",
+ value="",
+ lines=1,
+ )
+ user_identifier_txt = gr.Textbox(
+ show_label=True,
+ placeholder=i18n("用于定位滥用行为"),
+ label=i18n("用户标识符"),
+ value=user_name.value,
+ lines=1,
+ )
+ with gr.Tab(label=i18n("拓展")):
+ gr.Markdown(
+ "Will be here soon...\n(We hope)\n\nAnd we hope you can help us to make more extensions!")
+
+ # changeAPIURLBtn = gr.Button(i18n("🔄 切换API地址"))
+
+ with gr.Row(elem_id="popup-wrapper"):
+ with gr.Box(elem_id="chuanhu-popup"):
+ with gr.Box(elem_id="chuanhu-setting"):
+ with gr.Row():
+ gr.Markdown("## "+i18n("设置"))
+ gr.HTML(get_html("close_btn.html").format(
+ obj="box"), elem_classes="close-btn")
+ with gr.Tabs(elem_id="chuanhu-setting-tabs"):
+ with gr.Tab(label=i18n("模型")):
+ if multi_api_key:
+ usageTxt = gr.Markdown(i18n(
+ "多账号模式已开启,无需输入key,可直接开始对话"), elem_id="usage-display", elem_classes="insert-block", visible=show_api_billing)
+ else:
+ usageTxt = gr.Markdown(i18n(
+ "**发送消息** 或 **提交key** 以显示额度"), elem_id="usage-display", elem_classes="insert-block", visible=show_api_billing)
+ # model_select_dropdown = gr.Dropdown(
+ # label=i18n("选择模型"), choices=MODELS, multiselect=False, value=MODELS[DEFAULT_MODEL], interactive=True
+ # )
+ # lora_select_dropdown = gr.Dropdown(
+ # label=i18n("选择LoRA模型"), choices=[], multiselect=False, interactive=True, visible=False
+ # )
+ # with gr.Row():
+
+ language_select_dropdown = gr.Dropdown(
+ label=i18n("选择回复语言(针对搜索&索引功能)"),
+ choices=REPLY_LANGUAGES,
+ multiselect=False,
+ value=REPLY_LANGUAGES[0],
+ )
+
+ with gr.Tab(label=i18n("高级")):
+ gr.HTML(get_html("appearance_switcher.html").format(
+ label=i18n("切换亮暗色主题")), elem_classes="insert-block", visible=False)
+ use_streaming_checkbox = gr.Checkbox(
+ label=i18n("实时传输回答"), value=True, visible=ENABLE_STREAMING_OPTION, elem_classes="switch-checkbox"
+ )
+ name_chat_method = gr.Dropdown(
+ label=i18n("对话命名方式"),
+ choices=HISTORY_NAME_METHODS,
+ multiselect=False,
+ interactive=True,
+ value=HISTORY_NAME_METHODS[chat_name_method_index],
+ )
+ single_turn_checkbox = gr.Checkbox(label=i18n(
+ "单轮对话"), value=False, elem_classes="switch-checkbox", elem_id="gr-single-session-cb", visible=False)
+ # checkUpdateBtn = gr.Button(i18n("🔄 检查更新..."), visible=check_update)
+
+ with gr.Tab(i18n("网络")):
+ gr.Markdown(
+ i18n("⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置"), elem_id="netsetting-warning")
+ default_btn = gr.Button(i18n("🔙 恢复默认网络设置"))
+ # 网络代理
+ proxyTxt = gr.Textbox(
+ show_label=True,
+ placeholder=i18n("未设置代理..."),
+ label=i18n("代理地址"),
+ value=config.http_proxy,
+ lines=1,
+ interactive=False,
+ # container=False,
+ elem_classes="view-only-textbox no-container",
+ )
+ # changeProxyBtn = gr.Button(i18n("🔄 设置代理地址"))
+
+ # 优先展示自定义的api_host
+ apihostTxt = gr.Textbox(
+ show_label=True,
+ placeholder="api.openai.com",
+ label="OpenAI API-Host",
+ value=config.api_host or shared.API_HOST,
+ lines=1,
+ interactive=False,
+ # container=False,
+ elem_classes="view-only-textbox no-container",
+ )
+
+ with gr.Tab(label=i18n("关于"), elem_id="about-tab"):
+ gr.Markdown(
+ '')
+ gr.Markdown("# "+i18n("小原同学"))
+ gr.HTML(get_html("footer.html").format(
+ versions=versions_html()), elem_id="footer")
+ gr.Markdown(CHUANHU_DESCRIPTION, elem_id="description")
+
+ with gr.Box(elem_id="chuanhu-training"):
+ with gr.Row():
+ gr.Markdown("## "+i18n("训练"))
+ gr.HTML(get_html("close_btn.html").format(
+ obj="box"), elem_classes="close-btn")
+ with gr.Tabs(elem_id="chuanhu-training-tabs"):
+ with gr.Tab(label="OpenAI "+i18n("微调")):
+ openai_train_status = gr.Markdown(label=i18n("训练状态"), value=i18n(
+ "查看[使用介绍](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#微调-gpt-35)"))
+
+ with gr.Tab(label=i18n("准备数据集")):
+ dataset_preview_json = gr.JSON(
+ label=i18n("数据集预览"))
+ dataset_selection = gr.Files(label=i18n("选择数据集"), file_types=[
+ ".xlsx", ".jsonl"], file_count="single")
+ upload_to_openai_btn = gr.Button(
+ i18n("上传到OpenAI"), variant="primary", interactive=False)
+
+ with gr.Tab(label=i18n("训练")):
+ openai_ft_file_id = gr.Textbox(label=i18n(
+ "文件ID"), value="", lines=1, placeholder=i18n("上传到 OpenAI 后自动填充"))
+ openai_ft_suffix = gr.Textbox(label=i18n(
+ "模型名称后缀"), value="", lines=1, placeholder=i18n("可选,用于区分不同的模型"))
+ openai_train_epoch_slider = gr.Slider(label=i18n(
+ "训练轮数(Epochs)"), minimum=1, maximum=100, value=3, step=1, interactive=True)
+ openai_start_train_btn = gr.Button(
+ i18n("开始训练"), variant="primary", interactive=False)
+
+ with gr.Tab(label=i18n("状态")):
+ openai_status_refresh_btn = gr.Button(i18n("刷新状态"))
+ openai_cancel_all_jobs_btn = gr.Button(
+ i18n("取消所有任务"))
+ add_to_models_btn = gr.Button(
+ i18n("添加训练好的模型到模型列表"), interactive=False)
+
+ with gr.Box(elem_id="web-config", visible=False):
+ gr.HTML(get_html('web_config.html').format(
+ enableCheckUpdate_config=check_update,
+ hideHistoryWhenNotLoggedIn_config=hide_history_when_not_logged_in,
+ forView_i18n=i18n("仅供查看"),
+ deleteConfirm_i18n_pref=i18n("你真的要删除 "),
+ deleteConfirm_i18n_suff=i18n(" 吗?"),
+ usingLatest_i18n=i18n("您使用的就是最新版!"),
+ updatingMsg_i18n=i18n("正在尝试更新..."),
+ updateSuccess_i18n=i18n("更新成功,请重启本程序"),
+ updateFailure_i18n=i18n(
+ "更新失败,请尝试[手动更新](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)"),
+ regenerate_i18n=i18n("重新生成"),
+ deleteRound_i18n=i18n("删除这轮问答"),
+ renameChat_i18n=i18n("重命名该对话"),
+ validFileName_i18n=i18n("请输入有效的文件名,不要包含以下特殊字符:"),
+ ))
+ with gr.Box(elem_id="fake-gradio-components", visible=False):
+ updateChuanhuBtn = gr.Button(
+ visible=False, elem_classes="invisible-btn", elem_id="update-chuanhu-btn")
+ changeSingleSessionBtn = gr.Button(
+ visible=False, elem_classes="invisible-btn", elem_id="change-single-session-btn")
+ changeOnlineSearchBtn = gr.Button(
+ visible=False, elem_classes="invisible-btn", elem_id="change-online-search-btn")
+ historySelectBtn = gr.Button(
+ visible=False, elem_classes="invisible-btn", elem_id="history-select-btn") # Not used
+
+ # https://github.com/gradio-app/gradio/pull/3296
+
+ def create_greeting(request: gr.Request):
+ if hasattr(request, "username") and request.username: # is not None or is not ""
+ logging.info(f"Get User Name: {request.username}")
+ user_info, user_name = gr.Markdown.update(
+ value=f"User: {request.username}"), request.username
+ else:
+ user_info, user_name = gr.Markdown.update(
+ value=f"", visible=False), ""
+ current_model = get_model(
+ model_name=MODELS[DEFAULT_MODEL], access_key=my_api_key, user_name=user_name)[0]
+ if not hide_history_when_not_logged_in or user_name:
+ loaded_stuff = current_model.auto_load()
+ else:
+ loaded_stuff = [gr.update(), gr.update(), gr.Chatbot.update(label=MODELS[DEFAULT_MODEL]), current_model.single_turn, current_model.temperature, current_model.top_p, current_model.n_choices, current_model.stop_sequence, current_model.token_upper_limit, current_model.max_generation_token, current_model.presence_penalty, current_model.frequency_penalty, current_model.logit_bias, current_model.user_identifier]
+ return user_info, user_name, current_model, toggle_like_btn_visibility(DEFAULT_MODEL), *loaded_stuff, init_history_list(user_name)
+ demo.load(create_greeting, inputs=None, outputs=[
+ user_info, user_name, current_model, like_dislike_area, saveFileName, systemPromptTxt, chatbot, single_turn_checkbox, temperature_slider, top_p_slider, n_choices_slider, stop_sequence_txt, max_context_length_slider, max_generation_slider, presence_penalty_slider, frequency_penalty_slider, logit_bias_txt, user_identifier_txt, historySelectList], api_name="load")
+ chatgpt_predict_args = dict(
+ fn=predict,
+ inputs=[
+ current_model,
+ user_question,
+ chatbot,
+ use_streaming_checkbox,
+ use_websearch_checkbox,
+ index_files,
+ language_select_dropdown,
+ ],
+ outputs=[chatbot, status_display],
+ show_progress=True,
+ )
+
+ start_outputing_args = dict(
+ fn=start_outputing,
+ inputs=[],
+ outputs=[submitBtn, cancelBtn],
+ show_progress=True,
+ )
+
+ end_outputing_args = dict(
+ fn=end_outputing, inputs=[], outputs=[submitBtn, cancelBtn]
+ )
+
+ reset_textbox_args = dict(
+ fn=reset_textbox, inputs=[], outputs=[user_input]
+ )
+
+ transfer_input_args = dict(
+ fn=transfer_input, inputs=[user_input], outputs=[
+ user_question, user_input, submitBtn, cancelBtn], show_progress=True
+ )
+
+ get_usage_args = dict(
+ fn=billing_info, inputs=[current_model], outputs=[
+ usageTxt], show_progress=False
+ )
+
+ load_history_from_file_args = dict(
+ fn=load_chat_history,
+ inputs=[current_model, historySelectList],
+ outputs=[saveFileName, systemPromptTxt, chatbot, single_turn_checkbox, temperature_slider, top_p_slider, n_choices_slider, stop_sequence_txt, max_context_length_slider, max_generation_slider, presence_penalty_slider, frequency_penalty_slider, logit_bias_txt, user_identifier_txt],
+ )
+
+ refresh_history_args = dict(
+ fn=get_history_list, inputs=[user_name], outputs=[historySelectList]
+ )
+
+ auto_name_chat_history_args = dict(
+ fn=auto_name_chat_history,
+ inputs=[current_model, name_chat_method, user_question, chatbot, single_turn_checkbox],
+ outputs=[historySelectList],
+ show_progress=False,
+ )
+
+ # Chatbot
+ cancelBtn.click(interrupt, [current_model], [])
+
+ user_input.submit(**transfer_input_args).then(**
+ chatgpt_predict_args).then(**end_outputing_args).then(**auto_name_chat_history_args)
+ user_input.submit(**get_usage_args)
+
+ # user_input.submit(auto_name_chat_history, [current_model, user_question, chatbot, user_name], [historySelectList], show_progress=False)
+
+ submitBtn.click(**transfer_input_args).then(**chatgpt_predict_args,
+ api_name="predict").then(**end_outputing_args).then(**auto_name_chat_history_args)
+ submitBtn.click(**get_usage_args)
+
+ # submitBtn.click(auto_name_chat_history, [current_model, user_question, chatbot, user_name], [historySelectList], show_progress=False)
+
+ index_files.upload(handle_file_upload, [current_model, index_files, chatbot, language_select_dropdown], [
+ index_files, chatbot, status_display])
+ summarize_btn.click(handle_summarize_index, [
+ current_model, index_files, chatbot, language_select_dropdown], [chatbot, status_display])
+
+ emptyBtn.click(
+ reset,
+ inputs=[current_model, retain_system_prompt_checkbox],
+ outputs=[chatbot, status_display, historySelectList, systemPromptTxt, single_turn_checkbox, temperature_slider, top_p_slider, n_choices_slider, stop_sequence_txt, max_context_length_slider, max_generation_slider, presence_penalty_slider, frequency_penalty_slider, logit_bias_txt, user_identifier_txt],
+ show_progress=True,
+ _js='(a,b)=>{return clearChatbot(a,b);}',
+ )
+
+ retryBtn.click(**start_outputing_args).then(
+ retry,
+ [
+ current_model,
+ chatbot,
+ use_streaming_checkbox,
+ use_websearch_checkbox,
+ index_files,
+ language_select_dropdown,
+ ],
+ [chatbot, status_display],
+ show_progress=True,
+ ).then(**end_outputing_args)
+ retryBtn.click(**get_usage_args)
+
+ delFirstBtn.click(
+ delete_first_conversation,
+ [current_model],
+ [status_display],
+ )
+
+ delLastBtn.click(
+ delete_last_conversation,
+ [current_model, chatbot],
+ [chatbot, status_display],
+ show_progress=False
+ )
+
+ likeBtn.click(
+ like,
+ [current_model],
+ [status_display],
+ show_progress=False
+ )
+
+ dislikeBtn.click(
+ dislike,
+ [current_model],
+ [status_display],
+ show_progress=False
+ )
+
+ two_column.change(update_doc_config, [two_column], None)
+
+ # LLM Models
+ keyTxt.change(set_key, [current_model, keyTxt], [
+ user_api_key, status_display], api_name="set_key").then(**get_usage_args)
+ keyTxt.submit(**get_usage_args)
+ single_turn_checkbox.change(
+ set_single_turn, [current_model, single_turn_checkbox], None, show_progress=False)
+ model_select_dropdown.change(get_model, [model_select_dropdown, lora_select_dropdown, user_api_key, temperature_slider, top_p_slider, systemPromptTxt, user_name, current_model], [
+ current_model, status_display, chatbot, lora_select_dropdown, user_api_key, keyTxt], show_progress=True, api_name="get_model")
+ model_select_dropdown.change(toggle_like_btn_visibility, [model_select_dropdown], [
+ like_dislike_area], show_progress=False)
+ # model_select_dropdown.change(
+ # toggle_file_type, [model_select_dropdown], [index_files], show_progress=False)
+ lora_select_dropdown.change(get_model, [model_select_dropdown, lora_select_dropdown, user_api_key, temperature_slider,
+ top_p_slider, systemPromptTxt, user_name, current_model], [current_model, status_display, chatbot], show_progress=True)
+
+ # Template
+ systemPromptTxt.input(set_system_prompt, [
+ current_model, systemPromptTxt], None)
+ templateRefreshBtn.click(get_template_dropdown, None, [
+ templateFileSelectDropdown])
+ templateFileSelectDropdown.input(
+ load_template,
+ [templateFileSelectDropdown],
+ [promptTemplates, templateSelectDropdown],
+ show_progress=True,
+ )
+ templateSelectDropdown.change(
+ get_template_content,
+ [promptTemplates, templateSelectDropdown, systemPromptTxt],
+ [systemPromptTxt],
+ show_progress=True,
+ )
+
+ # S&L
+ renameHistoryBtn.click(
+ rename_chat_history,
+ [current_model, saveFileName, chatbot, user_name],
+ [historySelectList],
+ show_progress=True,
+ _js='(a,b,c,d)=>{return saveChatHistory(a,b,c,d);}'
+ )
+ exportMarkdownBtn.click(
+ export_markdown,
+ [current_model, saveFileName, chatbot],
+ [],
+ show_progress=True,
+ )
+ historyRefreshBtn.click(**refresh_history_args)
+ historyDeleteBtn.click(delete_chat_history, [current_model, historySelectList], [status_display, historySelectList, chatbot], _js='(a,b,c)=>{return showConfirmationDialog(a, b, c);}').then(
+ reset,
+ inputs=[current_model, retain_system_prompt_checkbox],
+ outputs=[chatbot, status_display, historySelectList, systemPromptTxt],
+ show_progress=True,
+ _js='(a,b)=>{return clearChatbot(a,b);}',
+ )
+ historySelectList.input(**load_history_from_file_args)
+ uploadFileBtn.upload(upload_chat_history, [current_model, uploadFileBtn], [
+ saveFileName, systemPromptTxt, chatbot, single_turn_checkbox, temperature_slider, top_p_slider, n_choices_slider, stop_sequence_txt, max_context_length_slider, max_generation_slider, presence_penalty_slider, frequency_penalty_slider, logit_bias_txt, user_identifier_txt]).then(**refresh_history_args)
+ historyDownloadBtn.click(None, [
+ user_name, historySelectList], None, _js='(a,b)=>{return downloadHistory(a,b,".json");}')
+ historyMarkdownDownloadBtn.click(None, [
+ user_name, historySelectList], None, _js='(a,b)=>{return downloadHistory(a,b,".md");}')
+ historySearchTextbox.input(
+ filter_history,
+ [user_name, historySearchTextbox],
+ [historySelectList]
+ )
+
+ # Train
+ dataset_selection.upload(handle_dataset_selection, dataset_selection, [
+ dataset_preview_json, upload_to_openai_btn, openai_train_status])
+ dataset_selection.clear(handle_dataset_clear, [], [
+ dataset_preview_json, upload_to_openai_btn])
+ upload_to_openai_btn.click(upload_to_openai, [dataset_selection], [
+ openai_ft_file_id, openai_train_status], show_progress=True)
+
+ openai_ft_file_id.change(lambda x: gr.update(interactive=True) if len(
+ x) > 0 else gr.update(interactive=False), [openai_ft_file_id], [openai_start_train_btn])
+ openai_start_train_btn.click(start_training, [
+ openai_ft_file_id, openai_ft_suffix, openai_train_epoch_slider], [openai_train_status])
+
+ openai_status_refresh_btn.click(get_training_status, [], [
+ openai_train_status, add_to_models_btn])
+ add_to_models_btn.click(add_to_models, [], [
+ model_select_dropdown, openai_train_status], show_progress=True)
+ openai_cancel_all_jobs_btn.click(
+ cancel_all_jobs, [], [openai_train_status], show_progress=True)
+
+ # Advanced
+ temperature_slider.input(
+ set_temperature, [current_model, temperature_slider], None, show_progress=False)
+ top_p_slider.input(set_top_p, [current_model, top_p_slider], None, show_progress=False)
+ n_choices_slider.input(
+ set_n_choices, [current_model, n_choices_slider], None, show_progress=False)
+ stop_sequence_txt.input(
+ set_stop_sequence, [current_model, stop_sequence_txt], None, show_progress=False)
+ max_context_length_slider.input(
+ set_token_upper_limit, [current_model, max_context_length_slider], None, show_progress=False)
+ max_generation_slider.input(
+ set_max_tokens, [current_model, max_generation_slider], None, show_progress=False)
+ presence_penalty_slider.input(
+ set_presence_penalty, [current_model, presence_penalty_slider], None, show_progress=False)
+ frequency_penalty_slider.input(
+ set_frequency_penalty, [current_model, frequency_penalty_slider], None, show_progress=False)
+ logit_bias_txt.input(
+ set_logit_bias, [current_model, logit_bias_txt], None, show_progress=False)
+ user_identifier_txt.input(set_user_identifier, [
+ current_model, user_identifier_txt], None, show_progress=False)
+
+ default_btn.click(
+ reset_default, [], [apihostTxt, proxyTxt, status_display], show_progress=True
+ )
+ # changeAPIURLBtn.click(
+ # change_api_host,
+ # [apihostTxt],
+ # [status_display],
+ # show_progress=True,
+ # )
+ # changeProxyBtn.click(
+ # change_proxy,
+ # [proxyTxt],
+ # [status_display],
+ # show_progress=True,
+ # )
+ # checkUpdateBtn.click(fn=None, _js='manualCheckUpdate')
+
+ # Invisible elements
+ updateChuanhuBtn.click(
+ update_chuanhu,
+ [],
+ [status_display],
+ show_progress=True,
+ )
+ changeSingleSessionBtn.click(
+ fn=lambda value: gr.Checkbox.update(value=value),
+ inputs=[single_turn_checkbox],
+ outputs=[single_turn_checkbox],
+ _js='(a)=>{return bgChangeSingleSession(a);}'
+ )
+ changeOnlineSearchBtn.click(
+ fn=lambda value: gr.Checkbox.update(value=value),
+ inputs=[use_websearch_checkbox],
+ outputs=[use_websearch_checkbox],
+ _js='(a)=>{return bgChangeOnlineSearch(a);}'
+ )
+ historySelectBtn.click( # This is an experimental feature... Not actually used.
+ fn=load_chat_history,
+ inputs=[current_model, historySelectList],
+ outputs=[saveFileName, systemPromptTxt, chatbot, single_turn_checkbox, temperature_slider, top_p_slider, n_choices_slider, stop_sequence_txt, max_context_length_slider, max_generation_slider, presence_penalty_slider, frequency_penalty_slider, logit_bias_txt, user_identifier_txt],
+ _js='(a,b)=>{return bgSelectHistory(a,b);}'
+ )
+
+
+logging.info(
+ colorama.Back.GREEN
+ + "\n小原同学的温馨提示:访问 http://localhost:7860 查看界面"
+ + colorama.Style.RESET_ALL
+)
+# 默认开启本地服务器,默认可以直接从IP访问,默认不创建公开分享链接
+demo.title = i18n("小原同学 🚀")
+
+if __name__ == "__main__":
+ reload_javascript()
+ demo.queue(concurrency_count=CONCURRENT_COUNT).launch(
+ allowed_paths=["history", "web_assets"],
+ server_name=server_name,
+ server_port=server_port,
+ share=share,
+ auth=auth_from_conf if authflag else None,
+ favicon_path="./web_assets/favicon.ico",
+ inbrowser=not dockerflag, # 禁止在docker下开启inbrowser
+ )
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000000000000000000000000000000000000..85d5045d5316ac160277af1e7d60afa823c0f953
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,18 @@
+FROM python:3.9-slim-buster as builder
+RUN apt-get update \
+ && apt-get install -y build-essential \
+ && apt-get clean \
+ && rm -rf /var/lib/apt/lists/*
+COPY requirements.txt .
+COPY requirements_advanced.txt .
+RUN pip install --user --no-cache-dir -r requirements.txt
+# RUN pip install --user --no-cache-dir -r requirements_advanced.txt
+
+FROM python:3.9-slim-buster
+LABEL maintainer="iskoldt"
+COPY --from=builder /root/.local /root/.local
+ENV PATH=/root/.local/bin:$PATH
+COPY . /app
+WORKDIR /app
+ENV dockerrun=yes
+CMD ["python3", "-u", "ChuanhuChatbot.py","2>&1", "|", "tee", "/var/log/application.log"]
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..f288702d2fa16d3cdf0035b15a9fcbc552cd88e7
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/README.md b/README.md
index d8ae27c0a0596a9d9ccfc9002874f9f246b4ab3f..9905304833748f48496d82175e12fcabb43d6cea 100644
--- a/README.md
+++ b/README.md
@@ -5,9 +5,202 @@ colorFrom: pink
colorTo: blue
sdk: gradio
sdk_version: 4.8.0
-app_file: app.py
+app_file: ChuanhuChatbot.py
pinned: false
license: apache-2.0
---
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
+