Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -392,6 +392,7 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
| 392 |
|
| 393 |
import gradio as gr
|
| 394 |
import torch
|
|
|
|
| 395 |
def generate_from_prompt(prompt):
|
| 396 |
try:
|
| 397 |
messages = [{"role": "user", "content": prompt}]
|
|
@@ -418,6 +419,7 @@ def generate_from_prompt(prompt):
|
|
| 418 |
|
| 419 |
except Exception as e:
|
| 420 |
return f"Error during generation: {e}"
|
|
|
|
| 421 |
def generate_model_from_description(description):
|
| 422 |
if not description.strip():
|
| 423 |
return "Error: Description is required."
|
|
@@ -560,8 +562,27 @@ with gr.Blocks(title="C# Validator Generator with 8 Tabs") as demo:
|
|
| 560 |
outputs=[model_code_output_desc]
|
| 561 |
)
|
| 562 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 563 |
# Tab 3 to Tab 8 placeholders for future features
|
| 564 |
-
for i in range(
|
| 565 |
with gr.Tab(f"Tab {i} - Placeholder"):
|
| 566 |
gr.Markdown(f"Content for Tab {i} goes here...")
|
| 567 |
|
|
|
|
| 392 |
|
| 393 |
import gradio as gr
|
| 394 |
import torch
|
| 395 |
+
@spaces.GPU
|
| 396 |
def generate_from_prompt(prompt):
|
| 397 |
try:
|
| 398 |
messages = [{"role": "user", "content": prompt}]
|
|
|
|
| 419 |
|
| 420 |
except Exception as e:
|
| 421 |
return f"Error during generation: {e}"
|
| 422 |
+
@spaces.GPU
|
| 423 |
def generate_model_from_description(description):
|
| 424 |
if not description.strip():
|
| 425 |
return "Error: Description is required."
|
|
|
|
| 562 |
outputs=[model_code_output_desc]
|
| 563 |
)
|
| 564 |
|
| 565 |
+
with gr.Tab("Generate from Description"):
|
| 566 |
+
with gr.Row():
|
| 567 |
+
with gr.Column():
|
| 568 |
+
description_inputt = gr.Textbox(
|
| 569 |
+
label="Project Description",
|
| 570 |
+
lines=10,
|
| 571 |
+
placeholder="Enter your project or model description here..."
|
| 572 |
+
)
|
| 573 |
+
generate_model_desc_btnt = gr.Button("Generate Model Code")
|
| 574 |
+
|
| 575 |
+
with gr.Column():
|
| 576 |
+
model_code_output_desct = gr.Code(label="Generated Model Code", lines=25)
|
| 577 |
+
|
| 578 |
+
generate_model_desc_btnt.click(
|
| 579 |
+
fn=generate_from_prompt,
|
| 580 |
+
inputs=[description_inputt],
|
| 581 |
+
outputs=[model_code_output_desct]
|
| 582 |
+
)
|
| 583 |
+
|
| 584 |
# Tab 3 to Tab 8 placeholders for future features
|
| 585 |
+
for i in range(5, 9):
|
| 586 |
with gr.Tab(f"Tab {i} - Placeholder"):
|
| 587 |
gr.Markdown(f"Content for Tab {i} goes here...")
|
| 588 |
|