Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -36,7 +36,6 @@ h1 {
|
|
36 |
|
37 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
|
38 |
|
39 |
-
|
40 |
|
41 |
|
42 |
def extract_text(path):
|
@@ -99,18 +98,14 @@ def mode_load(path):
|
|
99 |
|
100 |
@spaces.GPU()
|
101 |
def stream_chat(message, history: list, temperature: float, max_length: int, top_p: float, top_k: int, penalty: float):
|
102 |
-
|
103 |
-
|
104 |
-
model = AutoModelForCausalLM.from_pretrained(
|
105 |
MODEL_ID,
|
106 |
torch_dtype=torch.bfloat16,
|
107 |
low_cpu_mem_usage=True,
|
108 |
trust_remote_code=True
|
109 |
-
|
110 |
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
print(f'message is - {message}')
|
115 |
print(f'history is - {history}')
|
116 |
conversation = []
|
@@ -250,5 +245,5 @@ with gr.Blocks(css=CSS, theme="soft", fill_height=True) as demo:
|
|
250 |
),
|
251 |
gr.Examples(EXAMPLES, [chat_input])
|
252 |
|
253 |
-
|
254 |
-
demo.queue(api_open=False).launch(show_api=False, share=False, )#server_name="0.0.0.0", )
|
|
|
36 |
|
37 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
|
38 |
|
|
|
39 |
|
40 |
|
41 |
def extract_text(path):
|
|
|
98 |
|
99 |
@spaces.GPU()
|
100 |
def stream_chat(message, history: list, temperature: float, max_length: int, top_p: float, top_k: int, penalty: float):
|
101 |
+
if history.len()==0:
|
102 |
+
model = AutoModelForCausalLM.from_pretrained(
|
|
|
103 |
MODEL_ID,
|
104 |
torch_dtype=torch.bfloat16,
|
105 |
low_cpu_mem_usage=True,
|
106 |
trust_remote_code=True
|
107 |
+
)
|
108 |
|
|
|
|
|
|
|
109 |
print(f'message is - {message}')
|
110 |
print(f'history is - {history}')
|
111 |
conversation = []
|
|
|
245 |
),
|
246 |
gr.Examples(EXAMPLES, [chat_input])
|
247 |
|
248 |
+
if __name__ == "__main__":
|
249 |
+
demo.queue(api_open=False).launch(show_api=False, share=False, )#server_name="0.0.0.0", )
|