From ed5fc84d4e88753827bc90b504d2f7a290cf75dc Mon Sep 17 00:00:00 2001 From: Menghuan Date: Sat, 7 Dec 2024 23:41:02 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=BAwindows=E7=9A=84?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E6=89=93=E5=8C=85=E4=BB=A5=E5=8F=8A=E4=B8=80?= =?UTF-8?q?=E9=94=AE=E5=90=AF=E5=8A=A8=E8=84=9A=E6=9C=AC=20(#2068)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 新增自动打包windows下的环境依赖 --------- Co-authored-by: binary-husky --- .github/workflows/conda-pack-windows.yml | 56 ++++++++++++++++++++++++ docs/WindowsRun.bat | 26 +++++++++++ 2 files changed, 82 insertions(+) create mode 100644 .github/workflows/conda-pack-windows.yml create mode 100644 docs/WindowsRun.bat diff --git a/.github/workflows/conda-pack-windows.yml b/.github/workflows/conda-pack-windows.yml new file mode 100644 index 00000000..5d5e2251 --- /dev/null +++ b/.github/workflows/conda-pack-windows.yml @@ -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 diff --git a/docs/WindowsRun.bat b/docs/WindowsRun.bat new file mode 100644 index 00000000..6da541ac --- /dev/null +++ b/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 \ No newline at end of file From e4bebea28d132706e1834b38e1a22103f24b317d Mon Sep 17 00:00:00 2001 From: binary-husky Date: Mon, 9 Dec 2024 23:40:23 +0800 Subject: [PATCH 2/5] update requirements --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7a3d9f86..f739685d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -https://public.agent-matrix.com/publish/gradio-3.32.10-py3-none-any.whl +https://public.agent-matrix.com/publish/gradio-3.32.11-py3-none-any.whl fastapi==0.110 gradio-client==0.8 pypdf2==2.12.1 From 98e5cb7b7750b89025103d0c5865f29d6457b83a Mon Sep 17 00:00:00 2001 From: binary-husky Date: Mon, 9 Dec 2024 23:57:10 +0800 Subject: [PATCH 3/5] update readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 2b8ffaa5..7d98b5f8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ > [!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.8: 版本3.90加入对llama-index的初步支持,版本3.80加入插件二级菜单功能(详见wiki) > 2024.5.1: 加入Doc2x翻译PDF论文的功能,[查看详情](https://github.com/binary-husky/gpt_academic/wiki/Doc2x) From 4127162ee770b74cf710ac47e243da4a0b242e38 Mon Sep 17 00:00:00 2001 From: binary-husky Date: Wed, 18 Dec 2024 17:47:23 +0800 Subject: [PATCH 4/5] add tts test --- requirements.txt | 2 +- tests/test_tts.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/test_tts.py diff --git a/requirements.txt b/requirements.txt index f739685d..31ba9157 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,7 +25,7 @@ pyautogen colorama Markdown pygments -edge-tts +edge-tts>=7.0.0 pymupdf openai rjsmin diff --git a/tests/test_tts.py b/tests/test_tts.py new file mode 100644 index 00000000..7d86d1fc --- /dev/null +++ b/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()) \ No newline at end of file From 81da7bb1a50ed6287a323152a6be0941089f77bd Mon Sep 17 00:00:00 2001 From: binary-husky Date: Wed, 18 Dec 2024 17:48:02 +0800 Subject: [PATCH 5/5] remove welcome card when layout overflows --- themes/welcome.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/themes/welcome.js b/themes/welcome.js index 8296b1f5..e7d86067 100644 --- a/themes/welcome.js +++ b/themes/welcome.js @@ -192,10 +192,22 @@ class WelcomeMessage { async 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; 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) { + // console.log("remove welcome"); this.removeWelcome(); this.visible = false; this.card_array = [];