Spaces:
Paused
Paused
saving changes
Browse files- app/agent/custom_chatbot.py +1 -0
- clean-repo-history.bat +56 -0
- fresh-deploy.bat +78 -0
- setup-dubsway-env.bat +0 -81
- start-server.bat +0 -8
- worker/daemon.py +4 -4
app/agent/custom_chatbot.py
CHANGED
|
@@ -99,3 +99,4 @@ async def custom_chatbot(request: ChatRequest):
|
|
| 99 |
except Exception as e:
|
| 100 |
logger.exception("β Unexpected error in custom chatbot endpoint.")
|
| 101 |
raise HTTPException(status_code=500, detail="Internal server error")
|
|
|
|
|
|
| 99 |
except Exception as e:
|
| 100 |
logger.exception("β Unexpected error in custom chatbot endpoint.")
|
| 101 |
raise HTTPException(status_code=500, detail="Internal server error")
|
| 102 |
+
|
clean-repo-history.bat
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@echo off
|
| 2 |
+
echo π§Ή Deep cleaning repository history...
|
| 3 |
+
|
| 4 |
+
echo.
|
| 5 |
+
echo β οΈ WARNING: This will rewrite git history!
|
| 6 |
+
echo This will remove all binary files from the entire git history.
|
| 7 |
+
echo.
|
| 8 |
+
set /p confirm="Are you sure you want to continue? (y/N): "
|
| 9 |
+
|
| 10 |
+
if /i not "%confirm%"=="y" (
|
| 11 |
+
echo Cancelled.
|
| 12 |
+
pause
|
| 13 |
+
exit /b 0
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
echo.
|
| 17 |
+
echo ποΈ Removing binary files from git history...
|
| 18 |
+
|
| 19 |
+
REM Remove vector store directory from entire history
|
| 20 |
+
git filter-branch --force --index-filter "git rm -rf --cached --ignore-unmatch vector_store/" --prune-empty --tag-name-filter cat -- --all
|
| 21 |
+
|
| 22 |
+
REM Remove database files from entire history
|
| 23 |
+
git filter-branch --force --index-filter "git rm -rf --cached --ignore-unmatch *.db" --prune-empty --tag-name-filter cat -- --all
|
| 24 |
+
git filter-branch --force --index-filter "git rm -rf --cached --ignore-unmatch *.sqlite" --prune-empty --tag-name-filter cat -- --all
|
| 25 |
+
git filter-branch --force --index-filter "git rm -rf --cached --ignore-unmatch *.sqlite3" --prune-empty --tag-name-filter cat -- --all
|
| 26 |
+
|
| 27 |
+
REM Remove FAISS files from entire history
|
| 28 |
+
git filter-branch --force --index-filter "git rm -rf --cached --ignore-unmatch *.faiss" --prune-empty --tag-name-filter cat -- --all
|
| 29 |
+
git filter-branch --force --index-filter "git rm -rf --cached --ignore-unmatch *.index" --prune-empty --tag-name-filter cat -- --all
|
| 30 |
+
|
| 31 |
+
REM Remove log files from entire history
|
| 32 |
+
git filter-branch --force --index-filter "git rm -rf --cached --ignore-unmatch *.log" --prune-empty --tag-name-filter cat -- --all
|
| 33 |
+
|
| 34 |
+
echo.
|
| 35 |
+
echo π§Ή Cleaning up...
|
| 36 |
+
git for-each-ref --format="delete %(refname)" refs/original | git update-ref --stdin
|
| 37 |
+
git reflog expire --expire=now --all
|
| 38 |
+
git gc --prune=now --aggressive
|
| 39 |
+
|
| 40 |
+
echo.
|
| 41 |
+
echo β
Repository history cleaned!
|
| 42 |
+
echo.
|
| 43 |
+
echo π Now commit the current state...
|
| 44 |
+
git add .
|
| 45 |
+
git commit -m "Clean repository for Hugging Face deployment"
|
| 46 |
+
|
| 47 |
+
echo.
|
| 48 |
+
echo π Ready to push! Run:
|
| 49 |
+
echo git push --force space develop
|
| 50 |
+
echo.
|
| 51 |
+
echo Or create a new branch:
|
| 52 |
+
echo git checkout -b main
|
| 53 |
+
echo git push space main
|
| 54 |
+
echo.
|
| 55 |
+
|
| 56 |
+
pause
|
fresh-deploy.bat
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@echo off
|
| 2 |
+
echo π Creating fresh repository for Hugging Face deployment...
|
| 3 |
+
|
| 4 |
+
echo.
|
| 5 |
+
echo π Creating backup of current files...
|
| 6 |
+
if not exist "backup" mkdir backup
|
| 7 |
+
xcopy /E /I /Y "app" "backup\app"
|
| 8 |
+
xcopy /E /I /Y "worker" "backup\worker"
|
| 9 |
+
copy "requirements-hf.txt" "backup\"
|
| 10 |
+
copy "Dockerfile" "backup\"
|
| 11 |
+
copy ".huggingface.yaml" "backup\"
|
| 12 |
+
copy "env.example" "backup\"
|
| 13 |
+
copy "*.md" "backup\"
|
| 14 |
+
copy ".gitignore" "backup\"
|
| 15 |
+
|
| 16 |
+
echo.
|
| 17 |
+
echo π§Ή Creating clean deployment directory...
|
| 18 |
+
if exist "deploy" rmdir /s /q "deploy"
|
| 19 |
+
mkdir deploy
|
| 20 |
+
cd deploy
|
| 21 |
+
|
| 22 |
+
echo.
|
| 23 |
+
echo π Initializing new git repository...
|
| 24 |
+
git init
|
| 25 |
+
|
| 26 |
+
echo.
|
| 27 |
+
echo π Copying clean files...
|
| 28 |
+
xcopy /E /I /Y "..\backup\app" "app\"
|
| 29 |
+
xcopy /E /I /Y "..\backup\worker" "worker\"
|
| 30 |
+
copy "..\backup\requirements-hf.txt" "."
|
| 31 |
+
copy "..\backup\Dockerfile" "."
|
| 32 |
+
copy "..\backup\.huggingface.yaml" "."
|
| 33 |
+
copy "..\backup\env.example" "."
|
| 34 |
+
copy "..\backup\.gitignore" "."
|
| 35 |
+
copy "..\backup\*.md" "."
|
| 36 |
+
|
| 37 |
+
echo.
|
| 38 |
+
echo π Adding Hugging Face remote...
|
| 39 |
+
git remote add space https://huggingface.co/spaces/peace2024/DubswayAgenticAI
|
| 40 |
+
|
| 41 |
+
echo.
|
| 42 |
+
echo π Committing clean repository...
|
| 43 |
+
git add .
|
| 44 |
+
git commit -m "Initial clean deployment for Hugging Face Spaces"
|
| 45 |
+
|
| 46 |
+
echo.
|
| 47 |
+
echo π Pushing to Hugging Face...
|
| 48 |
+
echo Choose your branch:
|
| 49 |
+
echo 1. Push to develop branch
|
| 50 |
+
echo 2. Push to main branch
|
| 51 |
+
echo 3. Cancel
|
| 52 |
+
echo.
|
| 53 |
+
set /p choice="Enter choice (1-3): "
|
| 54 |
+
|
| 55 |
+
if "%choice%"=="1" (
|
| 56 |
+
echo Pushing to develop branch...
|
| 57 |
+
git push space develop
|
| 58 |
+
) else if "%choice%"=="2" (
|
| 59 |
+
echo Pushing to main branch...
|
| 60 |
+
git push space main
|
| 61 |
+
) else (
|
| 62 |
+
echo Cancelled.
|
| 63 |
+
cd ..
|
| 64 |
+
pause
|
| 65 |
+
exit /b 0
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
echo.
|
| 69 |
+
echo β
Fresh deployment completed!
|
| 70 |
+
echo.
|
| 71 |
+
echo π Your Space URL will be:
|
| 72 |
+
echo https://huggingface.co/spaces/peace2024/DubswayAgenticAI
|
| 73 |
+
echo.
|
| 74 |
+
echo π Monitor the build logs in your Space settings.
|
| 75 |
+
echo.
|
| 76 |
+
|
| 77 |
+
cd ..
|
| 78 |
+
pause
|
setup-dubsway-env.bat
DELETED
|
@@ -1,81 +0,0 @@
|
|
| 1 |
-
@echo off
|
| 2 |
-
setlocal enabledelayedexpansion
|
| 3 |
-
|
| 4 |
-
REM ---- CONFIGURATION ----
|
| 5 |
-
set ENV_NAME=myenv
|
| 6 |
-
set PYTHON_EXE=python REM Ensure python points to 3.10 or 3.11 in PATH
|
| 7 |
-
set TORCH_INDEX=https://download.pytorch.org/whl/cu121
|
| 8 |
-
|
| 9 |
-
echo.
|
| 10 |
-
echo π Creating virtual environment: %ENV_NAME%
|
| 11 |
-
%PYTHON_EXE% -m venv %ENV_NAME%
|
| 12 |
-
|
| 13 |
-
echo.
|
| 14 |
-
echo π Activating environment...
|
| 15 |
-
call %ENV_NAME%\Scripts\activate.bat
|
| 16 |
-
|
| 17 |
-
echo.
|
| 18 |
-
echo π¦ Upgrading pip
|
| 19 |
-
pip install --upgrade pip
|
| 20 |
-
|
| 21 |
-
echo.
|
| 22 |
-
echo π Writing requirements.txt
|
| 23 |
-
(
|
| 24 |
-
echo fastapi
|
| 25 |
-
echo uvicorn
|
| 26 |
-
echo boto3
|
| 27 |
-
echo requests
|
| 28 |
-
echo python-dotenv
|
| 29 |
-
echo python-multipart
|
| 30 |
-
echo pydantic[email]>=1.10,<2.0
|
| 31 |
-
echo asyncpg
|
| 32 |
-
echo sqlalchemy>=2.0
|
| 33 |
-
echo databases
|
| 34 |
-
echo psycopg2-binary
|
| 35 |
-
echo passlib[bcrypt]
|
| 36 |
-
echo python-jose[cryptography]
|
| 37 |
-
echo langchain==0.1.13
|
| 38 |
-
echo langchain-openai==0.1.7
|
| 39 |
-
echo langchain-community==0.0.38
|
| 40 |
-
echo langchain-core==0.1.53
|
| 41 |
-
echo langchain-groq==0.0.3
|
| 42 |
-
echo langchainhub
|
| 43 |
-
echo langserve
|
| 44 |
-
echo langchain-objectbox
|
| 45 |
-
echo sentence-transformers==2.2.2
|
| 46 |
-
echo faiss-cpu
|
| 47 |
-
echo chromadb
|
| 48 |
-
echo transformers
|
| 49 |
-
echo whisper
|
| 50 |
-
echo faster-whisper==1.0.1
|
| 51 |
-
echo ctranslate2==3.22.0
|
| 52 |
-
echo PyPDF2
|
| 53 |
-
echo pypdf
|
| 54 |
-
echo reportlab
|
| 55 |
-
echo bs4
|
| 56 |
-
echo beautifulsoup4
|
| 57 |
-
echo sse-starlette
|
| 58 |
-
echo wikipedia
|
| 59 |
-
echo arxiv
|
| 60 |
-
echo cassio
|
| 61 |
-
echo streamlit
|
| 62 |
-
) > requirements.txt
|
| 63 |
-
|
| 64 |
-
echo.
|
| 65 |
-
echo π₯ Installing base packages...
|
| 66 |
-
pip install -r requirements.txt
|
| 67 |
-
|
| 68 |
-
echo.
|
| 69 |
-
echo β‘ Installing PyTorch (CUDA 12.1 build)...
|
| 70 |
-
pip install torch torchvision torchaudio --index-url %TORCH_INDEX%
|
| 71 |
-
|
| 72 |
-
echo.
|
| 73 |
-
echo β
Verifying important packages...
|
| 74 |
-
python -c "import torch; print('Torch version:', torch.__version__)"
|
| 75 |
-
python -c "from langchain_groq import ChatGroq; print('β
langchain_groq available')"
|
| 76 |
-
python -c "from faster_whisper import WhisperModel; print('β
faster-whisper ready')"
|
| 77 |
-
python -c "import faiss; print('β
faiss-cpu available')"
|
| 78 |
-
|
| 79 |
-
echo.
|
| 80 |
-
echo π Setup complete! Environment '%ENV_NAME%' is ready to use.
|
| 81 |
-
endlocal
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
start-server.bat
DELETED
|
@@ -1,8 +0,0 @@
|
|
| 1 |
-
@echo off
|
| 2 |
-
echo π Activating virtual environment...
|
| 3 |
-
call .\myenv\Scripts\activate
|
| 4 |
-
|
| 5 |
-
echo π Starting FastAPI server...
|
| 6 |
-
python -m uvicorn app.main:app --reload
|
| 7 |
-
|
| 8 |
-
pause
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
worker/daemon.py
CHANGED
|
@@ -75,11 +75,11 @@ async def process_pending_videos():
|
|
| 75 |
logger.info(f"Lightweight agentic analysis completed for video {video.id}")
|
| 76 |
except Exception as agentic_error:
|
| 77 |
logger.warning(f"Lightweight agentic analysis failed, falling back to basic Whisper: {agentic_error}")
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
db=session
|
| 82 |
-
|
| 83 |
logger.info(f"Basic Whisper analysis completed for video {video.id}")
|
| 84 |
|
| 85 |
except Exception as e:
|
|
|
|
| 75 |
logger.info(f"Lightweight agentic analysis completed for video {video.id}")
|
| 76 |
except Exception as agentic_error:
|
| 77 |
logger.warning(f"Lightweight agentic analysis failed, falling back to basic Whisper: {agentic_error}")
|
| 78 |
+
transcription, summary = await whisper_llm.analyze(
|
| 79 |
+
video_url=video.video_url,
|
| 80 |
+
user_id=video.user_id,
|
| 81 |
db=session
|
| 82 |
+
)
|
| 83 |
logger.info(f"Basic Whisper analysis completed for video {video.id}")
|
| 84 |
|
| 85 |
except Exception as e:
|