Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,8 @@ warnings.filterwarnings("ignore")
|
|
12 |
logging.set_verbosity_error()
|
13 |
|
14 |
# Global variables
|
15 |
-
|
|
|
16 |
MAX_LENGTH = 2048
|
17 |
MAX_NEW_TOKENS = 512
|
18 |
TEMPERATURE = 0.7
|
@@ -37,7 +38,7 @@ def load_model_and_tokenizer():
|
|
37 |
tokenizer = AutoTokenizer.from_pretrained(
|
38 |
MODEL_ID,
|
39 |
use_fast=True,
|
40 |
-
trust_remote_code=True
|
41 |
)
|
42 |
|
43 |
# Load model with optimizations for limited resources
|
@@ -46,7 +47,7 @@ def load_model_and_tokenizer():
|
|
46 |
device_map="auto",
|
47 |
torch_dtype=torch.bfloat16,
|
48 |
load_in_4bit=True,
|
49 |
-
trust_remote_code=True
|
50 |
)
|
51 |
|
52 |
print("Model and tokenizer loaded successfully!")
|
@@ -162,7 +163,7 @@ def health_check():
|
|
162 |
# Gradio Web UI
|
163 |
def create_ui():
|
164 |
with gr.Blocks() as demo:
|
165 |
-
gr.Markdown("#
|
166 |
|
167 |
with gr.Row():
|
168 |
with gr.Column():
|
@@ -218,8 +219,4 @@ if __name__ == "__main__":
|
|
218 |
|
219 |
# Create and launch Gradio interface
|
220 |
demo = create_ui()
|
221 |
-
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|
222 |
-
|
223 |
-
# Flask won't reach here when Gradio is running
|
224 |
-
# If you want to run Flask separately:
|
225 |
-
# app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860)))
|
|
|
12 |
logging.set_verbosity_error()
|
13 |
|
14 |
# Global variables
|
15 |
+
# Updated to use a model that's actually available on Hugging Face
|
16 |
+
MODEL_ID = "microsoft/phi-2" # Alternative: "microsoft/phi-1_5" or any other available model
|
17 |
MAX_LENGTH = 2048
|
18 |
MAX_NEW_TOKENS = 512
|
19 |
TEMPERATURE = 0.7
|
|
|
38 |
tokenizer = AutoTokenizer.from_pretrained(
|
39 |
MODEL_ID,
|
40 |
use_fast=True,
|
41 |
+
trust_remote_code=True
|
42 |
)
|
43 |
|
44 |
# Load model with optimizations for limited resources
|
|
|
47 |
device_map="auto",
|
48 |
torch_dtype=torch.bfloat16,
|
49 |
load_in_4bit=True,
|
50 |
+
trust_remote_code=True
|
51 |
)
|
52 |
|
53 |
print("Model and tokenizer loaded successfully!")
|
|
|
163 |
# Gradio Web UI
|
164 |
def create_ui():
|
165 |
with gr.Blocks() as demo:
|
166 |
+
gr.Markdown("# AI Assistant with Step-by-Step Thinking")
|
167 |
|
168 |
with gr.Row():
|
169 |
with gr.Column():
|
|
|
219 |
|
220 |
# Create and launch Gradio interface
|
221 |
demo = create_ui()
|
222 |
+
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|
|
|
|
|
|
|
|