Spaces:
Paused
Paused
Update app.py via AI Editor
Browse files
app.py
CHANGED
@@ -1,25 +1,3 @@
|
|
1 |
-
Let's break down the changes needed:
|
2 |
-
|
3 |
-
1. **Switch from OpenAI to Gemini**:
|
4 |
-
- Remove all `openai` imports and usage.
|
5 |
-
- Use `google.generativeai` (Gemini) and set up the API key from `GEMINI_KEY`.
|
6 |
-
- Replace the `openai.ChatCompletion.create` logic with Gemini's chat completion API using the specified model.
|
7 |
-
|
8 |
-
2. **Fix duplicate callback for store-shred.data**:
|
9 |
-
- The callback for document generation (Outputting to many stores) is duplicated with allow_duplicate. Instead, combine all outputs/logic so each store is only output in a single callback. This means the chat update callback must update only the relevant store, and not all stores, and outputs must be refactored to avoid duplication.
|
10 |
-
|
11 |
-
3. **No unnecessary changes**:
|
12 |
-
- No unrelated changes (e.g., don't touch CSS, layout, or unrelated logic).
|
13 |
-
|
14 |
-
4. **Other requirements**:
|
15 |
-
- Use threading for Gemini requests.
|
16 |
-
- Comprehensive logging.
|
17 |
-
- No duplicate callbacks.
|
18 |
-
- All imports, global vars, etc.
|
19 |
-
|
20 |
-
Here is the revised code:
|
21 |
-
|
22 |
-
```
|
23 |
import base64
|
24 |
import io
|
25 |
import os
|
@@ -1000,5 +978,4 @@ def auto_expand_textarea(value, current_rows):
|
|
1000 |
if __name__ == '__main__':
|
1001 |
print("Starting the Dash application...")
|
1002 |
app.run(debug=True, host='0.0.0.0', port=7860, threaded=True)
|
1003 |
-
print("Dash application has finished running.")
|
1004 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import base64
|
2 |
import io
|
3 |
import os
|
|
|
978 |
if __name__ == '__main__':
|
979 |
print("Starting the Dash application...")
|
980 |
app.run(debug=True, host='0.0.0.0', port=7860, threaded=True)
|
981 |
+
print("Dash application has finished running.")
|
|