Spaces:
Sleeping
Sleeping
update app.py
Browse files
app.py
CHANGED
@@ -71,6 +71,7 @@ def chat_completion(
|
|
71 |
top_k: int,
|
72 |
top_p: float,
|
73 |
):
|
|
|
74 |
if model is None:
|
75 |
reload_model(DEFAULT_MODEL)
|
76 |
prompt = generate_alpaca_prompt(instruction=message)
|
@@ -91,8 +92,7 @@ def chat_completion(
|
|
91 |
|
92 |
def reload_model(model_name: str):
|
93 |
global model
|
94 |
-
|
95 |
-
del model
|
96 |
gc.collect()
|
97 |
model = Llama.from_pretrained(
|
98 |
**model_paths[model_name],
|
@@ -107,7 +107,7 @@ def reload_model(model_name: str):
|
|
107 |
height=500,
|
108 |
placeholder='<strong>Hi doctor, I have a headache, what should I do?</strong>',
|
109 |
label=model_name,
|
110 |
-
avatar_images=[None, 'https://raw.githubusercontent.com/minhnguyent546/medical-llama2/
|
111 |
)
|
112 |
return app_title_mark, chatbot
|
113 |
|
@@ -139,7 +139,7 @@ def main() -> None:
|
|
139 |
height=500,
|
140 |
placeholder='<strong>Hi doctor, I have a headache, what should I do?</strong>',
|
141 |
label=DEFAULT_MODEL,
|
142 |
-
avatar_images=[None, 'https://raw.githubusercontent.com/minhnguyent546/medical-llama2/
|
143 |
)
|
144 |
textbox = gr.Textbox(
|
145 |
placeholder='Hi doctor, I have a headache, what should I do?',
|
|
|
71 |
top_k: int,
|
72 |
top_p: float,
|
73 |
):
|
74 |
+
global model
|
75 |
if model is None:
|
76 |
reload_model(DEFAULT_MODEL)
|
77 |
prompt = generate_alpaca_prompt(instruction=message)
|
|
|
92 |
|
93 |
def reload_model(model_name: str):
|
94 |
global model
|
95 |
+
model = None
|
|
|
96 |
gc.collect()
|
97 |
model = Llama.from_pretrained(
|
98 |
**model_paths[model_name],
|
|
|
107 |
height=500,
|
108 |
placeholder='<strong>Hi doctor, I have a headache, what should I do?</strong>',
|
109 |
label=model_name,
|
110 |
+
avatar_images=[None, 'https://raw.githubusercontent.com/minhnguyent546/medical-llama2/refs/heads/master/assets/medical_llama2.png'], # pyright: ignore[reportArgumentType]
|
111 |
)
|
112 |
return app_title_mark, chatbot
|
113 |
|
|
|
139 |
height=500,
|
140 |
placeholder='<strong>Hi doctor, I have a headache, what should I do?</strong>',
|
141 |
label=DEFAULT_MODEL,
|
142 |
+
avatar_images=[None, 'https://raw.githubusercontent.com/minhnguyent546/medical-llama2/refs/heads/master/assets/medical_llama2.png'], # pyright: ignore[reportArgumentType]
|
143 |
)
|
144 |
textbox = gr.Textbox(
|
145 |
placeholder='Hi doctor, I have a headache, what should I do?',
|