peace2024 commited on
Commit
7e867e7
Β·
1 Parent(s): 08d7c19

saving changes

Browse files
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
- 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:
 
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: