Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
3 |
from fpdf import FPDF
|
4 |
import torch
|
5 |
import spaces
|
|
|
|
|
6 |
|
7 |
# Initialize the Qwen model and tokenizer
|
8 |
model_name = "Qwen/Qwen2.5-Coder-7B-Instruct"
|
@@ -28,7 +30,7 @@ def generate_documentation(code_input):
|
|
28 |
generated_ids = [output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)]
|
29 |
documentation = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
30 |
print(documentation)
|
31 |
-
return documentation
|
32 |
|
33 |
# Function to generate and download PDF
|
34 |
def create_pdf(documentation):
|
|
|
3 |
from fpdf import FPDF
|
4 |
import torch
|
5 |
import spaces
|
6 |
+
import io
|
7 |
+
import markdown
|
8 |
|
9 |
# Initialize the Qwen model and tokenizer
|
10 |
model_name = "Qwen/Qwen2.5-Coder-7B-Instruct"
|
|
|
30 |
generated_ids = [output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)]
|
31 |
documentation = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
32 |
print(documentation)
|
33 |
+
return markdown.markdown(documentation)
|
34 |
|
35 |
# Function to generate and download PDF
|
36 |
def create_pdf(documentation):
|