File size: 3,343 Bytes
5cb5b61
4c6e87c
5cb5b61
00e8bf1
 
4c6e87c
 
00e8bf1
 
 
 
 
 
 
4c6e87c
 
00e8bf1
4c6e87c
 
 
 
 
 
00e8bf1
4c6e87c
 
 
00e8bf1
4c6e87c
 
 
00e8bf1
4c6e87c
 
 
 
 
 
 
 
 
00e8bf1
 
 
 
 
4c6e87c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
00e8bf1
4c6e87c
00e8bf1
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
68
69
70
71
72
73
74
75
76
77
78
79
import gradio as gr
import requests, sqlite3, secrets

API_URL = "https://Mauricio-100-agent-ai.hf.space/infer"

# --- Fonctions de base ---
def call_model(system_prompt, user_prompt, temperature, max_new_tokens, top_p):
    payload = {
        "input": user_prompt,
        "system_prompt": system_prompt,
        "temperature": temperature,
        "max_new_tokens": int(max_new_tokens),
        "top_p": top_p
    }
    r = requests.post(API_URL, json=payload)
    return r.json().get("generated_text", "") if r.status_code == 200 else f"[Erreur {r.status_code}]"

def handle_text(system_prompt, user_prompt, temperature, max_new_tokens, top_p):
    return call_model(system_prompt, user_prompt, temperature, max_new_tokens, top_p)

def handle_image(image, system_prompt, temperature, max_new_tokens, top_p):
    # Ici tu pourrais envoyer l’image à un service externe (OCR, vision, etc.)
    return f"[Image reçue] {image.name if image else 'aucune'}"

def handle_video(video, system_prompt):
    # Placeholder : analyse vidéo ou résumé
    return f"[Vidéo reçue] {video.name if video else 'aucune'}"

def handle_web(query):
    # Placeholder : appel à une API de recherche web
    return f"Résultats simulés pour la recherche: {query}"

def handle_audio(audio):
    # Placeholder : transcription ou TTS
    return f"[Audio reçu] {audio}"

# --- Interface Gradio ---
with gr.Blocks(title="⚡ GopuOS Multimodal Hub") as demo:
    gr.Markdown("## ⚡ GopuOS Multimodal Hub")

    with gr.Tab("💬 Texte"):
        sys_prompt = gr.Textbox(label="Prompt système")
        user_prompt = gr.Textbox(label="Texte utilisateur")
        temp = gr.Slider(0.1, 1.5, value=0.7, step=0.1, label="Température")
        max_tok = gr.Slider(50, 500, value=200, step=10, label="Max new tokens")
        top_p = gr.Slider(0.1, 1.0, value=0.9, step=0.05, label="Top-p")
        out_text = gr.Textbox(label="Réponse")
        btn = gr.Button("Envoyer")
        btn.click(fn=handle_text, inputs=[sys_prompt, user_prompt, temp, max_tok, top_p], outputs=out_text)

    with gr.Tab("🖼️ Image"):
        img = gr.Image(type="file", label="Uploader une image")
        sys_prompt_img = gr.Textbox(label="Prompt système")
        out_img = gr.Textbox(label="Réponse")
        btn_img = gr.Button("Analyser")
        btn_img.click(fn=handle_image, inputs=[img, sys_prompt_img, temp, max_tok, top_p], outputs=out_img)

    with gr.Tab("🎥 Vidéo"):
        vid = gr.File(label="Uploader une vidéo")
        sys_prompt_vid = gr.Textbox(label="Prompt système")
        out_vid = gr.Textbox(label="Réponse")
        btn_vid = gr.Button("Analyser")
        btn_vid.click(fn=handle_video, inputs=[vid, sys_prompt_vid], outputs=out_vid)

    with gr.Tab("🌐 Web"):
        query = gr.Textbox(label="Requête de recherche")
        out_web = gr.Textbox(label="Résultats")
        btn_web = gr.Button("Rechercher")
        btn_web.click(fn=handle_web, inputs=query, outputs=out_web)

    with gr.Tab("🎙️ Voix"):
        audio = gr.Audio(type="filepath", label="Uploader un fichier audio")
        out_audio = gr.Textbox(label="Résultat")
        btn_audio = gr.Button("Transcrire / Répondre")
        btn_audio.click(fn=handle_audio, inputs=audio, outputs=out_audio)

# Hugging Face Spaces attend une variable "app" ou "demo"
app = demo