Ancastal commited on
Commit
52819f4
·
verified ·
1 Parent(s): dc4e3e8

Delete .github/workflows

Browse files
.github/workflows/deploy.yml DELETED
@@ -1,169 +0,0 @@
1
- name: Deploy Gradio App
2
-
3
- on:
4
- push:
5
- branches: [ main ]
6
- pull_request:
7
- branches: [ main ]
8
- workflow_dispatch:
9
-
10
- jobs:
11
- deploy:
12
- runs-on: ubuntu-latest
13
-
14
- steps:
15
- - name: Checkout code
16
- uses: actions/checkout@v4
17
-
18
- - name: Set up Python
19
- uses: actions/setup-python@v4
20
- with:
21
- python-version: '3.11'
22
-
23
- - name: Cache pip dependencies
24
- uses: actions/cache@v3
25
- with:
26
- path: ~/.cache/pip
27
- key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
28
- restore-keys: |
29
- ${{ runner.os }}-pip-
30
-
31
- - name: Install dependencies
32
- run: |
33
- python -m pip install --upgrade pip
34
- pip install -r requirements.txt
35
-
36
- - name: Download spaCy model
37
- run: python -m spacy download en_core_web_sm
38
-
39
- - name: Create config file
40
- run: |
41
- cat > config.yaml << EOF
42
- openai:
43
- api_key: ${{ secrets.OPENAI_API_KEY }}
44
- model: "gpt-3.5-turbo"
45
- max_tokens: 1500
46
- temperature: 0.7
47
-
48
- database:
49
- url: "sqlite:///chatbot.db"
50
-
51
- vector_store:
52
- persist_directory: "./chroma_db"
53
- collection_name: "business_transactions"
54
-
55
- intent_classifier:
56
- confidence_threshold: 0.7
57
-
58
- entity_extraction:
59
- spacy_model: "en_core_web_sm"
60
- EOF
61
-
62
- - name: Initialize database
63
- run: python -c "from src.database_manager import DatabaseManager; db = DatabaseManager(); db.create_tables()"
64
-
65
- - name: Run tests (if available)
66
- run: |
67
- if [ -d "tests" ] && [ -n "$(ls -A tests/*.py 2>/dev/null)" ]; then
68
- python -m pytest tests/ -v
69
- else
70
- echo "No tests found, skipping test step"
71
- fi
72
- continue-on-error: true
73
-
74
- - name: Deploy to Hugging Face Spaces
75
- if: github.ref == 'refs/heads/main'
76
- env:
77
- HF_TOKEN: ${{ secrets.HF_TOKEN }}
78
- OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
79
- run: |
80
- # Install huggingface_hub
81
- pip install huggingface_hub
82
-
83
- # Create a simple app.py for HF Spaces
84
- cat > app.py << 'EOF'
85
- #!/usr/bin/env python3
86
- import os
87
- import sys
88
- from pathlib import Path
89
-
90
- # Add gui directory to path
91
- gui_dir = Path(__file__).parent / "gui"
92
- sys.path.append(str(gui_dir))
93
-
94
- if __name__ == "__main__":
95
- from gradio_interface import GradioInterface
96
-
97
- gui = GradioInterface()
98
- gui.launch(
99
- server_name="0.0.0.0",
100
- server_port=7860,
101
- share=False,
102
- debug=False
103
- )
104
- EOF
105
-
106
- # Create requirements.txt for HF Spaces
107
- cp requirements.txt requirements_hf.txt
108
-
109
- # Upload to Hugging Face Spaces
110
- python -c "
111
- from huggingface_hub import HfApi, upload_folder
112
- import os
113
-
114
- api = HfApi(token=os.environ['HF_TOKEN'])
115
-
116
- # Create or update the space
117
- try:
118
- api.create_repo(
119
- repo_id='${{ github.repository_owner }}/llm-chatbot',
120
- repo_type='space',
121
- space_sdk='gradio',
122
- exist_ok=True
123
- )
124
- print('Space created/updated successfully')
125
- except Exception as e:
126
- print(f'Error creating space: {e}')
127
-
128
- # Upload files
129
- try:
130
- upload_folder(
131
- folder_path='.',
132
- repo_id='${{ github.repository_owner }}/llm-chatbot',
133
- repo_type='space',
134
- token=os.environ['HF_TOKEN'],
135
- ignore_patterns=['.git*', '__pycache__', '*.pyc', 'chroma_db', '*.db']
136
- )
137
- print('Files uploaded successfully')
138
- except Exception as e:
139
- print(f'Error uploading files: {e}')
140
- "
141
-
142
- - name: Deploy to Railway (Alternative)
143
- if: github.ref == 'refs/heads/main' && env.RAILWAY_TOKEN != ''
144
- env:
145
- RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
146
- run: |
147
- # Install Railway CLI
148
- npm install -g @railway/cli
149
-
150
- # Create Procfile for Railway
151
- echo "web: python run_gui.py --host 0.0.0.0 --port \$PORT" > Procfile
152
-
153
- # Deploy to Railway
154
- railway login --token $RAILWAY_TOKEN
155
- railway up
156
- continue-on-error: true
157
-
158
- - name: Deploy Summary
159
- run: |
160
- echo "🚀 Deployment completed!"
161
- echo "📱 Your Gradio app should be available at:"
162
- echo " - Hugging Face Spaces: https://huggingface.co/spaces/${{ github.repository_owner }}/llm-chatbot"
163
- if [ -n "${{ secrets.RAILWAY_TOKEN }}" ]; then
164
- echo " - Railway: Check Railway dashboard for URL"
165
- fi
166
- echo "🔧 Make sure to set the required secrets in your repository:"
167
- echo " - OPENAI_API_KEY: Your OpenAI API key"
168
- echo " - HF_TOKEN: Your Hugging Face token"
169
- echo " - RAILWAY_TOKEN: Your Railway token (optional)"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.github/workflows/update_space.yml DELETED
@@ -1,28 +0,0 @@
1
- name: Run Python script
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- jobs:
9
- build:
10
- runs-on: ubuntu-latest
11
-
12
- steps:
13
- - name: Checkout
14
- uses: actions/checkout@v2
15
-
16
- - name: Set up Python
17
- uses: actions/setup-python@v2
18
- with:
19
- python-version: '3.9'
20
-
21
- - name: Install Gradio
22
- run: python -m pip install gradio
23
-
24
- - name: Log in to Hugging Face
25
- run: python -c 'import huggingface_hub; huggingface_hub.login(token="${{ secrets.hf_token }}")'
26
-
27
- - name: Deploy to Spaces
28
- run: gradio deploy