File size: 2,240 Bytes
b52a08f
efaff76
 
 
b52a08f
efaff76
 
 
 
 
b52a08f
efaff76
 
 
b52a08f
efaff76
 
 
 
 
 
 
 
 
 
b52a08f
 
efaff76
 
 
 
 
 
 
 
 
 
 
 
b52a08f
efaff76
 
 
 
b52a08f
efaff76
 
 
 
b52a08f
efaff76
 
 
 
b52a08f
efaff76
 
 
 
b52a08f
efaff76
 
 
 
b52a08f
efaff76
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import gradio as gr
import requests
import torch
from diffusers import StableDiffusionPipeline

# --- Load Diffusers model ---
pipe = StableDiffusionPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5",
    torch_dtype=torch.float16
).to("cuda")  # use GPU if available

# --- Functions ---
def greet(name):
    return f"Hello {name}, welcome to AeroVortex ๐Ÿš€"

def ask_openassistant(prompt):
    url = "https://api.open-assistant.io"  # replace with actual endpoint
    try:
        response = requests.post(url, json={"prompt": prompt})
        return response.json().get("reply", "No response")
    except Exception as e:
        return f"Error contacting OpenAssistant: {e}"

def upload_file(file):
    return f"File {file.name} uploaded successfully to AeroVortex storage."

def generate_image(prompt):
    try:
        image = pipe(prompt).images[0]
        return image
    except Exception as e:
        return f"Error generating image: {e}"

def draft_document(text):
    return f"Drafted document with content: {text[:50]}..."

# --- Gradio Dashboard ---
with gr.Blocks() as demo:
    gr.Markdown("# ๐ŸŒ AeroVortex Dashboard")

    with gr.Tab("Greeting"):
        name = gr.Textbox(label="Enter your name")
        output = gr.Textbox(label="Greeting")
        name.submit(greet, inputs=name, outputs=output)

    with gr.Tab("Ask OpenAssistant"):
        prompt = gr.Textbox(label="Enter your prompt")
        reply = gr.Textbox(label="OpenAssistant reply")
        prompt.submit(ask_openassistant, inputs=prompt, outputs=reply)

    with gr.Tab("File Upload"):
        file = gr.File(label="Upload a file")
        file_output = gr.Textbox(label="Upload status")
        file.upload(upload_file, inputs=file, outputs=file_output)

    with gr.Tab("Image Generation"):
        img_prompt = gr.Textbox(label="Enter image prompt")
        img_output = gr.Image(label="Generated image")
        img_prompt.submit(generate_image, inputs=img_prompt, outputs=img_output)

    with gr.Tab("Document Drafting"):
        doc_text = gr.Textbox(label="Enter draft text", lines=5)
        doc_output = gr.Textbox(label="Draft status")
        doc_text.submit(draft_document, inputs=doc_text, outputs=doc_output)

demo.launch()