coingimp commited on
Commit
1237e8b
Β·
verified Β·
1 Parent(s): 08924f0

Create INSTALL.md

Browse files
Files changed (1) hide show
  1. INSTALL.md +147 -0
INSTALL.md ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AI Writer β€” Installation Guide
2
+
3
+ ## Quick Start (Local)
4
+
5
+ ### 1. Prerequisites
6
+
7
+ - Python 3.9 or higher
8
+ - pip package manager
9
+
10
+ ### 2. Install Dependencies
11
+
12
+ ```bash
13
+ cd "AI Writer"
14
+ pip install -r requirements.txt
15
+ ```
16
+
17
+ ### 3. Run the Application
18
+
19
+ ```bash
20
+ python app.py
21
+ ```
22
+
23
+ The application will start on `http://localhost:7860`.
24
+
25
+ ---
26
+
27
+ ## Hugging Face Spaces Deployment
28
+
29
+ ### 1. Create a New Space
30
+
31
+ 1. Go to [huggingface.co/spaces](https://huggingface.co/spaces)
32
+ 2. Click **Create new Space**
33
+ 3. Choose **Gradio** as the SDK
34
+ 4. Name your Space (e.g., `ai-writer`)
35
+
36
+ ### 2. Upload Files
37
+
38
+ Upload all files from the `AI Writer` folder to your Space repository:
39
+
40
+ ```
41
+ β”œβ”€β”€ app.py
42
+ β”œβ”€β”€ requirements.txt
43
+ β”œβ”€β”€ system_prompt.md
44
+ β”œβ”€β”€ editor_prompt.md
45
+ β”œβ”€β”€ INSTALL.md
46
+ β”œβ”€β”€ README.md
47
+ └── utils/
48
+ β”œβ”€β”€ __init__.py
49
+ β”œβ”€β”€ api_client.py
50
+ β”œβ”€β”€ docx_parser.py
51
+ β”œβ”€β”€ editor.py
52
+ └── style_analyzer.py
53
+ ```
54
+
55
+ ### 3. Set Environment Variables (Optional)
56
+
57
+ If you want to set the API token as a secret environment variable:
58
+
59
+ 1. Go to your Space **Settings**
60
+ 2. Under **Repository secrets**, add:
61
+ - Name: `GLM_API_TOKEN`
62
+ - Value: your API token
63
+
64
+ ### 4. Space Will Build Automatically
65
+
66
+ Hugging Face will install the dependencies from `requirements.txt` and launch `app.py`.
67
+
68
+ ---
69
+
70
+ ## Changing the GLM API Key
71
+
72
+ ### Method 1: Through the UI (Recommended)
73
+
74
+ 1. Open the AI Writer application
75
+ 2. Go to the **βš™οΈ API Settings** tab
76
+ 3. In the **API Token** field, paste your new token
77
+ 4. Click **πŸ” Test Connection** to verify the token works
78
+ 5. The new token will be used for all subsequent requests in the current session
79
+
80
+ > **Note:** The token set through the UI is stored only in the current session. It will reset to the default when you reload the page.
81
+
82
+ ### Method 2: Change the Default Token in Code
83
+
84
+ 1. Open `utils/api_client.py` in a text editor
85
+ 2. Find the line:
86
+ ```python
87
+ DEFAULT_TOKEN = "modalresearch_-z6GDDZ_VYtv7RlIuppxp5Vll50nSaDLtAOO-A5OnrI"
88
+ ```
89
+ 3. Replace the token value with your new token:
90
+ ```python
91
+ DEFAULT_TOKEN = "your_new_token_here"
92
+ ```
93
+ 4. Save the file and restart the application
94
+
95
+ ### Method 3: Environment Variable (Hugging Face Spaces)
96
+
97
+ 1. Go to your Space **Settings**
98
+ 2. Under **Repository secrets**, add or update:
99
+ - Name: `GLM_API_TOKEN`
100
+ - Value: your new API token
101
+ 3. The Space will restart automatically
102
+
103
+ To use the environment variable, modify the `DEFAULT_TOKEN` in `utils/api_client.py`:
104
+
105
+ ```python
106
+ import os
107
+ DEFAULT_TOKEN = os.environ.get("GLM_API_TOKEN", "modalresearch_-z6GDDZ_VYtv7RlIuppxp5Vll50nSaDLtAOO-A5OnrI")
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Changing the Model
113
+
114
+ By default, the application uses `zai-org/GLM-5.1-FP8`. To change the model:
115
+
116
+ 1. Open the **βš™οΈ API Settings** tab in the UI
117
+ 2. Change the **Model Name** field to your desired model
118
+ 3. Or edit `utils/api_client.py` and change `DEFAULT_MODEL`
119
+
120
+ ---
121
+
122
+ ## Troubleshooting
123
+
124
+ ### API Connection Fails
125
+
126
+ - Check your internet connection
127
+ - Verify the API token is correct
128
+ - Ensure the API endpoint URL is accessible from your network
129
+ - The default endpoint is: `https://api.us-west-2.modal.direct/v1/chat/completions`
130
+
131
+ ### DOCX Files Not Loading
132
+
133
+ - Ensure files are in `.docx` format (not `.doc` or `.txt`)
134
+ - Try re-saving the file in Microsoft Word or LibreOffice
135
+ - Check that the file is not password-protected
136
+
137
+ ### Generation Takes Too Long
138
+
139
+ - Reduce the `max_words` parameter
140
+ - Lower the `temperature` slightly
141
+ - The API may have rate limits; wait a moment and try again
142
+
143
+ ### Generated Text Contains Dashes or Quotation Marks
144
+
145
+ - The automated editor should remove these, but the LLM editor pass may reintroduce them
146
+ - The system runs two editor passes (automated + LLM) to minimize this
147
+ - If issues persist, try regenerating the article