ad4r5hgs commited on
Commit
3e16d33
1 Parent(s): 366c843

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +81 -0
  2. requirements.txt +0 -0
app.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+
4
+ def generate_pdf(prompt):
5
+ from fpdf import FPDF
6
+
7
+ pdf = FPDF()
8
+ pdf.add_page()
9
+ pdf.set_font("Arial", size=12)
10
+ pdf.multi_cell(0, 10, prompt)
11
+ pdf_file = "/mnt/data/generated_prompt.pdf"
12
+ pdf.output(pdf_file)
13
+ return pdf_file
14
+
15
+
16
+ # Advanced features
17
+ def get_advanced_features():
18
+ with gr.Accordion("Advanced Features", open=False):
19
+ temp = gr.Slider(
20
+ 0.0,
21
+ 1.0,
22
+ value=0.5,
23
+ label="Model Temperature",
24
+ step=0.05, interactive=True,
25
+ info="Higher values produce more diverse outputs"
26
+ )
27
+ context_len = gr.Slider(
28
+ 0,
29
+ 2048,
30
+ value=512,
31
+ label="Context Length",
32
+ step=64,
33
+ interactive=True,
34
+ info="The maximum numbers of tokens"
35
+ )
36
+ return temp, context_len
37
+
38
+
39
+ with gr.Blocks() as demo:
40
+ gr.Markdown(
41
+ """
42
+ <center><h2>AI-Powered Prompt to PDF Generator</h2></center>
43
+ <p>Welcome to the AI-Powered Prompt to PDF Generator! This tool allows you to select different AI models, customize their parameters, and generate personalized content in PDF format.</p>
44
+ <p><b>Features:</b></p>
45
+ <ul>
46
+ <li>Select from various AI models</li>
47
+ <li>Adjust advanced parameters like model temperature and context length</li>
48
+ <li>Input your custom prompt to generate content</li>
49
+ <li>Download the generated content as a PDF</li>
50
+ </ul>
51
+ <p><b>Note:</b> This tool is designed to help you experiment with different AI models and generate unique content based on your inputs. The process may take some time depending on the complexity of the prompt and model selected.</p>
52
+ """
53
+ )
54
+
55
+ with gr.Tab("Select Model"):
56
+ model_dropdown = gr.Dropdown(
57
+ ["Model 1", "Model 2", "Model 3"],
58
+ label="Select Model"
59
+ )
60
+ temperature, context_length = get_advanced_features()
61
+
62
+ with gr.Tab("Model Selection"):
63
+ model_radio = gr.Radio(
64
+ ["Huggingface/ModelA", "Huggingface/ModelB", "Huggingface/ModelC"],
65
+ label="Choose a Model"
66
+ )
67
+
68
+ with gr.Tab("Prompt"):
69
+ prompt_text = gr.Textbox(
70
+ label="Enter your prompt here",
71
+ lines=10,
72
+ placeholder="Type your prompt..."
73
+ )
74
+
75
+ with gr.Tab("Generate Output"):
76
+ generate_button = gr.Button("Generate PDF")
77
+ output_file = gr.File(label="Download your PDF")
78
+
79
+ generate_button.click(generate_pdf, inputs=prompt_text, outputs=output_file)
80
+
81
+ demo.launch(share=True, show_api=False)
requirements.txt ADDED
Binary file (6.36 kB). View file