Spaces:
Sleeping
Sleeping
fix according to zoa llm
Browse files
app.py
CHANGED
@@ -18,25 +18,28 @@ def generate(prompt):
|
|
18 |
{"role": "system", "content": "You are HTML Web Developer. enerate HTML code using Tailwind CSS framework and Shadcn UI components. Add HTML tags to the code. Don't forget to use the correct classes. Don't write inline styles and descriptions."},
|
19 |
{"role": "user", "content": prompt}
|
20 |
]
|
21 |
-
text = tokenizer.apply_chat_template(
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
)
|
26 |
-
model_inputs = tokenizer([text], return_tensors="pt").to("cuda")
|
27 |
|
28 |
-
|
29 |
-
# response = tokenizer.decode(output[0], skip_special_tokens=True)
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
)
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
40 |
|
41 |
return response
|
42 |
|
|
|
18 |
{"role": "system", "content": "You are HTML Web Developer. enerate HTML code using Tailwind CSS framework and Shadcn UI components. Add HTML tags to the code. Don't forget to use the correct classes. Don't write inline styles and descriptions."},
|
19 |
{"role": "user", "content": prompt}
|
20 |
]
|
21 |
+
# text = tokenizer.apply_chat_template(
|
22 |
+
# messages,
|
23 |
+
# tokenize=False,
|
24 |
+
# add_generation_prompt=True
|
25 |
+
# )
|
|
|
26 |
|
27 |
+
inputs = tokenizer(messages, return_tensors="pt").to("cuda")
|
|
|
28 |
|
29 |
+
output = model.generate(**inputs, max_length=2500)
|
30 |
+
response = tokenizer.decode(output[0], skip_special_tokens=True)
|
31 |
+
|
32 |
+
# model_inputs = tokenizer([text], return_tensors="pt").to("cuda")
|
33 |
+
|
34 |
+
# generated_ids = model.generate(
|
35 |
+
# **model_inputs,
|
36 |
+
# max_new_tokens=512
|
37 |
+
# )
|
38 |
+
# generated_ids = [
|
39 |
+
# output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
40 |
+
# ]
|
41 |
|
42 |
+
# response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
43 |
|
44 |
return response
|
45 |
|