镜像自地址
https://github.com/binary-husky/gpt_academic.git
已同步 2025-12-06 06:26:47 +00:00
Merge branch 'master' into frontier
这个提交包含在:
56
.github/workflows/conda-pack-windows.yml
vendored
普通文件
56
.github/workflows/conda-pack-windows.yml
vendored
普通文件
@@ -0,0 +1,56 @@
|
|||||||
|
name: Create Conda Environment Package
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Miniconda
|
||||||
|
uses: conda-incubator/setup-miniconda@v3
|
||||||
|
with:
|
||||||
|
auto-activate-base: true
|
||||||
|
activate-environment: ""
|
||||||
|
|
||||||
|
- name: Create new Conda environment
|
||||||
|
shell: bash -l {0}
|
||||||
|
run: |
|
||||||
|
conda create -n gpt python=3.11 -y
|
||||||
|
conda activate gpt
|
||||||
|
|
||||||
|
- name: Install requirements
|
||||||
|
shell: bash -l {0}
|
||||||
|
run: |
|
||||||
|
conda activate gpt
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
- name: Install conda-pack
|
||||||
|
shell: bash -l {0}
|
||||||
|
run: |
|
||||||
|
conda activate gpt
|
||||||
|
conda install conda-pack -y
|
||||||
|
|
||||||
|
- name: Pack conda environment
|
||||||
|
shell: bash -l {0}
|
||||||
|
run: |
|
||||||
|
conda activate gpt
|
||||||
|
conda pack -n gpt -o gpt.tar.gz
|
||||||
|
|
||||||
|
- name: Create workspace zip
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
mkdir workspace
|
||||||
|
Get-ChildItem -Exclude "workspace" | Copy-Item -Destination workspace -Recurse
|
||||||
|
Remove-Item -Path workspace/.git* -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
Copy-Item gpt.tar.gz workspace/ -Force
|
||||||
|
|
||||||
|
- name: Upload packed files
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: gpt-academic-package
|
||||||
|
path: workspace
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
|
> `frontier开发分支`最新动态(2024.12.9): 更新对话时间线功能,优化xelatex论文翻译
|
||||||
|
> `wiki文档`最新动态(2024.12.5): 更新ollama接入指南
|
||||||
|
>
|
||||||
> 2024.10.10: 突发停电,紧急恢复了提供[whl包](https://drive.google.com/file/d/19U_hsLoMrjOlQSzYS3pzWX9fTzyusArP/view?usp=sharing)的文件服务器
|
> 2024.10.10: 突发停电,紧急恢复了提供[whl包](https://drive.google.com/file/d/19U_hsLoMrjOlQSzYS3pzWX9fTzyusArP/view?usp=sharing)的文件服务器
|
||||||
> 2024.10.8: 版本3.90加入对llama-index的初步支持,版本3.80加入插件二级菜单功能(详见wiki)
|
> 2024.10.8: 版本3.90加入对llama-index的初步支持,版本3.80加入插件二级菜单功能(详见wiki)
|
||||||
> 2024.5.1: 加入Doc2x翻译PDF论文的功能,[查看详情](https://github.com/binary-husky/gpt_academic/wiki/Doc2x)
|
> 2024.5.1: 加入Doc2x翻译PDF论文的功能,[查看详情](https://github.com/binary-husky/gpt_academic/wiki/Doc2x)
|
||||||
|
|||||||
26
docs/WindowsRun.bat
普通文件
26
docs/WindowsRun.bat
普通文件
@@ -0,0 +1,26 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
:: 设置环境变量
|
||||||
|
set ENV_NAME=gpt
|
||||||
|
set ENV_PATH=%~dp0%ENV_NAME%
|
||||||
|
set SCRIPT_PATH=%~dp0main.py
|
||||||
|
|
||||||
|
:: 判断环境是否已解压
|
||||||
|
if not exist "%ENV_PATH%" (
|
||||||
|
echo Extracting environment...
|
||||||
|
mkdir "%ENV_PATH%"
|
||||||
|
tar -xzf gpt.tar.gz -C "%ENV_PATH%"
|
||||||
|
|
||||||
|
:: 运行conda环境激活脚本
|
||||||
|
call "%ENV_PATH%\Scripts\activate.bat"
|
||||||
|
) else (
|
||||||
|
:: 如果环境已存在,直接激活
|
||||||
|
call "%ENV_PATH%\Scripts\activate.bat"
|
||||||
|
)
|
||||||
|
echo Start to run program:
|
||||||
|
:: 运行Python脚本
|
||||||
|
python "%SCRIPT_PATH%"
|
||||||
|
|
||||||
|
endlocal
|
||||||
|
pause
|
||||||
@@ -25,7 +25,7 @@ pyautogen
|
|||||||
colorama
|
colorama
|
||||||
Markdown
|
Markdown
|
||||||
pygments
|
pygments
|
||||||
edge-tts
|
edge-tts>=7.0.0
|
||||||
pymupdf
|
pymupdf
|
||||||
openai
|
openai
|
||||||
rjsmin
|
rjsmin
|
||||||
|
|||||||
33
tests/test_tts.py
普通文件
33
tests/test_tts.py
普通文件
@@ -0,0 +1,33 @@
|
|||||||
|
import edge_tts
|
||||||
|
import os
|
||||||
|
import httpx
|
||||||
|
from toolbox import get_conf
|
||||||
|
|
||||||
|
|
||||||
|
async def test_tts():
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
try:
|
||||||
|
# Forward the request to the target service
|
||||||
|
import tempfile
|
||||||
|
import edge_tts
|
||||||
|
import wave
|
||||||
|
import uuid
|
||||||
|
from pydub import AudioSegment
|
||||||
|
voice = get_conf("EDGE_TTS_VOICE")
|
||||||
|
tts = edge_tts.Communicate(text="测试", voice=voice)
|
||||||
|
temp_folder = tempfile.gettempdir()
|
||||||
|
temp_file_name = str(uuid.uuid4().hex)
|
||||||
|
temp_file = os.path.join(temp_folder, f'{temp_file_name}.mp3')
|
||||||
|
await tts.save(temp_file)
|
||||||
|
try:
|
||||||
|
mp3_audio = AudioSegment.from_file(temp_file, format="mp3")
|
||||||
|
mp3_audio.export(temp_file, format="wav")
|
||||||
|
with open(temp_file, 'rb') as wav_file: t = wav_file.read()
|
||||||
|
except:
|
||||||
|
raise RuntimeError("ffmpeg未安装,无法处理EdgeTTS音频。安装方法见`https://github.com/jiaaro/pydub#getting-ffmpeg-set-up`")
|
||||||
|
except httpx.RequestError as e:
|
||||||
|
raise RuntimeError(f"请求失败: {e}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
import asyncio
|
||||||
|
asyncio.run(test_tts())
|
||||||
@@ -192,10 +192,22 @@ class WelcomeMessage {
|
|||||||
|
|
||||||
async update() {
|
async update() {
|
||||||
// console.log('update')
|
// console.log('update')
|
||||||
|
const elem_chatbot = document.getElementById('gpt-chatbot');
|
||||||
|
const chatbot_top = elem_chatbot.getBoundingClientRect().top;
|
||||||
|
const welcome_card_container = document.getElementsByClassName('welcome-card-container')[0];
|
||||||
|
let welcome_card_overflow = false;
|
||||||
|
if (welcome_card_container) {
|
||||||
|
const welcome_card_top = welcome_card_container.getBoundingClientRect().top;
|
||||||
|
if (welcome_card_top < chatbot_top) {
|
||||||
|
welcome_card_overflow = true;
|
||||||
|
// console.log("welcome_card_overflow");
|
||||||
|
}
|
||||||
|
}
|
||||||
var page_width = document.documentElement.clientWidth;
|
var page_width = document.documentElement.clientWidth;
|
||||||
const width_to_hide_welcome = 1000;
|
const width_to_hide_welcome = 1200;
|
||||||
if (!await this.isChatbotEmpty() || page_width < width_to_hide_welcome) {
|
if (!await this.isChatbotEmpty() || page_width < width_to_hide_welcome || welcome_card_overflow) {
|
||||||
if (this.visible) {
|
if (this.visible) {
|
||||||
|
// console.log("remove welcome");
|
||||||
this.removeWelcome();
|
this.removeWelcome();
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.card_array = [];
|
this.card_array = [];
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户